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("/"): |
gstepanov | 8053b01 | 2015-02-16 17:25:27 +0200 | [diff] [blame] | 7 | url += '/api/tests/' + test_name |
gstepanov | 3ce37b8 | 2015-02-12 16:20:56 +0200 | [diff] [blame] | 8 | |
gstepanov | 8053b01 | 2015-02-16 17:25:27 +0200 | [diff] [blame] | 9 | import pdb |
| 10 | pdb.set_trace() |
gstepanov | 3ce37b8 | 2015-02-12 16:20:56 +0200 | [diff] [blame] | 11 | requests.post(url=url, data=json.dumps(test_data)) |
| 12 | |
| 13 | |
| 14 | def get_test(test_name, url): |
| 15 | if not url.endswith("/"): |
gstepanov | 8053b01 | 2015-02-16 17:25:27 +0200 | [diff] [blame] | 16 | url += '/api/tests/' + test_name |
gstepanov | 3ce37b8 | 2015-02-12 16:20:56 +0200 | [diff] [blame] | 17 | |
| 18 | result = requests.get(url=url) |
| 19 | |
| 20 | return json.loads(result.content) |
| 21 | |
| 22 | |
| 23 | def get_all_tests(url): |
gstepanov | 8053b01 | 2015-02-16 17:25:27 +0200 | [diff] [blame] | 24 | if not url.endswith('/'): |
| 25 | url += '/api/tests' |
| 26 | |
gstepanov | 3ce37b8 | 2015-02-12 16:20:56 +0200 | [diff] [blame] | 27 | result = requests.get(url=url) |
| 28 | return json.loads(result.content) |
| 29 | |
| 30 | |
| 31 | if __name__ == '__main__': |
| 32 | url = "http://0.0.0.0:5000/api/tests" |
| 33 | test = get_test("GA", url=url) |
| 34 | print test |
| 35 | |
| 36 | tests = get_all_tests(url=url) |
| 37 | print tests |
| 38 | |
| 39 | # test["type"] = "some build name" |
| 40 | # add_test("bla_bla", [test], url=url) |
| 41 | |
| 42 | tests = get_all_tests(url=url) |
koder aka kdanilov | 6e2ae79 | 2015-03-04 18:02:24 -0800 | [diff] [blame] | 43 | print len(tests) |