Refactor test utilities and enhance ASGI settings

- Cleaned up and standardized assertions in ApiTestMixin for API response validation.
- Updated ASGI settings to use os.environ for setting the DJANGO_SETTINGS_MODULE.
- Removed unused imports and improved formatting in settings.py.
- Refactored URL patterns in urls.py for better readability and organization.
- Enhanced view functions in views.py for consistency and clarity.
- Added .flake8 configuration for linting and style enforcement.
- Introduced type stubs for django-environ to improve type checking with Pylance.
This commit is contained in:
pacnpal
2025-08-20 19:51:59 -04:00
parent 69c07d1381
commit 66ed4347a9
230 changed files with 15094 additions and 11578 deletions

View File

@@ -1,5 +1,4 @@
from django.utils import timezone
from django.contrib.gis.geos import Point
from parks.models import Park, ParkLocation
from rides.models import Ride, RideModel, RollerCoasterStats
from rides.models import Manufacturer
@@ -9,11 +8,16 @@ park, _ = Park.objects.get_or_create(
name="Cedar Point",
slug="cedar-point",
defaults={
"description": "Cedar Point is a 364-acre amusement park located on a Lake Erie peninsula in Sandusky, Ohio.",
"description": (
"Cedar Point is a 364-acre amusement park located on a Lake Erie "
"peninsula in Sandusky, Ohio."
),
"website": "https://www.cedarpoint.com",
"size_acres": 364,
"opening_date": timezone.datetime(1870, 1, 1).date(), # Cedar Point opened in 1870
}
"opening_date": timezone.datetime(
1870, 1, 1
).date(), # Cedar Point opened in 1870
},
)
# Create location for Cedar Point
@@ -25,7 +29,7 @@ location, _ = ParkLocation.objects.get_or_create(
"state": "OH",
"postal_code": "44870",
"country": "USA",
}
},
)
# Set coordinates using the helper method
location.set_coordinates(-82.6839, 41.4822) # longitude, latitude
@@ -36,9 +40,12 @@ bm, _ = Manufacturer.objects.get_or_create(
name="Intamin",
slug="intamin",
defaults={
"description": "Intamin Amusement Rides is a design company known for creating some of the most thrilling and innovative roller coasters in the world.",
"website": "https://www.intaminworldwide.com"
}
"description": (
"Intamin Amusement Rides is a design company known for creating "
"some of the most thrilling and innovative roller coasters in the world."
),
"website": "https://www.intaminworldwide.com",
},
)
# Create Giga Coaster model
@@ -46,9 +53,12 @@ giga_model, _ = RideModel.objects.get_or_create(
name="Giga Coaster",
manufacturer=bm,
defaults={
"description": "A roller coaster type characterized by a height between 300399 feet and a complete circuit.",
"category": "RC" # Roller Coaster
}
"description": (
"A roller coaster type characterized by a height between 300399 feet "
"and a complete circuit."
),
"category": "RC", # Roller Coaster
},
)
# Create Millennium Force
@@ -57,9 +67,11 @@ millennium, _ = Ride.objects.get_or_create(
slug="millennium-force",
defaults={
"description": (
"Millennium Force is a steel roller coaster located at Cedar Point amusement park in Sandusky, Ohio. "
"It was built by Intamin of Switzerland and opened on May 13, 2000 as the world's first giga coaster, "
"a class of roller coasters having a height between 300 and 399 feet and a complete circuit."
"Millennium Force is a steel roller coaster located at Cedar Point "
"amusement park in Sandusky, Ohio. It was built by Intamin of "
"Switzerland and opened on May 13, 2000 as the world's first giga "
"coaster, a class of roller coasters having a height between 300 "
"and 399 feet and a complete circuit."
),
"park": park,
"category": "RC",
@@ -69,8 +81,8 @@ millennium, _ = Ride.objects.get_or_create(
"opening_date": timezone.datetime(2000, 5, 13).date(),
"min_height_in": 48, # 48 inches minimum height
"capacity_per_hour": 1300,
"ride_duration_seconds": 120 # 2 minutes
}
"ride_duration_seconds": 120, # 2 minutes
},
)
# Create stats for Millennium Force
@@ -89,8 +101,8 @@ RollerCoasterStats.objects.get_or_create(
"train_style": "Open-air stadium seating",
"trains_count": 3,
"cars_per_train": 9,
"seats_per_car": 4
}
"seats_per_car": 4,
},
)
print("Initial data created successfully!")
print("Initial data created successfully!")