Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRAFT: 17/fuzz tests initial implementation #31

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.venv
__pycache__
.pytest_cache
.hypothesis
dist
.vscode
183 changes: 92 additions & 91 deletions ergast_py/constants/expected.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" Expected class """
import datetime


class Expected:
Expand All @@ -8,21 +9,21 @@ class Expected:
Each model has a set of keys, and the types expected.

Types are stored as one of the following strings:
* "int"
* "float"
* "string"
* "dict" """
* int
* float
* str
* dict"""

@property
def location(self):
"""
Return the expected types of a Location
"""
return {
"lat": "float",
"long": "float",
"locality": "string",
"country": "string",
"lat": float,
"long": float,
"locality": str,
"country": str,
}

@property
Expand All @@ -31,10 +32,10 @@ def circuit(self):
Return the expected types of a Circuit
"""
return {
"circuitId": "string",
"url": "string",
"circuitName": "string",
"Location": "string",
"circuitId": str,
"url": str,
"circuitName": str,
"Location": str,
}

@property
Expand All @@ -43,10 +44,10 @@ def constructor(self):
Return the expected types of a Constructor
"""
return {
"constructorId": "string",
"url": "string",
"name": "string",
"nationality": "string",
"constructorId": str,
"url": str,
"name": str,
"nationality": str,
}

@property
Expand All @@ -55,14 +56,14 @@ def driver(self):
Return the expected types of a Driver
"""
return {
"driverId": "string",
"permanentNumber": "int",
"code": "string",
"url": "string",
"givenName": "string",
"familyName": "string",
"dateOfBirth": "string",
"nationality": "string",
"driverId": str,
"permanentNumber": int,
"code": str,
"url": str,
"givenName": str,
"familyName": str,
"dateOfBirth": str,
"nationality": str,
}

@property
Expand All @@ -71,23 +72,23 @@ def race(self):
Return the expected types of a Race
"""
return {
"season": "int",
"round": "int",
"url": "string",
"raceName": "string",
"Circuit": "dict",
"date": "string",
"time": "string",
"Results": "dict",
"FirstPractice": "dict",
"SecondPractice": "dict",
"ThirdPractice": "dict",
"Sprint": "dict",
"SprintResults": "dict",
"Qualifying": "dict",
"QualifyingResults": "dict",
"PitStops": "dict",
"Laps": "dict",
"season": int,
"round": int,
"url": str,
"raceName": str,
"Circuit": dict,
"date": str,
"time": str,
"Results": dict,
"FirstPractice": dict,
"SecondPractice": dict,
"ThirdPractice": dict,
"Sprint": dict,
"SprintResults": dict,
"Qualifying": dict,
"QualifyingResults": dict,
"PitStops": dict,
"Laps": dict,
}

@property
Expand All @@ -96,20 +97,20 @@ def result(self):
Return the expected types of a Result
"""
return {
"number": "int",
"position": "int",
"positionText": "string",
"points": "float",
"Driver": "dict",
"Constructor": "dict",
"grid": "int",
"laps": "int",
"status": "string",
"Time": "dict",
"FastestLap": "dict",
"Q1": "string",
"Q2": "string",
"Q3": "string",
"number": int,
"position": int,
"positionText": str,
"points": float,
"Driver": dict,
"Constructor": dict,
"grid": int,
"laps": int,
"status": str,
"Time": dict,
"FastestLap": dict,
"Q1": str,
"Q2": str,
"Q3": str,
}

@property
Expand All @@ -118,10 +119,10 @@ def fastest_lap(self):
Return the expected types of a Fastest Lap
"""
return {
"rank": "int",
"lap": "int",
"Time": "dict",
"AverageSpeed": "dict",
"rank": int,
"lap": int,
"Time": dict,
"AverageSpeed": dict,
}

@property
Expand All @@ -130,8 +131,8 @@ def average_speed(self):
Return the expected types of a Average Speed
"""
return {
"units": "string",
"speed": "float",
"units": str,
"speed": float,
}

@property
Expand All @@ -140,11 +141,11 @@ def pit_stop(self):
Return the expected types of a Pit Stop
"""
return {
"driverId": "string",
"lap": "int",
"stop": "int",
"time": "string",
"duration": "string",
"driverId": str,
"lap": int,
"stop": int,
"time": str,
"duration": str,
}

@property
Expand All @@ -153,8 +154,8 @@ def lap(self):
Return the expected types of a Lap
"""
return {
"number": "int",
"Timings": "dict",
"number": int,
"Timings": dict,
}

@property
Expand All @@ -163,9 +164,9 @@ def timing(self):
Return the expected types of a Timing
"""
return {
"driverId": "string",
"position": "int",
"time": "string",
"driverId": str,
"position": int,
"time": str,
}

@property
Expand All @@ -174,29 +175,29 @@ def season(self):
Return the expected types of a Season
"""
return {
"season": "int",
"url": "string",
"season": int,
"url": str,
}

@property
def status(self):
"""
Return the expected types of a Status
"""
return {"statusId": "int", "count": "int", "status": "string"}
return {"statusId": int, "count": int, "status": str}

@property
def driver_standing(self):
"""
Return the expected types of a Driver Standing
"""
return {
"position": "int",
"positionText": "string",
"points": "float",
"wins": "int",
"Driver": "dict",
"Constructors": "dict",
"position": int,
"positionText": str,
"points": float,
"wins": int,
"Driver": dict,
"Constructors": dict,
}

@property
Expand All @@ -205,11 +206,11 @@ def constructor_standing(self):
Return the expected types of a Constructor Standing
"""
return {
"position": "int",
"positionText": "string",
"points": "float",
"wins": "int",
"Constructor": "dict",
"position": int,
"positionText": str,
"points": float,
"wins": int,
"Constructor": dict,
}

@property
Expand All @@ -218,10 +219,10 @@ def standings_list(self):
Return the expected types of a Standings List
"""
return {
"season": "int",
"round": "int",
"DriverStandings": "dict",
"ConstructorStandings": "dict",
"season": int,
"round": int,
"DriverStandings": dict,
"ConstructorStandings": dict,
}

@property
Expand All @@ -230,6 +231,6 @@ def time(self):
Return the expected types of a Time
"""
return {
"millis": "datetime.time",
"time": "string",
"millis": datetime.time,
"time": str,
}
6 changes: 3 additions & 3 deletions ergast_py/type_constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ def __init__(self) -> None:
def _populate_missing(expected: dict, actual: dict) -> dict:
for item in expected:
if item not in actual:
if expected[item] == "dict":
if expected[item] == dict:
actual[item] = {}
elif expected[item] == "float":
elif expected[item] == float:
actual[item] = "0.0"
elif expected[item] == "int":
elif expected[item] == int:
actual[item] = "0"
else:
actual[item] = ""
Expand Down
Loading
Loading