-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify_migration.py
More file actions
74 lines (62 loc) · 2.22 KB
/
verify_migration.py
File metadata and controls
74 lines (62 loc) · 2.22 KB
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
72
73
74
import requests
import json
BASE_URL = "http://localhost:5000/api"
# --- Test Data ---
NGO_DATA = {
"name": "Test NGO",
"email": "test@ngo.com",
"phone": "1234567890",
"password": "testpassword"
}
CASE_DATA = {
"description": "This is a test case.",
"location": "Test Location"
}
def run_verification():
"""Runs a series of tests to verify the MySQL migration."""
print("--- Starting MySQL Migration Verification ---")
# 1. Register a new NGO
try:
response = requests.post(f"{BASE_URL}/register/ngo", json=NGO_DATA)
response.raise_for_status()
print("✅ NGO Registration: PASSED")
except requests.exceptions.RequestException as e:
print(f"❌ NGO Registration: FAILED - {e}")
return
# 2. Log in as the new NGO
try:
login_data = {"email": NGO_DATA["email"], "password": NGO_DATA["password"], "role": "NGO"}
response = requests.post(f"{BASE_URL}/auth/login", json=login_data)
response.raise_for_status()
token = response.json().get("access_token")
if not token:
print("❌ NGO Login: FAILED - No access token returned")
return
print("✅ NGO Login: PASSED")
except requests.exceptions.RequestException as e:
print(f"❌ NGO Login: FAILED - {e}")
return
headers = {"Authorization": f"Bearer {token}"}
# 3. Create a new case
try:
response = requests.post(f"{BASE_URL}/cases", json=CASE_DATA, headers=headers)
response.raise_for_status()
print("✅ Case Creation: PASSED")
except requests.exceptions.RequestException as e:
print(f"❌ Case Creation: FAILED - {e}")
return
# 4. Fetch cases
try:
response = requests.get(f"{BASE_URL}/cases", headers=headers)
response.raise_for_status()
cases = response.json()
if not cases:
print("❌ Case Fetching: FAILED - No cases returned")
return
print("✅ Case Fetching: PASSED")
except requests.exceptions.RequestException as e:
print(f"❌ Case Fetching: FAILED - {e}")
return
print("\n--- MySQL Migration Verification Complete ---")
if __name__ == "__main__":
run_verification()