mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-29 20:47:00 -05:00
feat: Implement MFA authentication, add ride statistics model, and update various services, APIs, and tests across the application.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import os
|
||||
import django
|
||||
import sys
|
||||
import json
|
||||
|
||||
import django
|
||||
|
||||
# Setup Django environment
|
||||
sys.path.append('/Volumes/macminissd/Projects/thrillwiki_django_no_react/backend')
|
||||
@@ -10,20 +10,19 @@ django.setup()
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from rest_framework.test import APIClient
|
||||
from rest_framework import status
|
||||
from apps.lists.models import UserList, ListItem
|
||||
|
||||
from apps.parks.models import Park
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
def run_verification():
|
||||
print("Starting Backend Verification...")
|
||||
|
||||
|
||||
# 1. Create Test User
|
||||
username = "verify_user"
|
||||
email = "verify@example.com"
|
||||
password = "password123"
|
||||
|
||||
|
||||
user, created = User.objects.get_or_create(username=username, email=email)
|
||||
user.set_password(password)
|
||||
user.save()
|
||||
@@ -44,7 +43,7 @@ def run_verification():
|
||||
# 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')
|
||||
if response.status_code == 200:
|
||||
print(f"Profile updated successfully: {response.data.get('unit_system')}")
|
||||
@@ -75,19 +74,12 @@ def run_verification():
|
||||
if not park:
|
||||
print("Creating dummy park for testing...")
|
||||
park = Park.objects.create(name="Test Park", slug="test-park", country="US")
|
||||
|
||||
item_data = {
|
||||
"user_list": list_id,
|
||||
"content_type": "parks.park", # format app.model
|
||||
"object_id": park.id,
|
||||
"rank": 1,
|
||||
"comment": "Top tier"
|
||||
}
|
||||
|
||||
# Note: Serializer might expect 'content_type' as ID or string.
|
||||
# Let's try string first if using slug-based or app-label based lookup.
|
||||
# If standard serializer, might be tricky.
|
||||
# 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}/')
|
||||
if response.status_code == 200:
|
||||
|
||||
Reference in New Issue
Block a user