"""Test shot list endpoint with task status information""" import requests import json BASE_URL = "http://localhost:8000" # Login to get token 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:", login_response.text) exit(1) token = login_response.json()["access_token"] headers = {"Authorization": f"Bearer {token}"} # Get shots list print("\n=== Testing Shot List with Task Status ===\n") shots_response = requests.get( f"{BASE_URL}/shots/", headers=headers ) if shots_response.status_code == 200: shots = shots_response.json() print(f"Found {len(shots)} shots") if shots: print("\nFirst shot details:") shot = shots[0] print(f" ID: {shot['id']}") print(f" Name: {shot['name']}") print(f" Episode ID: {shot['episode_id']}") print(f" Frame Range: {shot['frame_start']}-{shot['frame_end']}") print(f" Status: {shot['status']}") print(f" Task Count: {shot['task_count']}") print(f" Task Status: {json.dumps(shot.get('task_status', {}), indent=4)}") print(f" Task Details: {json.dumps(shot.get('task_details', []), indent=4)}") else: print(f"Failed to get shots: {shots_response.status_code}") print(shots_response.text) # Test with episode filter print("\n=== Testing Shot List with Episode Filter ===\n") shots_response = requests.get( f"{BASE_URL}/shots/?episode_id=1", headers=headers ) if shots_response.status_code == 200: shots = shots_response.json() print(f"Found {len(shots)} shots in episode 1") else: print(f"Failed to get shots: {shots_response.status_code}") print(shots_response.text) # Test with task status filter print("\n=== Testing Shot List with Task Status Filter ===\n") shots_response = requests.get( f"{BASE_URL}/shots/?task_status_filter=layout:not_started", headers=headers ) if shots_response.status_code == 200: shots = shots_response.json() print(f"Found {len(shots)} shots with layout task not started") else: print(f"Failed to get shots: {shots_response.status_code}") print(shots_response.text) # Test with sorting print("\n=== Testing Shot List with Sorting ===\n") shots_response = requests.get( f"{BASE_URL}/shots/?sort_by=name&sort_direction=asc", headers=headers ) if shots_response.status_code == 200: shots = shots_response.json() print(f"Found {len(shots)} shots sorted by name") if shots: print(f" First shot: {shots[0]['name']}") if len(shots) > 1: print(f" Last shot: {shots[-1]['name']}") else: print(f"Failed to get shots: {shots_response.status_code}") print(shots_response.text) print("\n=== Test Complete ===")