#!/usr/bin/env python3 """ Test custom task status support in the optimized asset router. """ import requests import json def test_custom_status_support(): BASE_URL = 'http://localhost:8000' # Login login_response = requests.post(f'{BASE_URL}/auth/login', json={'email': 'admin@vfx.com', 'password': 'admin123'}) if login_response.status_code != 200: print("❌ Login failed") return token = login_response.json()['access_token'] headers = {'Authorization': f'Bearer {token}'} # Get projects to find one with custom task types projects_response = requests.get(f'{BASE_URL}/projects/', headers=headers) if projects_response.status_code != 200: print("❌ Failed to get projects") return projects = projects_response.json() project_id = projects[0]['id'] if projects else 2 print(f'Testing custom status support with project {project_id}...') # Test list assets with custom task types response = requests.get(f'{BASE_URL}/assets/?project_id={project_id}', headers=headers) print(f'List assets status: {response.status_code}') if response.status_code == 200: assets = response.json() print(f'Assets returned: {len(assets)}') if assets: asset = assets[0] task_status = asset.get('task_status', {}) task_details = asset.get('task_details', []) print(f'Task status keys: {list(task_status.keys())}') print(f'Task details count: {len(task_details)}') # Check if custom task types are included standard_types = ['modeling', 'surfacing', 'rigging'] all_types = list(task_status.keys()) custom_types = [t for t in all_types if t not in standard_types] if custom_types: print(f'Custom task types found: {custom_types}') else: print('No custom task types (using standard types only)') # Verify all task details have the required fields if task_details: sample_task = task_details[0] required_fields = ['task_type', 'status', 'task_id', 'assigned_user_id'] missing_fields = [f for f in required_fields if f not in sample_task] if missing_fields: print(f'❌ Missing fields in task details: {missing_fields}') else: print('✅ Task details have all required fields') print('✅ Custom status support test passed!') else: print('No assets found for testing') else: print(f'❌ List assets failed: {response.status_code}') if __name__ == "__main__": test_custom_status_support()