You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.8 KiB

6 years ago
  1. import provoj
  2. import requests
  3. test1 = provoj.NewTest("testing some function")
  4. a = "hello"
  5. b = "world"
  6. c = "hello"
  7. test1.equal("comparing a and b", a, b)
  8. test1.notequal("comparing a and b", a, b)
  9. test1.equal("comparing a and c", a, c)
  10. x = 2
  11. y = 3
  12. test1.bigger("comparing x and y", x, y)
  13. test1.smaller("comparing x and y", x, y)
  14. test1.length("checking length", a, 2)
  15. test1.length("checking length", a, 5)
  16. animals = ["cat", "dog", "racoon"]
  17. test1.length("checking the length of the array animals", animals, 3)
  18. test1.printScores()
  19. t2 = provoj.NewTest("Testing some websites")
  20. r = requests.get("https://www.github.com")
  21. t2.rStatus("get github", r)
  22. r = requests.get("https://arnaucode.com")
  23. t2.rStatus("get arnaucode.com", r)
  24. r = requests.get("https://arnaucode.com/fake")
  25. t2.rStatus("get arnaucode.com/fake_path", r)
  26. r = requests.get("https://arnaucode.com/blog")
  27. t2.rStatus("get arnaucode.com/blog", r)
  28. t2.printScores()
  29. tGithub = provoj.NewTest("Github API tests")
  30. r = requests.get("https://api.github.com")
  31. tGithub.rStatus("get api.github", r)
  32. r = requests.get("https://api.github.com/users/arnaucode")
  33. tGithub.rStatus("get https://api.github.com/users/arnaucode", r)
  34. jsonResp = r.json()
  35. tGithub.equal("checking quantity of followers", jsonResp["followers"], 100)
  36. tGithub.equal("checking quantity of public_repos", jsonResp["public_repos"], 77)
  37. r = requests.get("https://api.github.com/users/arnaucode/repos")
  38. tGithub.rStatus("get https://api.github.com/users/arnaucode/repos", r)
  39. jsonResp = r.json()
  40. tGithub.length("checking length of repos", jsonResp, 30)
  41. tGithub.equal("checking first repo", jsonResp[0]["name"], "argos")
  42. tGithub.equal("checking second repo", jsonResp[1]["name"], "coffeeminer")
  43. tGithub.equal("checking third repo", jsonResp[2]["name"], "bc")
  44. tGithub.printScores()