fix asserts
use dict equal and list equal instead of plain equal make it more readable if it fails Change-Id: Ia7e838c79a750c2c0d14a8ff7ddcfc440401cfe0
This commit is contained in:
parent
11fd7859ba
commit
083736772a
@ -75,7 +75,7 @@ class BaseRcaTest(BaseAlarmsTest):
|
||||
parsed_rca = json.loads(cli_rca)
|
||||
sorted_cli_graph = self._clean_timestamps(sorted(parsed_rca.items()))
|
||||
sorted_api_graph = self._clean_timestamps(sorted(api_rca.items()))
|
||||
self.assertEqual(sorted_cli_graph, sorted_api_graph)
|
||||
self.assert_list_equal(sorted_cli_graph, sorted_api_graph)
|
||||
|
||||
def _validate_rca(self, rca):
|
||||
self.assertThat(rca, IsNotEmpty, 'The rca is empty')
|
||||
|
@ -69,7 +69,7 @@ class BaseTemplateTest(BaseVitrageTempest):
|
||||
parsed_topology = json.loads(cli_templates)
|
||||
sorted_cli_templates = sorted(parsed_topology.items())
|
||||
sorted_api_templates = sorted(api_templates.items())
|
||||
self.assertEqual(sorted_api_templates, sorted_cli_templates)
|
||||
self.assert_list_equal(sorted_api_templates, sorted_cli_templates)
|
||||
|
||||
def _validate_templates_list_length(self, api_templates, cli_templates):
|
||||
self.assertEqual(len(cli_templates.splitlines()),
|
||||
@ -132,7 +132,7 @@ class BaseTemplateTest(BaseVitrageTempest):
|
||||
parsed_topology = json.loads(cli_templates)
|
||||
sorted_cli_templates = sorted(parsed_topology.items())
|
||||
sorted_api_templates = sorted(api_templates.items())
|
||||
self.assertEqual(sorted_api_templates, sorted_cli_templates)
|
||||
self.assert_list_equal(sorted_api_templates, sorted_cli_templates)
|
||||
|
||||
def _rollback_to_default(self, templates):
|
||||
try:
|
||||
|
@ -236,8 +236,8 @@ class TemplatesDBTest(BaseTemplateTest):
|
||||
status=TemplateStatus.ACTIVE)
|
||||
payload_from_db = self.client.template.show(db_row['uuid'])
|
||||
payload_from_file = file.load_yaml_file(template_path)
|
||||
self.assertEqual(payload_from_file, payload_from_db,
|
||||
"Template content doesn't match")
|
||||
self.assert_dict_equal(payload_from_file, payload_from_db,
|
||||
"Template content doesn't match")
|
||||
v_utils.delete_template(db_row['uuid'])
|
||||
except Exception as e:
|
||||
self._handle_exception(e)
|
||||
|
@ -93,7 +93,7 @@ class BaseTopologyTest(BaseVitrageTempest):
|
||||
for item in sorted_api_graph[4][1]:
|
||||
item.pop(VProps.VITRAGE_SAMPLE_TIMESTAMP, None)
|
||||
|
||||
self.assertEqual(sorted_cli_graph, sorted_api_graph)
|
||||
self.assert_list_equal(sorted_cli_graph, sorted_api_graph)
|
||||
|
||||
@staticmethod
|
||||
def _graph_query():
|
||||
|
@ -456,7 +456,7 @@ class TestTopology(BaseTopologyTest):
|
||||
all_tenants=True)
|
||||
|
||||
# Test Assertions
|
||||
self.assertEqual({}, api_graph)
|
||||
self.assert_is_empty(api_graph)
|
||||
except Exception as e:
|
||||
self._handle_exception(e)
|
||||
raise
|
||||
|
@ -82,6 +82,12 @@ class BaseVitrageTempest(base.BaseTestCase):
|
||||
def assert_set_equal(self, s1, s2, message=None):
|
||||
self.assertSetEqual(s1, s2, message)
|
||||
|
||||
def assert_sequence_equal(self, s1, s2, message=None):
|
||||
self.assertSequenceEqual(self, s1, s2, message)
|
||||
|
||||
def assert_tuple_equal(self, s1, s2, message=None):
|
||||
self.assertTupleEqual(self, s1, s2, message)
|
||||
|
||||
def assert_timestamp_equal(self, first, second, msg=None):
|
||||
"""Checks that two timestamps are equals.
|
||||
|
||||
|
@ -168,13 +168,13 @@ class TestBasicActions(TestActionsBase):
|
||||
self._trigger_do_action(trigger_name)
|
||||
nova_service = TempestClients.nova().services.list(
|
||||
host=host_name, binary='nova-compute')[0]
|
||||
self.assertEqual("down", str(nova_service.state))
|
||||
self.assertEqual("down", nova_service.state)
|
||||
|
||||
# Undo
|
||||
self._trigger_undo_action(trigger_name)
|
||||
nova_service = TempestClients.nova().services.list(
|
||||
host=host_name, binary='nova-compute')[0]
|
||||
self.assertEqual("up", str(nova_service.state))
|
||||
self.assertEqual("up", nova_service.state)
|
||||
except Exception as e:
|
||||
self._handle_exception(e)
|
||||
raise
|
||||
@ -198,12 +198,12 @@ class TestBasicActions(TestActionsBase):
|
||||
# Do
|
||||
self._trigger_do_action(trigger_name)
|
||||
nova_instance = TempestClients.nova().servers.get(vm_id)
|
||||
self.assertEqual("ERROR", str(nova_instance.status))
|
||||
self.assertEqual("ERROR", nova_instance.status)
|
||||
|
||||
# Undo
|
||||
self._trigger_undo_action(trigger_name)
|
||||
nova_instance = TempestClients.nova().servers.get(vm_id)
|
||||
self.assertEqual("ACTIVE", str(nova_instance.status))
|
||||
self.assertEqual("ACTIVE", nova_instance.status)
|
||||
except Exception as e:
|
||||
self._handle_exception(e)
|
||||
raise
|
||||
|
@ -299,8 +299,8 @@ class TestWebhook(TestActionsBase):
|
||||
|
||||
sent_fields = utils.filter_data(payload, DOCTOR_ALARM_FILTER)
|
||||
|
||||
self.assertEqual(DOCTOR_ALARM_FILTER, sent_fields,
|
||||
"Some alarm fields not sent")
|
||||
self.assert_set_equal(DOCTOR_ALARM_FILTER, sent_fields,
|
||||
"Some alarm fields not sent")
|
||||
|
||||
resource = payload.get(VProps.RESOURCE)
|
||||
if resource:
|
||||
@ -314,8 +314,8 @@ class TestWebhook(TestActionsBase):
|
||||
|
||||
sent_fields = utils.filter_data(resource, RESOURCE_FILTER)
|
||||
|
||||
self.assertEqual(RESOURCE_FILTER, sent_fields,
|
||||
"Some resource fields not sent")
|
||||
self.assert_set_equal(RESOURCE_FILTER, sent_fields,
|
||||
"Some resource fields not sent")
|
||||
finally:
|
||||
self._trigger_undo_action(TRIGGER_ALARM_1)
|
||||
|
||||
|
@ -118,19 +118,19 @@ class TestOverlappingActions(TestActionsBase):
|
||||
self._trigger_do_action(TRIGGER_ALARM_3)
|
||||
nova_service = TempestClients.nova().services.list(
|
||||
host=host_name, binary='nova-compute')[0]
|
||||
self.assertEqual("down", str(nova_service.state))
|
||||
self.assertEqual("down", nova_service.state)
|
||||
|
||||
# Do - second
|
||||
self._trigger_do_action(TRIGGER_ALARM_4)
|
||||
nova_service = TempestClients.nova().services.list(
|
||||
host=host_name, binary='nova-compute')[0]
|
||||
self.assertEqual("down", str(nova_service.state))
|
||||
self.assertEqual("down", nova_service.state)
|
||||
|
||||
# Undo - first
|
||||
self._trigger_undo_action(TRIGGER_ALARM_3)
|
||||
nova_service = TempestClients.nova().services.list(
|
||||
host=host_name, binary='nova-compute')[0]
|
||||
self.assertEqual("down", str(nova_service.state))
|
||||
self.assertEqual("down", nova_service.state)
|
||||
|
||||
# Undo - second
|
||||
self._trigger_undo_action(TRIGGER_ALARM_4)
|
||||
|
Loading…
x
Reference in New Issue
Block a user