Change assertTrue(isinstance()) by optimal assert
Use assertIsInstance() instead of assertTrue(isinstance()) Change-Id: Ib1d84eb1245d822bac0c0ee5fac7a086fabadcdc
This commit is contained in:
parent
1544d4cb49
commit
47560f56a6
@ -65,7 +65,7 @@ class JMXTestCase(unittest.TestCase):
|
||||
|
||||
metrics = self.reporter.metrics
|
||||
|
||||
self.assertTrue(isinstance(metrics, list))
|
||||
self.assertIsInstance(metrics, list)
|
||||
self.assertTrue(len(metrics) > 0)
|
||||
self.assertTrue(len([t for t in metrics if "cassandra.db." in t[
|
||||
'metric'] and "instance:cassandra_instance" in t['dimensions']]) > 40, metrics)
|
||||
|
@ -59,7 +59,7 @@ class TestElastic(unittest.TestCase):
|
||||
self.check.check(conf['instances'][0])
|
||||
r = self.check.get_metrics()
|
||||
|
||||
self.assertTrue(isinstance(r, list))
|
||||
self.assertIsInstance(r, list)
|
||||
self.assertTrue(len(r) > 0)
|
||||
self.assertEqual(len([t for t in r if t[0] == "elasticsearch.get.total"]), 1, r)
|
||||
self.assertEqual(len([t for t in r if t[0] == "elasticsearch.search.fetch.total"]), 1, r)
|
||||
|
@ -23,6 +23,6 @@ class GearmanTestCase(unittest.TestCase):
|
||||
self.check.check(config['instances'][0])
|
||||
|
||||
metrics = self.check.get_metrics()
|
||||
self.assertTrue(isinstance(metrics, list))
|
||||
self.assertIsInstance(metrics, list)
|
||||
self.assertTrue(len(metrics) == 4)
|
||||
self.assertTrue(len([k for k in metrics if "second" in k[3]['dimensions']['first']]) == 4)
|
||||
|
@ -93,7 +93,7 @@ class HaproxyTestCase(unittest.TestCase):
|
||||
# Metric assertions
|
||||
metrics = self.check.get_metrics()
|
||||
assert metrics
|
||||
self.assertTrue(isinstance(metrics, list))
|
||||
self.assertIsInstance(metrics, list)
|
||||
self.assertTrue(len(metrics) > 0)
|
||||
|
||||
self.assertEqual(len([t for t in metrics
|
||||
@ -156,7 +156,7 @@ class HaproxyTestCase(unittest.TestCase):
|
||||
|
||||
metrics = self.check.get_metrics()
|
||||
assert metrics
|
||||
self.assertTrue(isinstance(metrics, list))
|
||||
self.assertIsInstance(metrics, list)
|
||||
self.assertTrue(len(metrics) > 0)
|
||||
|
||||
self.assertEqual(len([t for t in metrics
|
||||
|
@ -66,7 +66,7 @@ class JMXTestCase(unittest.TestCase):
|
||||
|
||||
metrics = self.reporter.metrics
|
||||
|
||||
self.assertTrue(isinstance(metrics, list))
|
||||
self.assertIsInstance(metrics, list)
|
||||
self.assertTrue(len(metrics) > 0)
|
||||
self.assertEqual(len([t for t in metrics if t[
|
||||
'metric'] == "my.metric.buf" and "instance:jmx_instance1" in t['dimensions']]), 2, metrics)
|
||||
|
@ -116,7 +116,7 @@ class TestMongo(unittest.TestCase):
|
||||
# Metric assertions
|
||||
metrics = self.check.get_metrics()
|
||||
assert metrics
|
||||
self.assertTrue(isinstance(metrics, list))
|
||||
self.assertIsInstance(metrics, list)
|
||||
self.assertTrue(len(metrics) > 0)
|
||||
|
||||
metric_val_checks = {
|
||||
@ -142,7 +142,7 @@ class TestMongo(unittest.TestCase):
|
||||
# Metric assertions
|
||||
metrics = self.check.get_metrics()
|
||||
assert metrics
|
||||
self.assertTrue(isinstance(metrics, list))
|
||||
self.assertIsInstance(metrics, list)
|
||||
self.assertTrue(len(metrics) > 0)
|
||||
|
||||
for m in metrics:
|
||||
@ -178,7 +178,7 @@ class TestMongo(unittest.TestCase):
|
||||
# Metric assertions
|
||||
metrics = self.check.get_metrics()
|
||||
assert metrics
|
||||
self.assertTrue(isinstance(metrics, list))
|
||||
self.assertIsInstance(metrics, list)
|
||||
self.assertTrue(len(metrics) > 0)
|
||||
|
||||
metric_val_checks = {
|
||||
@ -207,7 +207,7 @@ class TestMongo(unittest.TestCase):
|
||||
# Metric assertions
|
||||
metrics = self.check.get_metrics()
|
||||
assert metrics
|
||||
self.assertTrue(isinstance(metrics, list))
|
||||
self.assertIsInstance(metrics, list)
|
||||
self.assertTrue(len(metrics) > 0)
|
||||
|
||||
for m in metrics:
|
||||
|
@ -66,7 +66,7 @@ class JMXTestCase(unittest.TestCase):
|
||||
|
||||
metrics = self.reporter.metrics
|
||||
|
||||
self.assertTrue(isinstance(metrics, list))
|
||||
self.assertIsInstance(metrics, list)
|
||||
self.assertTrue(len(metrics) > 8, metrics)
|
||||
self.assertEqual(len([t for t in metrics if 'instance:solr_instance' in t[
|
||||
'dimensions'] and t['metric'] == "jvm.thread_count"]), 1, metrics)
|
||||
|
@ -66,7 +66,7 @@ class JMXTestCase(unittest.TestCase):
|
||||
|
||||
metrics = self.reporter.metrics
|
||||
|
||||
self.assertTrue(isinstance(metrics, list))
|
||||
self.assertIsInstance(metrics, list)
|
||||
self.assertTrue(len(metrics) > 0)
|
||||
self.assertEqual(len([t for t in metrics if t[
|
||||
'metric'] == "tomcat.threads.busy" and "instance:tomcat_instance" in t['dimensions']]), 2, metrics)
|
||||
|
Loading…
Reference in New Issue
Block a user