import requests import json # API endpoint for user signup API_URL = "http://localhost:8000/api/auth/signup" def create_test_user(): """Create a test user for API testing""" try: # Prepare the user data user_data = { "email": "testuser@example.com", "password": "Password123!", "display_name": "Test User", "organization": "Test Org", "role": "citizen" } # Make the API request print(f"Creating test user at {API_URL}") response = requests.post( API_URL, data=json.dumps(user_data), headers={"Content-Type": "application/json"} ) # Process the response if response.status_code == 200: result = response.json() print("User created successfully!") print(f"Token: {result.get('access_token')[:15]}...") print(f"User ID: {result.get('user', {}).get('id')}") return result else: print(f"API request failed with status code {response.status_code}") print(f"Response: {response.text}") return None except Exception as e: print(f"Error creating test user: {e}") return None if __name__ == "__main__": print("Creating test user for Marine Guard API") create_test_user()