From fa0fc8578ef590792db604b6366071fad719ffa5 Mon Sep 17 00:00:00 2001 From: nicolargo Date: Sat, 23 Dec 2023 11:10:52 +0100 Subject: [PATCH] Add unittest (API) for fields description and unit --- unitest-restful.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/unitest-restful.py b/unitest-restful.py index 08f7c27f..faf1fe8f 100755 --- a/unitest-restful.py +++ b/unitest-restful.py @@ -257,6 +257,20 @@ class TestGlances(unittest.TestCase): self.assertTrue(req.headers['Content-Encoding'] == 'gzip') self.assertTrue(req.json(), dict) + def test_016_fields_description(self): + """Fields description.""" + print('INFO: [TEST_016] Get fields description and unit') + + print("HTTP RESTful request: %s/cpu/total/description" % URL) + req = self.http_get("%s/cpu/total/description" % URL) + self.assertTrue(req.ok) + self.assertTrue(req.json(), str) + + print("HTTP RESTful request: %s/cpu/total/unit" % URL) + req = self.http_get("%s/cpu/total/unit" % URL) + self.assertTrue(req.ok) + self.assertTrue(req.json(), str) + def test_999_stop_server(self): """Stop the Glances Web Server.""" print('INFO: [TEST_999] Stop the Glances Web Server')