mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2026-01-01 23:27:02 -05:00
feat: Implement initial schema and add various API, service, and management command enhancements across the application.
This commit is contained in:
@@ -4,17 +4,18 @@ import sys
|
||||
import django
|
||||
|
||||
# Setup Django environment
|
||||
sys.path.append('/Volumes/macminissd/Projects/thrillwiki_django_no_react/backend')
|
||||
sys.path.append("/Volumes/macminissd/Projects/thrillwiki_django_no_react/backend")
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.django.local")
|
||||
django.setup()
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from rest_framework.test import APIClient
|
||||
from django.contrib.auth import get_user_model # noqa: E402
|
||||
from rest_framework.test import APIClient # noqa: E402
|
||||
|
||||
from apps.parks.models import Park
|
||||
from apps.parks.models import Park # noqa: E402
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
def run_verification():
|
||||
print("Starting Backend Verification...")
|
||||
|
||||
@@ -36,19 +37,16 @@ def run_verification():
|
||||
# 3. Verify Profile Update (Unit System)
|
||||
# Endpoint: /api/v1/auth/user/ or /api/v1/accounts/me/ (depending on dj-rest-auth)
|
||||
# Let's try updating profile via PATCH /api/v1/auth/user/
|
||||
update_data = {
|
||||
"unit_system": "imperial",
|
||||
"location": "Test City, TS"
|
||||
}
|
||||
update_data = {"unit_system": "imperial", "location": "Test City, TS"}
|
||||
# Note: unit_system expects 'metric', 'imperial'.
|
||||
# Check if 'imperial' is valid key in RichChoiceField.
|
||||
# Assuming it is based on implementation plan.
|
||||
|
||||
response = client.patch('/api/v1/accounts/profile/update/', update_data, format='json')
|
||||
response = client.patch("/api/v1/accounts/profile/update/", update_data, format="json")
|
||||
if response.status_code == 200:
|
||||
print(f"Profile updated successfully: {response.data.get('unit_system')}")
|
||||
if response.data.get('unit_system') != 'imperial':
|
||||
print(f"WARNING: unit_system mismatch. Got {response.data.get('unit_system')}")
|
||||
if response.data.get("unit_system") != "imperial":
|
||||
print(f"WARNING: unit_system mismatch. Got {response.data.get('unit_system')}")
|
||||
else:
|
||||
print(f"FAILED to update profile: {response.status_code} {response.data}")
|
||||
|
||||
@@ -56,13 +54,13 @@ def run_verification():
|
||||
# Create List
|
||||
list_data = {
|
||||
"title": "My Favorite Coasters",
|
||||
"category": "RC", # Roller Coaster
|
||||
"category": "RC", # Roller Coaster
|
||||
"description": "Best rides ever",
|
||||
"is_public": True
|
||||
"is_public": True,
|
||||
}
|
||||
response = client.post('/api/v1/lists/lists/', list_data, format='json')
|
||||
response = client.post("/api/v1/lists/lists/", list_data, format="json")
|
||||
if response.status_code == 201:
|
||||
list_id = response.data['id']
|
||||
list_id = response.data["id"]
|
||||
print(f"UserList created: {list_id} - {response.data['title']}")
|
||||
else:
|
||||
print(f"FAILED to create UserList: {response.status_code} {response.data}")
|
||||
@@ -81,7 +79,7 @@ def run_verification():
|
||||
# Alternatively, use specialized endpoint or just test UserList creation for now.
|
||||
|
||||
# Actually, let's just check if we can GET the list
|
||||
response = client.get(f'/api/v1/lists/lists/{list_id}/')
|
||||
response = client.get(f"/api/v1/lists/lists/{list_id}/")
|
||||
if response.status_code == 200:
|
||||
print(f"UserList retrieved: {response.data['title']}")
|
||||
else:
|
||||
@@ -89,5 +87,6 @@ def run_verification():
|
||||
|
||||
print("Verification Complete.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_verification()
|
||||
|
||||
Reference in New Issue
Block a user