74 lines
2.1 KiB
Python
74 lines
2.1 KiB
Python
"""
|
|
Test script to verify shots endpoints
|
|
"""
|
|
import requests
|
|
import json
|
|
|
|
BASE_URL = "http://localhost:8000"
|
|
|
|
# Test credentials
|
|
LOGIN_DATA = {
|
|
"email": "admin@vfx.com",
|
|
"password": "admin123"
|
|
}
|
|
|
|
|
|
def login():
|
|
"""Login and get access token"""
|
|
response = requests.post(f"{BASE_URL}/auth/login", json=LOGIN_DATA)
|
|
if response.status_code == 200:
|
|
return response.json()["access_token"]
|
|
else:
|
|
print(f"Login failed: {response.status_code}")
|
|
return None
|
|
|
|
|
|
def test_shots_endpoints():
|
|
"""Test shots endpoints"""
|
|
print("=== Test: Shots Endpoints ===\n")
|
|
|
|
token = login()
|
|
if not token:
|
|
return
|
|
|
|
headers = {"Authorization": f"Bearer {token}"}
|
|
|
|
# Test 1: List all shots
|
|
print("1. Testing GET /shots")
|
|
response = requests.get(f"{BASE_URL}/shots", headers=headers)
|
|
print(f" Status: {response.status_code}")
|
|
if response.status_code == 200:
|
|
shots = response.json()
|
|
print(f" Total shots: {len(shots)}")
|
|
if shots:
|
|
print(f" First shot: {shots[0]['name']} (ID: {shots[0]['id']})")
|
|
else:
|
|
print(f" Error: {response.json()}")
|
|
|
|
# Test 2: List shots for episode 1
|
|
print("\n2. Testing GET /shots?episode_id=1")
|
|
response = requests.get(f"{BASE_URL}/shots?episode_id=1", headers=headers)
|
|
print(f" Status: {response.status_code}")
|
|
if response.status_code == 200:
|
|
shots = response.json()
|
|
print(f" Shots in episode 1: {len(shots)}")
|
|
for shot in shots[:3]:
|
|
print(f" - {shot['name']} (ID: {shot['id']})")
|
|
else:
|
|
print(f" Error: {response.json()}")
|
|
|
|
# Test 3: Try the old endpoint (should fail)
|
|
print("\n3. Testing GET /projects/1/shots?episode_id=1 (should fail)")
|
|
response = requests.get(f"{BASE_URL}/projects/1/shots?episode_id=1", headers=headers)
|
|
print(f" Status: {response.status_code}")
|
|
if response.status_code == 404:
|
|
print(f" ✓ Correctly returns 404 (endpoint doesn't exist)")
|
|
else:
|
|
print(f" Response: {response.json()}")
|
|
|
|
print("\n=== Test Completed ===")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
test_shots_endpoints()
|