arnaucube
arnaucube/provojPublic Self-hosted repository
provoj/exampleTest.py
exampleTest.pyRaw
 1import provoj
 2import requests
 3
 4
 5test1 = provoj.NewTest("testing some function")
 6
 7a = "hello"
 8b = "world"
 9c = "hello"
10
11test1.equal("comparing a and b", a, b)
12test1.notequal("comparing a and b", a, b)
13
14test1.equal("comparing a and c", a, c)
15
16x = 2
17y = 3
18test1.bigger("comparing x and y", x, y)
19test1.smaller("comparing x and y", x, y)
20
21test1.length("checking length", a, 2)
22test1.length("checking length", a, 5)
23
24animals = ["cat", "dog", "racoon"]
25test1.length("checking the length of the array animals", animals, 3)
26
27test1.printScores()
28
29
30t2 = provoj.NewTest("Testing some websites")
31
32r = requests.get("https://www.github.com")
33t2.rStatus("get github", r)
34
35r = requests.get("https://arnaucode.com")
36t2.rStatus("get arnaucode.com", r)
37
38r = requests.get("https://arnaucode.com/fake")
39t2.rStatus("get arnaucode.com/fake_path", r)
40
41r = requests.get("https://arnaucode.com/blog")
42t2.rStatus("get arnaucode.com/blog", r)
43
44t2.printScores()
45
46
47tGithub = provoj.NewTest("Github API tests")
48
49r = requests.get("https://api.github.com")
50tGithub.rStatus("get api.github", r)
51r = requests.get("https://api.github.com/users/arnaucode")
52tGithub.rStatus("get https://api.github.com/users/arnaucode", r)
53jsonResp = r.json()
54tGithub.equal("checking quantity of followers", jsonResp["followers"], 100)
55tGithub.equal("checking quantity of public_repos", jsonResp["public_repos"], 77)
56
57r = requests.get("https://api.github.com/users/arnaucode/repos")
58tGithub.rStatus("get https://api.github.com/users/arnaucode/repos", r)
59jsonResp = r.json()
60tGithub.length("checking length of repos", jsonResp, 30)
61tGithub.equal("checking first repo", jsonResp[0]["name"], "argos")
62tGithub.equal("checking second repo", jsonResp[1]["name"], "coffeeminer")
63tGithub.equal("checking third repo", jsonResp[2]["name"], "bc")
64
65tGithub.printScores()