LinkDesk/backend/test_asset_task_creation.py

41 lines
1.3 KiB
Python

#!/usr/bin/env python3
"""
Test asset task creation to debug the issue
"""
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_creation():
token = login()
if not token:
return
headers = {'Authorization': f'Bearer {token}'}
# Try to create a task for asset ID 32
response = requests.post(f'{BASE_URL}/assets/32/tasks?task_type=modeling', headers=headers)
print(f"Status: {response.status_code}")
print(f"Response: {response.text}")
if response.status_code != 201:
# Check if asset exists
asset_response = requests.get(f'{BASE_URL}/assets/32', headers=headers)
print(f"Asset exists check - Status: {asset_response.status_code}")
if asset_response.status_code == 200:
asset = asset_response.json()
print(f"Asset: {asset['name']} in project {asset['project_id']}")
else:
print("Asset not found")
if __name__ == "__main__":
test_asset_task_creation()