fix: Update import paths to use 'apps' prefix for models and services

This commit is contained in:
pacnpal
2025-09-28 10:50:57 -04:00
parent 1b246eeaa4
commit bf04e4d854
6 changed files with 395 additions and 363 deletions

View File

@@ -2,8 +2,8 @@
"""
Basic test script to verify RideLocation and CompanyHeadquarters models work correctly.
"""
from rides.models import Ride, RideLocation
from parks.models import Company, CompanyHeadquarters
from apps.rides.models import Ride, RideLocation
from apps.parks.models import Company, CompanyHeadquarters
import os
import sys
import django
@@ -23,11 +23,11 @@ def test_company_headquarters():
print("⚠️ No existing companies found, skipping CompanyHeadquarters test")
return None, None
# Check if headquarters already exist
try:
headquarters = existing_company.headquarters
# Check if headquarters already exist (use queryset lookup to avoid relying on a reverse attribute name)
headquarters = CompanyHeadquarters.objects.filter(company=existing_company).first()
if headquarters:
print(f"✓ Found existing headquarters: {headquarters}")
except CompanyHeadquarters.DoesNotExist:
else:
# Create headquarters for existing company
headquarters = CompanyHeadquarters.objects.create(
company=existing_company,
@@ -53,7 +53,13 @@ def test_ride_location():
# First, we need a ride - let's check if any exist
if Ride.objects.exists():
ride = Ride.objects.first()
print(f"✓ Using existing ride: {ride.name}")
# Safely access the ride's name in case static analysis or runtime sees None/no attribute.
ride_name = getattr(ride, "name", None) if ride is not None else None
if ride_name:
print(f"✓ Using existing ride: {ride_name}")
else:
# Fall back to repr of the ride object to avoid AttributeError
print(f"✓ Using existing ride: {ride!r}")
else:
print("! No rides found in database - skipping RideLocation test")
return None, None
@@ -93,9 +99,9 @@ def cleanup_test_data(company=None, headquarters=None, ride_location=None):
headquarters.delete()
print("✓ Deleted test headquarters")
if company:
company.delete()
print("✓ Deleted test company")
# Do not delete an existing company record discovered in the database.
# Tests should avoid removing production/existing data. If a test created a Company
# instance explicitly, add logic to delete it here (not implemented by default).
def main():