"""
Test if the backend has the latest code changes
"""
import requests

BASE_URL = "http://localhost:8000"

print("Testing if backend has the fix...")
print("=" * 60)

# Check if backend is running
try:
    response = requests.get(f"{BASE_URL}/docs")
    if response.status_code == 200:
        print("✓ Backend is running")
    else:
        print("✗ Backend returned unexpected status")
        exit(1)
except Exception as e:
    print(f"✗ Backend is not running: {e}")
    print("\nStart backend with:")
    print("cd backend")
    print("uvicorn main:app --reload --host 0.0.0.0 --port 8000")
    exit(1)

# Check the actual code to see if fix is present
print("\nChecking if code fix is present...")
with open('routers/shots.py', 'r') as f:
    content = f.read()
    if 'if current_user.is_admin or current_user.role == UserRole.COORDINATOR:' in content:
        print("✓ Code fix IS present in shots.py")
    else:
        print("✗ Code fix NOT found in shots.py")
        print("  The file might have been reverted")

print("\n" + "=" * 60)
print("IMPORTANT: If backend is running WITHOUT --reload flag,")
print("you MUST restart it manually for changes to take effect!")
print("=" * 60)
