File size: 1,389 Bytes
54fe70d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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()