54 lines
1.9 KiB
Python
54 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Simple test to verify the optimized asset endpoints work correctly.
|
|
"""
|
|
|
|
import requests
|
|
import json
|
|
|
|
def test_asset_endpoints():
|
|
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}'}
|
|
|
|
# Test list assets
|
|
print('Testing list_assets...')
|
|
response = requests.get(f'{BASE_URL}/assets/?project_id=2', headers=headers)
|
|
print(f'Status: {response.status_code}')
|
|
|
|
if response.status_code == 200:
|
|
assets = response.json()
|
|
print(f'Assets returned: {len(assets)}')
|
|
if assets:
|
|
asset = assets[0]
|
|
print(f'Sample asset has task_status: {"task_status" in asset}')
|
|
print(f'Sample asset has task_details: {"task_details" in asset}')
|
|
print(f'Task count: {asset.get("task_count", 0)}')
|
|
|
|
# Test get single asset
|
|
asset_id = asset['id']
|
|
print(f'\nTesting get_asset({asset_id})...')
|
|
response = requests.get(f'{BASE_URL}/assets/{asset_id}', headers=headers)
|
|
print(f'Status: {response.status_code}')
|
|
|
|
if response.status_code == 200:
|
|
single_asset = response.json()
|
|
print(f'Asset has task_count: {"task_count" in single_asset}')
|
|
print(f'Task count: {single_asset.get("task_count", 0)}')
|
|
print('✅ All tests passed!')
|
|
else:
|
|
print('❌ get_asset failed')
|
|
else:
|
|
print('No assets found')
|
|
else:
|
|
print('❌ list_assets failed')
|
|
|
|
if __name__ == "__main__":
|
|
test_asset_endpoints() |