Spaces:
Sleeping
Sleeping
| import os | |
| import requests | |
| import json | |
| from dotenv import load_dotenv | |
| # Load environment variables | |
| load_dotenv() | |
| # Base URL for API | |
| BASE_URL = "http://localhost:5000/api" | |
| def test_create_department(): | |
| """Test creating a new department with an admin user""" | |
| # Department data | |
| department_data = { | |
| "name": "Test Police Department", | |
| "address": "123 Test Street, Test City, TS 12345", | |
| "website": "https://test-pd.example.com", | |
| "admin_email": "admin@test-pd.example.com", | |
| "admin_name": "Admin User", | |
| "admin_password": "SecurePassword123" | |
| } | |
| # Make POST request to create department | |
| response = requests.post(f"{BASE_URL}/departments", json=department_data) | |
| # Print response details | |
| print(f"Status Code: {response.status_code}") | |
| print("Response:") | |
| print(json.dumps(response.json(), indent=2)) | |
| return response.json() | |
| def main(): | |
| """Run test functions""" | |
| print("=== Testing Department Creation ===") | |
| result = test_create_department() | |
| # If department was created successfully, store admin details | |
| if result.get('department') and result.get('admin_user'): | |
| print("\n=== Department Created Successfully ===") | |
| print(f"Department Name: {result['department']['name']}") | |
| print(f"Admin Email: {result['admin_user']['email']}") | |
| print("You can now use these details to test the auth endpoints") | |
| if __name__ == "__main__": | |
| main() |