From 3db98fb9a1d0e8508400e973cee799931cc981e4 Mon Sep 17 00:00:00 2001 From: Alessio Sergi Date: Tue, 22 Sep 2015 12:00:00 +0200 Subject: unitest-restful: Python 3 compat --- unitest-restful.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'unitest-restful.py') diff --git a/unitest-restful.py b/unitest-restful.py index 82ce53fc..cdb90e69 100755 --- a/unitest-restful.py +++ b/unitest-restful.py @@ -27,7 +27,6 @@ import shlex import subprocess import requests import json -import types from glances.core.glances_globals import ( appname, @@ -107,7 +106,7 @@ class TestGlances(unittest.TestCase): req = requests.get("%s/%s" % (URL, method)) self.assertTrue(req.ok) - self.assertIsInstance(req.json(), types.ListType) + self.assertIsInstance(req.json(), list) self.assertIn('cpu', req.json()) def test_003_plugins(self): @@ -122,13 +121,13 @@ class TestGlances(unittest.TestCase): req = requests.get("%s/%s" % (URL, p)) self.assertTrue(req.ok) if p in ('uptime', 'now'): - self.assertIsInstance(req.json(), types.UnicodeType) + self.assertIsInstance(req.json(), str) elif p in ('fs', 'monitor', 'percpu', 'sensors', 'alert', 'processlist', 'diskio', 'hddtemp', 'batpercent', 'network'): - self.assertIsInstance(req.json(), types.ListType) + self.assertIsInstance(req.json(), list) elif p in ('psutilversion', 'help'): pass else: - self.assertIsInstance(req.json(), types.DictType) + self.assertIsInstance(req.json(), dict) def test_004_items(self): """Items""" @@ -141,8 +140,8 @@ class TestGlances(unittest.TestCase): print("HTTP RESTFul request: %s/%s/%s" % (URL, method, i)) req = requests.get("%s/%s/%s" % (URL, method, i)) self.assertTrue(req.ok) - self.assertIsInstance(req.json(), types.DictType) - self.assertIsInstance(req.json()[i], types.FloatType) + self.assertIsInstance(req.json(), dict) + self.assertIsInstance(req.json()[i], float) def test_005_values(self): """Valuess""" @@ -153,7 +152,7 @@ class TestGlances(unittest.TestCase): req = requests.get("%s/%s/pid/0" % (URL, method)) self.assertTrue(req.ok) - self.assertIsInstance(req.json(), types.DictType) + self.assertIsInstance(req.json(), dict) def test_006_all_limits(self): """All""" @@ -164,7 +163,7 @@ class TestGlances(unittest.TestCase): req = requests.get("%s/%s" % (URL, method)) self.assertTrue(req.ok) - self.assertIsInstance(req.json(), types.DictType) + self.assertIsInstance(req.json(), dict) def test_007_all_views(self): """All""" @@ -175,7 +174,7 @@ class TestGlances(unittest.TestCase): req = requests.get("%s/%s" % (URL, method)) self.assertTrue(req.ok) - self.assertIsInstance(req.json(), types.DictType) + self.assertIsInstance(req.json(), dict) def test_008_plugins_limits(self): """Plugins limits""" @@ -188,7 +187,7 @@ class TestGlances(unittest.TestCase): print("HTTP RESTFul request: %s/%s/limits" % (URL, p)) req = requests.get("%s/%s/limits" % (URL, p)) self.assertTrue(req.ok) - self.assertIsInstance(req.json(), types.DictType) + self.assertIsInstance(req.json(), dict) def test_009_plugins_views(self): """Plugins views""" @@ -201,7 +200,7 @@ class TestGlances(unittest.TestCase): print("HTTP RESTFul request: %s/%s/views" % (URL, p)) req = requests.get("%s/%s/views" % (URL, p)) self.assertTrue(req.ok) - self.assertIsInstance(req.json(), types.DictType) + self.assertIsInstance(req.json(), dict) def test_999_stop_server(self): """Stop the Glances Web Server""" -- cgit v1.2.3