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.

48 lines
1.2 KiB

  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. To run this test, just need to run:
  7. python test.py
  8. '''
  9. import provoj
  10. import requests
  11. test = provoj.NewTest("testing padArchiver API Server")
  12. url = "http://127.0.0.1:3080"
  13. jsonData = {"link": "http://board.net/p/pad1", "dir": "Group1", "title": "Pad1"}
  14. r = requests.post(url + "/repos/repo01/pad", json=jsonData)
  15. test.rStatus("POST add new pad", r)
  16. print(r.json())
  17. jsonData = {"link": "http://board.net/p/pad2", "dir": "Group2", "title": "Pad2"}
  18. r = requests.post(url + "/repos/repo01/pad", json=jsonData)
  19. test.rStatus("POST add new pad", r)
  20. print(r.json())
  21. jsonData = {"link": "http://board.net/p/pad3", "dir": "Group2", "title": "Pad3"}
  22. r = requests.post(url + "/repos/repo01/pad", json=jsonData)
  23. test.rStatus("POST add new pad", r)
  24. print(r.json())
  25. r = requests.get(url + "/repos")
  26. test.rStatus("GET repos list", r)
  27. print(r.json())
  28. reposList = r.json()
  29. testRepo = reposList[0]
  30. r = requests.get(url + "/repos/" + testRepo)
  31. test.rStatus("GET repo " + testRepo + " list", r)
  32. print(r.json())
  33. test.printScores()