padArchiver/apiServer/test.py
apiServer/test.pyRaw
1'''
2 this script uses requests and provoj
3 provoj is a simple library to test endpoints of an API RESTful
4 provoj can be downloaded using: pip install provoj
5 provoj repository: https://github.com/arnaucode/provoj
6
7 To run this test, just need to run:
8 python test.py
9'''
10import provoj
11import requests
12
13
14test = provoj.NewTest("testing padArchiver API Server")
15
16url = "http://127.0.0.1:3080"
17
18
19
20jsonData = {"link": "http://board.net/p/pad1", "dir": "Group1", "title": "Pad1"}
21r = requests.post(url + "/repos/repo01/pad", json=jsonData)
22test.rStatus("POST add new pad", r)
23print(r.json())
24
25jsonData = {"link": "http://board.net/p/pad2", "dir": "Group2", "title": "Pad2"}
26r = requests.post(url + "/repos/repo01/pad", json=jsonData)
27test.rStatus("POST add new pad", r)
28print(r.json())
29
30jsonData = {"link": "http://board.net/p/pad3", "dir": "Group2", "title": "Pad3"}
31r = requests.post(url + "/repos/repo01/pad", json=jsonData)
32test.rStatus("POST add new pad", r)
33print(r.json())
34
35
36r = requests.get(url + "/repos")
37test.rStatus("GET repos list", r)
38print(r.json())
39reposList = r.json()
40testRepo = reposList[0]
41
42r = requests.get(url + "/repos/" + testRepo)
43test.rStatus("GET repo " + testRepo + " list", r)
44print(r.json())
45
46
47
48test.printScores()