-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_auth_flow.py
More file actions
43 lines (39 loc) · 1.12 KB
/
test_auth_flow.py
File metadata and controls
43 lines (39 loc) · 1.12 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
import requests
import sys
BASE_URL = "http://127.0.0.1:8000"
def test_signup_login():
# 1. Signup
print("1. Testing Signup...")
signup_data = {
"restaurant_name": "Test Bistro",
"username": "owner",
"password": "password123"
}
try:
r = requests.post(f"{BASE_URL}/signup", json=signup_data)
print(f"Signup Status: {r.status_code}")
print(f"Signup Response: {r.text}")
if r.status_code != 200:
print("Signup Failed")
return
except Exception as e:
print(f"Signup Exception: {e}")
return
# 2. Login
print("\n2. Testing Login...")
login_data = {
"username": "owner",
"password": "password123"
}
try:
r = requests.post(f"{BASE_URL}/token", data=login_data)
print(f"Login Status: {r.status_code}")
print(f"Login Response: {r.text}")
if r.status_code == 200:
print("Login Successful")
else:
print("Login Failed")
except Exception as e:
print(f"Login Exception: {e}")
if __name__ == "__main__":
test_signup_login()