mirror of
https://github.com/nicolargo/glances.git
synced 2024-11-28 14:12:21 +03:00
unitest-restful: Python 3 compat
This commit is contained in:
parent
f2cf282ce5
commit
3db98fb9a1
@ -27,7 +27,6 @@ import shlex
|
|||||||
import subprocess
|
import subprocess
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
import types
|
|
||||||
|
|
||||||
from glances.core.glances_globals import (
|
from glances.core.glances_globals import (
|
||||||
appname,
|
appname,
|
||||||
@ -107,7 +106,7 @@ class TestGlances(unittest.TestCase):
|
|||||||
req = requests.get("%s/%s" % (URL, method))
|
req = requests.get("%s/%s" % (URL, method))
|
||||||
|
|
||||||
self.assertTrue(req.ok)
|
self.assertTrue(req.ok)
|
||||||
self.assertIsInstance(req.json(), types.ListType)
|
self.assertIsInstance(req.json(), list)
|
||||||
self.assertIn('cpu', req.json())
|
self.assertIn('cpu', req.json())
|
||||||
|
|
||||||
def test_003_plugins(self):
|
def test_003_plugins(self):
|
||||||
@ -122,13 +121,13 @@ class TestGlances(unittest.TestCase):
|
|||||||
req = requests.get("%s/%s" % (URL, p))
|
req = requests.get("%s/%s" % (URL, p))
|
||||||
self.assertTrue(req.ok)
|
self.assertTrue(req.ok)
|
||||||
if p in ('uptime', 'now'):
|
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'):
|
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'):
|
elif p in ('psutilversion', 'help'):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
self.assertIsInstance(req.json(), types.DictType)
|
self.assertIsInstance(req.json(), dict)
|
||||||
|
|
||||||
def test_004_items(self):
|
def test_004_items(self):
|
||||||
"""Items"""
|
"""Items"""
|
||||||
@ -141,8 +140,8 @@ class TestGlances(unittest.TestCase):
|
|||||||
print("HTTP RESTFul request: %s/%s/%s" % (URL, method, i))
|
print("HTTP RESTFul request: %s/%s/%s" % (URL, method, i))
|
||||||
req = requests.get("%s/%s/%s" % (URL, method, i))
|
req = requests.get("%s/%s/%s" % (URL, method, i))
|
||||||
self.assertTrue(req.ok)
|
self.assertTrue(req.ok)
|
||||||
self.assertIsInstance(req.json(), types.DictType)
|
self.assertIsInstance(req.json(), dict)
|
||||||
self.assertIsInstance(req.json()[i], types.FloatType)
|
self.assertIsInstance(req.json()[i], float)
|
||||||
|
|
||||||
def test_005_values(self):
|
def test_005_values(self):
|
||||||
"""Valuess"""
|
"""Valuess"""
|
||||||
@ -153,7 +152,7 @@ class TestGlances(unittest.TestCase):
|
|||||||
req = requests.get("%s/%s/pid/0" % (URL, method))
|
req = requests.get("%s/%s/pid/0" % (URL, method))
|
||||||
|
|
||||||
self.assertTrue(req.ok)
|
self.assertTrue(req.ok)
|
||||||
self.assertIsInstance(req.json(), types.DictType)
|
self.assertIsInstance(req.json(), dict)
|
||||||
|
|
||||||
def test_006_all_limits(self):
|
def test_006_all_limits(self):
|
||||||
"""All"""
|
"""All"""
|
||||||
@ -164,7 +163,7 @@ class TestGlances(unittest.TestCase):
|
|||||||
req = requests.get("%s/%s" % (URL, method))
|
req = requests.get("%s/%s" % (URL, method))
|
||||||
|
|
||||||
self.assertTrue(req.ok)
|
self.assertTrue(req.ok)
|
||||||
self.assertIsInstance(req.json(), types.DictType)
|
self.assertIsInstance(req.json(), dict)
|
||||||
|
|
||||||
def test_007_all_views(self):
|
def test_007_all_views(self):
|
||||||
"""All"""
|
"""All"""
|
||||||
@ -175,7 +174,7 @@ class TestGlances(unittest.TestCase):
|
|||||||
req = requests.get("%s/%s" % (URL, method))
|
req = requests.get("%s/%s" % (URL, method))
|
||||||
|
|
||||||
self.assertTrue(req.ok)
|
self.assertTrue(req.ok)
|
||||||
self.assertIsInstance(req.json(), types.DictType)
|
self.assertIsInstance(req.json(), dict)
|
||||||
|
|
||||||
def test_008_plugins_limits(self):
|
def test_008_plugins_limits(self):
|
||||||
"""Plugins limits"""
|
"""Plugins limits"""
|
||||||
@ -188,7 +187,7 @@ class TestGlances(unittest.TestCase):
|
|||||||
print("HTTP RESTFul request: %s/%s/limits" % (URL, p))
|
print("HTTP RESTFul request: %s/%s/limits" % (URL, p))
|
||||||
req = requests.get("%s/%s/limits" % (URL, p))
|
req = requests.get("%s/%s/limits" % (URL, p))
|
||||||
self.assertTrue(req.ok)
|
self.assertTrue(req.ok)
|
||||||
self.assertIsInstance(req.json(), types.DictType)
|
self.assertIsInstance(req.json(), dict)
|
||||||
|
|
||||||
def test_009_plugins_views(self):
|
def test_009_plugins_views(self):
|
||||||
"""Plugins views"""
|
"""Plugins views"""
|
||||||
@ -201,7 +200,7 @@ class TestGlances(unittest.TestCase):
|
|||||||
print("HTTP RESTFul request: %s/%s/views" % (URL, p))
|
print("HTTP RESTFul request: %s/%s/views" % (URL, p))
|
||||||
req = requests.get("%s/%s/views" % (URL, p))
|
req = requests.get("%s/%s/views" % (URL, p))
|
||||||
self.assertTrue(req.ok)
|
self.assertTrue(req.ok)
|
||||||
self.assertIsInstance(req.json(), types.DictType)
|
self.assertIsInstance(req.json(), dict)
|
||||||
|
|
||||||
def test_999_stop_server(self):
|
def test_999_stop_server(self):
|
||||||
"""Stop the Glances Web Server"""
|
"""Stop the Glances Web Server"""
|
||||||
|
Loading…
Reference in New Issue
Block a user