Files
thrillwiki_django_no_react/tests/test_manufacturer_sync.py
pacnpal 1b246eeaa4 Add comprehensive test scripts for various models and services
- Implement tests for RideLocation and CompanyHeadquarters models to verify functionality and data integrity.
- Create a manual trigger test script for trending content calculation endpoint, including authentication and unauthorized access tests.
- Develop a manufacturer sync test to ensure ride manufacturers are correctly associated with ride models.
- Add tests for ParkLocation model, including coordinate setting and distance calculations between parks.
- Implement a RoadTripService test suite covering geocoding, route calculation, park discovery, and error handling.
- Create a unified map service test script to validate map functionality, API endpoints, and performance metrics.
2025-09-27 22:26:40 -04:00

66 lines
2.3 KiB
Python

#!/usr/bin/env python
"""
Test script to verify manufacturer syncing with ride models.
"""
import os
import sys
import django
# Add the backend directory to the Python path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'backend'))
# Set up Django
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings.local')
django.setup()
from apps.rides.models import Ride, RideModel, Company
from apps.parks.models import Park
def test_manufacturer_sync():
"""Test that ride manufacturer syncs with ride model manufacturer."""
print("Testing manufacturer sync with ride models...")
# Get a ride that has a ride_model
ride = Ride.objects.select_related('ride_model', 'ride_model__manufacturer', 'manufacturer').first()
if not ride:
print("No rides found in database")
return
print(f"\nRide: {ride.name}")
print(f"Park: {ride.park.name}")
if ride.ride_model:
print(f"Ride Model: {ride.ride_model.name}")
print(f"Ride Model Manufacturer: {ride.ride_model.manufacturer.name if ride.ride_model.manufacturer else 'None'}")
else:
print("Ride Model: None")
print(f"Ride Manufacturer: {ride.manufacturer.name if ride.manufacturer else 'None'}")
# Check if they match
if ride.ride_model and ride.ride_model.manufacturer:
if ride.manufacturer == ride.ride_model.manufacturer:
print("✅ Manufacturer is correctly synced with ride model")
else:
print("❌ Manufacturer is NOT synced with ride model")
print("This should be fixed by the new save() method")
# Test the fix by saving the ride
print("\nTesting fix by re-saving the ride...")
ride.save()
ride.refresh_from_db()
print(f"After save - Ride Manufacturer: {ride.manufacturer.name if ride.manufacturer else 'None'}")
if ride.manufacturer == ride.ride_model.manufacturer:
print("✅ Fix successful! Manufacturer is now synced")
else:
print("❌ Fix failed - manufacturer still not synced")
else:
print("⚠️ Cannot test sync - ride model has no manufacturer")
if __name__ == "__main__":
test_manufacturer_sync()