-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
executable file
·63 lines (53 loc) · 1.59 KB
/
test.py
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
import requests
import json
BASE = "http://127.0.0.1:5000"
def print_response(response):
print(f"Status Code: {response.status_code}")
print(json.dumps(response.json(), indent=2))
print("///////////////////")
# test for RegisterUser
print("Testing RegisterUser...")
response = requests.post(f"{BASE}/user", json={
"name": "Vaibhav Achuthananda",
"age": 23
})
print_response(response)
user_id = response.json()["id"]
# test for GetUser
print("Testing GetUser...")
response = requests.get(f"{BASE}/user/{user_id}")
print_response(response)
# test for AddWorkout
print("Testing AddWorkout...")
response = requests.put(f"{BASE}/workouts/{user_id}", json={
"date": "2024-10-20",
"time": "39:27",
"distance": "3mi"
})
print_response(response)
# test for ListWorkouts
print("Testing ListWorkouts...")
response = requests.get(f"{BASE}/workouts/{user_id}")
print_response(response)
# test for ListUsers
print("Testing for ListUsers...")
response = requests.get(f"{BASE}/users")
print_response(response)
# adding an extra user for following
print("Testing RegisterUser AGAIN...")
response = requests.post(f"{BASE}/user", json={
"name": "Rocco Polimeni",
"age": 27
})
print_response(response)
second_user_id = response.json()["id"]
# test for FollowFriend
print("Testing for FollowFriend...")
response = requests.put(f"{BASE}/follow-list/{user_id}", json={
"follow_id": second_user_id
})
print_response(response)
# test for ShowFriendWorkouts
print("Testing ShowFriendWorkouts...")
response = requests.get(f"{BASE}/follow-list/{user_id}/{second_user_id}")
print_response(response)