Merge "Use more specific asserts"
This commit is contained in:
@@ -420,7 +420,7 @@ class TestPost(api_base.FunctionalTest):
|
|||||||
expected_error_msg = ('The audit template UUID or name specified is '
|
expected_error_msg = ('The audit template UUID or name specified is '
|
||||||
'invalid')
|
'invalid')
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['error_message'])
|
||||||
self.assertTrue(expected_error_msg in response.json['error_message'])
|
self.assertIn(expected_error_msg, response.json['error_message'])
|
||||||
|
|
||||||
@mock.patch.object(deapi.DecisionEngineAPI, 'trigger_audit')
|
@mock.patch.object(deapi.DecisionEngineAPI, 'trigger_audit')
|
||||||
def test_create_audit_doesnt_contain_id(self, mock_trigger_audit):
|
def test_create_audit_doesnt_contain_id(self, mock_trigger_audit):
|
||||||
@@ -489,7 +489,7 @@ class TestPost(api_base.FunctionalTest):
|
|||||||
expected_error_msg = ('Interval of audit must be specified '
|
expected_error_msg = ('Interval of audit must be specified '
|
||||||
'for CONTINUOUS.')
|
'for CONTINUOUS.')
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['error_message'])
|
||||||
self.assertTrue(expected_error_msg in response.json['error_message'])
|
self.assertIn(expected_error_msg, response.json['error_message'])
|
||||||
|
|
||||||
@mock.patch.object(deapi.DecisionEngineAPI, 'trigger_audit')
|
@mock.patch.object(deapi.DecisionEngineAPI, 'trigger_audit')
|
||||||
def test_create_oneshot_audit_with_period(self, mock_trigger_audit):
|
def test_create_oneshot_audit_with_period(self, mock_trigger_audit):
|
||||||
@@ -506,7 +506,7 @@ class TestPost(api_base.FunctionalTest):
|
|||||||
self.assertEqual('application/json', response.content_type)
|
self.assertEqual('application/json', response.content_type)
|
||||||
expected_error_msg = 'Interval of audit must not be set for ONESHOT.'
|
expected_error_msg = 'Interval of audit must not be set for ONESHOT.'
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['error_message'])
|
||||||
self.assertTrue(expected_error_msg in response.json['error_message'])
|
self.assertIn(expected_error_msg, response.json['error_message'])
|
||||||
|
|
||||||
def test_create_audit_trigger_decision_engine(self):
|
def test_create_audit_trigger_decision_engine(self):
|
||||||
with mock.patch.object(deapi.DecisionEngineAPI,
|
with mock.patch.object(deapi.DecisionEngineAPI,
|
||||||
@@ -544,7 +544,7 @@ class TestPost(api_base.FunctionalTest):
|
|||||||
'strategy for audit template, or no '
|
'strategy for audit template, or no '
|
||||||
'parameter spec in predefined strategy')
|
'parameter spec in predefined strategy')
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['error_message'])
|
||||||
self.assertTrue(expected_error_msg in response.json['error_message'])
|
self.assertIn(expected_error_msg, response.json['error_message'])
|
||||||
assert not mock_trigger_audit.called
|
assert not mock_trigger_audit.called
|
||||||
|
|
||||||
@mock.patch.object(deapi.DecisionEngineAPI, 'trigger_audit')
|
@mock.patch.object(deapi.DecisionEngineAPI, 'trigger_audit')
|
||||||
@@ -564,7 +564,7 @@ class TestPost(api_base.FunctionalTest):
|
|||||||
'strategy for audit template, or no '
|
'strategy for audit template, or no '
|
||||||
'parameter spec in predefined strategy')
|
'parameter spec in predefined strategy')
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['error_message'])
|
||||||
self.assertTrue(expected_error_msg in response.json['error_message'])
|
self.assertIn(expected_error_msg, response.json['error_message'])
|
||||||
assert not mock_trigger_audit.called
|
assert not mock_trigger_audit.called
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class TestListGoal(api_base.FunctionalTest):
|
|||||||
name='GOAL_{0}'.format(idx))
|
name='GOAL_{0}'.format(idx))
|
||||||
goal_list.append(goal.uuid)
|
goal_list.append(goal.uuid)
|
||||||
response = self.get_json('/goals')
|
response = self.get_json('/goals')
|
||||||
self.assertTrue(len(response['goals']) > 2)
|
self.assertGreater(len(response['goals']), 2)
|
||||||
|
|
||||||
def test_many_without_soft_deleted(self):
|
def test_many_without_soft_deleted(self):
|
||||||
goal_list = []
|
goal_list = []
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ class TestUniformAirflow(base.BaseTestCase):
|
|||||||
vms = model.get_all_vms()
|
vms = model.get_all_vms()
|
||||||
vms.clear()
|
vms.clear()
|
||||||
vm_to_mig = self.strategy.choose_vm_to_migrate(h1)
|
vm_to_mig = self.strategy.choose_vm_to_migrate(h1)
|
||||||
self.assertEqual(vm_to_mig, None)
|
self.assertIsNone(vm_to_mig)
|
||||||
|
|
||||||
def test_filter_destination_hosts(self):
|
def test_filter_destination_hosts(self):
|
||||||
model = self.fake_cluster.generate_scenario_7_with_2_hypervisors()
|
model = self.fake_cluster.generate_scenario_7_with_2_hypervisors()
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ class TestWorkloadBalance(base.BaseTestCase):
|
|||||||
vms = model.get_all_vms()
|
vms = model.get_all_vms()
|
||||||
vms.clear()
|
vms.clear()
|
||||||
vm_to_mig = self.strategy.choose_vm_to_migrate(h1, avg, w_map)
|
vm_to_mig = self.strategy.choose_vm_to_migrate(h1, avg, w_map)
|
||||||
self.assertEqual(vm_to_mig, None)
|
self.assertIsNone(vm_to_mig)
|
||||||
|
|
||||||
def test_filter_destination_hosts(self):
|
def test_filter_destination_hosts(self):
|
||||||
model = self.fake_cluster.generate_scenario_6_with_2_hypervisors()
|
model = self.fake_cluster.generate_scenario_6_with_2_hypervisors()
|
||||||
|
|||||||
@@ -376,7 +376,8 @@ class TestSyncer(base.DbTestCase):
|
|||||||
|
|
||||||
self.assertEqual(2, strategy2.goal_id)
|
self.assertEqual(2, strategy2.goal_id)
|
||||||
self.assertIn(strategy2.name, created_strategies)
|
self.assertIn(strategy2.name, created_strategies)
|
||||||
self.assertTrue(strategy2.id != created_strategies[strategy2.name].id)
|
self.assertNotEqual(strategy2.id,
|
||||||
|
created_strategies[strategy2.name].id)
|
||||||
|
|
||||||
self.assertEqual(set([audit_template2.id,
|
self.assertEqual(set([audit_template2.id,
|
||||||
audit_template3.id,
|
audit_template3.id,
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ class TestObjectSerializer(test_base.TestCase):
|
|||||||
ser = base.WatcherObjectSerializer()
|
ser = base.WatcherObjectSerializer()
|
||||||
obj = MyObj(self.context)
|
obj = MyObj(self.context)
|
||||||
primitive = ser.serialize_entity(self.context, obj)
|
primitive = ser.serialize_entity(self.context, obj)
|
||||||
self.assertTrue('watcher_object.name' in primitive)
|
self.assertIn('watcher_object.name', primitive)
|
||||||
obj2 = ser.deserialize_entity(self.context, primitive)
|
obj2 = ser.deserialize_entity(self.context, primitive)
|
||||||
self.assertIsInstance(obj2, MyObj)
|
self.assertIsInstance(obj2, MyObj)
|
||||||
self.assertEqual(self.context, obj2._context)
|
self.assertEqual(self.context, obj2._context)
|
||||||
|
|||||||
Reference in New Issue
Block a user