File size: 1,806 Bytes
d2426db | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | """
Test script to verify the signup endpoint works.
"""
import requests
import json
API_BASE_URL = "http://localhost:8000"
def test_signup():
"""Test user signup."""
print("Testing signup endpoint...")
payload = {
"email": "testuser@example.com",
"name": "Test User",
"password": "SecurePass123!",
"role": "STAFF"
}
try:
response = requests.post(
f"{API_BASE_URL}/auth/signup",
json=payload
)
print(f"Status Code: {response.status_code}")
print(f"Response: {json.dumps(response.json(), indent=2)}")
if response.status_code == 201:
print("β
Signup successful!")
return True
else:
print("β Signup failed!")
return False
except Exception as e:
print(f"β Error: {e}")
return False
def test_health():
"""Test health endpoint."""
print("\nTesting health endpoint...")
try:
response = requests.get(f"{API_BASE_URL}/health")
print(f"Status Code: {response.status_code}")
print(f"Response: {json.dumps(response.json(), indent=2)}")
if response.status_code == 200:
print("β
Backend is healthy!")
return True
else:
print("β Backend health check failed!")
return False
except Exception as e:
print(f"β Error: {e}")
return False
if __name__ == "__main__":
print("=" * 50)
print("API Test Script")
print("=" * 50)
# Test health first
if test_health():
# Then test signup
test_signup()
else:
print("\nβ Backend is not responding. Make sure it's running on port 8000.")
|