-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.py
More file actions
66 lines (38 loc) · 1.64 KB
/
tests.py
File metadata and controls
66 lines (38 loc) · 1.64 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
## testing the main.py with request module
import requests, json
BASEurl = "http://127.0.0.1:5000/" ## location of the API
data = [{"name":"first_video","likes":10,"views":1000},
{"name":"second_video","likes":10324,"views":100430},
{"name":"third_video","likes":1023,"views":100210}]
for i in range(0,3):
Video_response = requests.put(BASEurl + f"videos/{i+1}", json=data[i])
## putting the json attribute we set the header for application/json
print(Video_response.json())
print(Video_response.status_code)
for i in range(0,4):
Video_response = requests.get(BASEurl + f"videos/{i+1}")
print(Video_response.json())
print(Video_response.status_code)
#for i in range(0,3):
# Video_response = requests.delete(BASEurl + f"videos/{i+1}")
# print(Video_response)
#in delete methods we dont response any json data only the status code
#print(Video_response.status_code)
Video_response = requests.patch(BASEurl + "videos/1", json={"likes":999, "name":"new_video1"})
print(Video_response.status_code)
data = Video_response.text
data_json = json.loads(data)
print(data_json)
# testing delete
Video_response = requests.delete(BASEurl + "videos/2")
print(Video_response.text)
print(Video_response.status_code)
#Dont use this anymore --------------------------------------------
#response = requests.get(BASEurl + "helloworld/bill")
#response1 = requests.post(BASEurl + "helloworld/aslas/1")
#responsepaulo = requests.get(BASEurl + "testing")
#responsepaulo1 = requests.post(BASEurl + "testing")
#print(response.json())
#print(response1.json())
#print(responsepaulo.json())
#print(responsepaulo1.json())