#!/usr/bin/env python3 """ Test updating existing asset tasks with custom statuses """ import requests BASE_URL = 'http://localhost:8000' def login(): """Login and get access token""" response = requests.post(f'{BASE_URL}/auth/login', json={'email': 'admin@vfx.com', 'password': 'admin123'}) if response.status_code != 200: print("❌ Login failed") return None return response.json()['access_token'] def test_asset_task_update(): token = login() if not token: return headers = {'Authorization': f'Bearer {token}'} # Get asset 34 tasks response = requests.get(f'{BASE_URL}/assets/34/task-status', headers=headers) print(f"Get asset task status - Status: {response.status_code}") if response.status_code == 200: tasks = response.json() print(f"Found {len(tasks)} tasks:") for task in tasks: print(f" Task {task['task_id']}: {task['task_type']} - {task['status']}") # Try to update the first task to a custom status if task['task_id']: update_data = {'status': 'custom_9441a740'} # Use the custom status from the test update_response = requests.put(f'{BASE_URL}/tasks/{task["task_id"]}', json=update_data, headers=headers) print(f"Update task {task['task_id']} - Status: {update_response.status_code}") if update_response.status_code == 200: print(f"✅ Successfully updated task {task['task_id']} to custom status") break else: print(f"❌ Failed to update task: {update_response.text}") else: print(f"Failed to get asset tasks: {response.text}") if __name__ == "__main__": test_asset_task_update()