diff options
author | nicolargo <nicolashennion@gmail.com> | 2016-06-04 16:17:00 +0200 |
---|---|---|
committer | nicolargo <nicolashennion@gmail.com> | 2016-06-04 16:17:00 +0200 |
commit | a790a3b7f0e10027fdc3c17a82e25d9225456d2e (patch) | |
tree | afdb6b0843c1bd8a9ceec6ce8638549691177780 /unitest-restful.py | |
parent | a4613d14760938c48d8f9f2e34fd2659953e102f (diff) |
Add unitary test for history Restfull API
Diffstat (limited to 'unitest-restful.py')
-rwxr-xr-x | unitest-restful.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/unitest-restful.py b/unitest-restful.py index 86598563..be29236f 100755 --- a/unitest-restful.py +++ b/unitest-restful.py @@ -169,6 +169,31 @@ class TestGlances(unittest.TestCase): self.assertTrue(req.ok) self.assertIsInstance(req.json(), dict) + def test_010_history(self): + """History.""" + method = "history" + print('INFO: [TEST_010] History') + print("HTTP RESTful request: %s/cpu/%s" % (URL, method)) + req = requests.get("%s/cpu/%s" % (URL, method)) + self.assertIsInstance(req.json(), dict) + self.assertIsInstance(req.json()['user'], list) + self.assertTrue(len(req.json()['user']) > 0) + print("HTTP RESTful request: %s/cpu/%s/3" % (URL, method)) + req = requests.get("%s/cpu/%s/3" % (URL, method)) + self.assertIsInstance(req.json(), dict) + self.assertIsInstance(req.json()['user'], list) + self.assertTrue(len(req.json()['user']) == 3) + print("HTTP RESTful request: %s/cpu/system/%s" % (URL, method)) + req = requests.get("%s/cpu/system/%s" % (URL, method)) + self.assertIsInstance(req.json(), dict) + self.assertIsInstance(req.json()['system'], list) + self.assertTrue(len(req.json()['system']) > 0) + print("HTTP RESTful request: %s/cpu/system/%s/3" % (URL, method)) + req = requests.get("%s/cpu/system/%s/3" % (URL, method)) + self.assertIsInstance(req.json(), dict) + self.assertIsInstance(req.json()['system'], list) + self.assertTrue(len(req.json()['system']) == 3) + def test_999_stop_server(self): """Stop the Glances Web Server.""" print('INFO: [TEST_999] Stop the Glances Web Server') |