Commit 3337d0ca authored by zhangguoqing's avatar zhangguoqing

Use assertIn and assertNotIn

because assertIn and assertNotIn raise more meaningful errors

Change-Id: Id9bb318754f3ff329c794e4d3c2e80abbe5cd55b
parent dd2c6509
......@@ -354,7 +354,7 @@ class BaseAgentManagerTestCase(base.BaseTestCase):
def test_setup_polling_tasks(self):
polling_tasks = self.mgr.setup_polling_tasks()
self.assertEqual(1, len(polling_tasks))
self.assertTrue(60 in polling_tasks.keys())
self.assertIn(60, polling_tasks.keys())
per_task_resources = polling_tasks[60].resources
self.assertEqual(1, len(per_task_resources))
self.assertEqual(set(self.pipeline_cfg['sources'][0]['resources']),
......@@ -371,8 +371,8 @@ class BaseAgentManagerTestCase(base.BaseTestCase):
self.setup_polling()
polling_tasks = self.mgr.setup_polling_tasks()
self.assertEqual(2, len(polling_tasks))
self.assertTrue(60 in polling_tasks.keys())
self.assertTrue(10 in polling_tasks.keys())
self.assertIn(60, polling_tasks.keys())
self.assertIn(10, polling_tasks.keys())
def test_setup_polling_tasks_mismatch_counter(self):
self.pipeline_cfg['sources'].append({
......@@ -384,8 +384,8 @@ class BaseAgentManagerTestCase(base.BaseTestCase):
})
polling_tasks = self.mgr.setup_polling_tasks()
self.assertEqual(1, len(polling_tasks))
self.assertTrue(60 in polling_tasks.keys())
self.assertFalse(10 in polling_tasks.keys())
self.assertIn(60, polling_tasks.keys())
self.assertNotIn(10, polling_tasks.keys())
def test_setup_polling_task_same_interval(self):
self.pipeline_cfg['sources'].append({
......@@ -554,7 +554,7 @@ class BaseAgentManagerTestCase(base.BaseTestCase):
self.setup_polling()
polling_tasks = self.mgr.setup_polling_tasks()
self.assertEqual(1, len(polling_tasks))
self.assertTrue(60 in polling_tasks.keys())
self.assertIn(60, polling_tasks.keys())
self.mgr.interval_task(polling_tasks.get(60))
self.assertEqual([None], self.Discovery.params)
self.assertEqual([None], self.DiscoveryAnother.params)
......@@ -593,7 +593,7 @@ class BaseAgentManagerTestCase(base.BaseTestCase):
self.setup_polling()
polling_tasks = self.mgr.setup_polling_tasks()
self.assertEqual(1, len(polling_tasks))
self.assertTrue(60 in polling_tasks.keys())
self.assertIn(60, polling_tasks.keys())
self.mgr.interval_task(polling_tasks.get(60))
self.assertEqual(1, len(self.Pollster.samples))
self.assertEqual(['discovered_1', 'discovered_2'],
......@@ -620,7 +620,7 @@ class BaseAgentManagerTestCase(base.BaseTestCase):
self.setup_polling()
polling_tasks = self.mgr.setup_polling_tasks()
self.assertEqual(1, len(polling_tasks))
self.assertTrue(60 in polling_tasks.keys())
self.assertIn(60, polling_tasks.keys())
self.mgr.interval_task(polling_tasks.get(60))
self.assertEqual(1, len(self.Pollster.samples))
self.assertEqual(['discovered_1', 'discovered_2'],
......
......@@ -330,7 +330,7 @@ class TestQueryToKwArgs(tests_base.BaseTestCase):
request.headers.return_value = {'X-ProjectId': 'foobar'}
kwargs = utils.query_to_kwargs(queries,
storage.SampleFilter.__init__)
self.assertFalse('self' in kwargs)
self.assertNotIn('self', kwargs)
def test_sample_filter_translation(self):
queries = [v2_base.Query(field=f,
......
......@@ -355,7 +355,7 @@ class TestMeterProcessing(test.BaseTestCase):
self.assertEqual(2, len(data))
expected_names = ['test1', 'test2']
for s in data:
self.assertTrue(s.as_dict()['name'] in expected_names)
self.assertIn(s.as_dict()['name'], expected_names)
def test_unmatched_meter(self):
cfg = yaml.dump(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment