gstepanov | 3ce37b8 | 2015-02-12 16:20:56 +0200 | [diff] [blame] | 1 | import json |
| 2 | import requests |
| 3 | |
| 4 | |
| 5 | def add_test(test_name, test_data, url): |
| 6 | if not url.endswith("/"): |
| 7 | url += '/' + test_name |
| 8 | |
| 9 | requests.post(url=url, data=json.dumps(test_data)) |
| 10 | |
| 11 | |
| 12 | def get_test(test_name, url): |
| 13 | if not url.endswith("/"): |
| 14 | url += '/' + test_name |
| 15 | |
| 16 | result = requests.get(url=url) |
| 17 | |
| 18 | return json.loads(result.content) |
| 19 | |
| 20 | |
| 21 | def get_all_tests(url): |
| 22 | result = requests.get(url=url) |
| 23 | return json.loads(result.content) |
| 24 | |
| 25 | |
| 26 | if __name__ == '__main__': |
| 27 | url = "http://0.0.0.0:5000/api/tests" |
| 28 | test = get_test("GA", url=url) |
| 29 | print test |
| 30 | |
| 31 | tests = get_all_tests(url=url) |
| 32 | print tests |
| 33 | |
| 34 | # test["type"] = "some build name" |
| 35 | # add_test("bla_bla", [test], url=url) |
| 36 | |
| 37 | tests = get_all_tests(url=url) |
| 38 | print len(tests) |