From 6491f4c078fe73dc301074e33527a4e12419a041 Mon Sep 17 00:00:00 2001 From: sudhir_agarwal Date: Mon, 17 Jul 2017 16:57:01 +0530 Subject: [PATCH] Fixed order of arguments in assertEqual Some tests used incorrect order of arguments in assertEqual(observed, expected). The correct order expected by testtool is assertEqual(expected, observed). Change-Id: I4962812206ea170c855a2574083b7b136d067850 --- .../evaluator/test_scenario_evaluator.py | 413 +++++++++--------- .../unit/datasources/aodh/test_aodh_driver.py | 5 +- .../cinder/test_cinder_volume_transformer.py | 12 +- .../heat/test_heat_stack_transformer.py | 12 +- .../nova/test_nova_host_transformer.py | 12 +- .../nova/test_nova_instance_transformer.py | 12 +- .../nova/test_nova_zone_transformer.py | 17 +- .../static/test_static_transformer.py | 14 +- .../test_static_physical_driver.py | 10 +- .../test_static_physical_transformer.py | 12 +- .../test_datasource_update_method.py | 4 +- .../datasources/test_rescheduler_functions.py | 4 +- .../entity_graph/processor/test_processor.py | 8 +- .../template_validation/content/base.py | 2 +- .../test_template_syntax_validator.py | 4 +- .../evaluator/test_scenario_repository.py | 6 +- .../unit/evaluator/test_template_data.py | 12 +- .../test_snmp_sender_with_severity_map.py | 6 +- .../test_snmp_sender_without_severity_map.py | 4 +- vitrage_tempest_tests/tests/api/rca/base.py | 24 +- .../tests/api/templates/base.py | 24 +- .../tests/api/templates/test_template.py | 8 +- .../tests/api/topology/test_topology.py | 4 +- 23 files changed, 304 insertions(+), 325 deletions(-) diff --git a/vitrage/tests/functional/evaluator/test_scenario_evaluator.py b/vitrage/tests/functional/evaluator/test_scenario_evaluator.py index 97289c2a4..ad34b1332 100644 --- a/vitrage/tests/functional/evaluator/test_scenario_evaluator.py +++ b/vitrage/tests/functional/evaluator/test_scenario_evaluator.py @@ -456,12 +456,12 @@ class TestScenarioEvaluator(TestFunctionalBase): self.assertEqual(num_orig_edges + num_added_edges + num_deduced_edges, entity_graph.num_edges()) self.assertEqual(1, len(port_neighbors)) - self.assertEqual(port_neighbors[0][VProps.VITRAGE_CATEGORY], - EntityCategory.ALARM) - self.assertEqual(port_neighbors[0][VProps.VITRAGE_TYPE], - VITRAGE_DATASOURCE) - self.assertEqual(port_neighbors[0][VProps.NAME], - 'simple_port_deduced_alarm') + self.assertEqual(EntityCategory.ALARM, + port_neighbors[0][VProps.VITRAGE_CATEGORY]) + self.assertEqual(VITRAGE_DATASOURCE, + port_neighbors[0][VProps.VITRAGE_TYPE]) + self.assertEqual('simple_port_deduced_alarm', + port_neighbors[0][VProps.NAME]) # Add PORT_PROBLEM alarm test_vals = {'status': NagiosTestStatus.WARNING, @@ -491,26 +491,25 @@ class TestScenarioEvaluator(TestFunctionalBase): port_neighbors = entity_graph.neighbors(port_vertex.vertex_id, vertex_attr_filter=query) self.assertEqual(1, len(port_neighbors)) - self.assertEqual(port_neighbors[0][VProps.VITRAGE_CATEGORY], - EntityCategory.ALARM) - self.assertEqual(port_neighbors[0][VProps.VITRAGE_TYPE], - VITRAGE_DATASOURCE) - self.assertEqual(port_neighbors[0][VProps.NAME], - 'simple_port_deduced_alarm') - self.assertEqual(port_neighbors[0][VProps.VITRAGE_IS_DELETED], True) + self.assertEqual(EntityCategory.ALARM, + port_neighbors[0][VProps.VITRAGE_CATEGORY]) + self.assertEqual(VITRAGE_DATASOURCE, + port_neighbors[0][VProps.VITRAGE_TYPE]) + self.assertEqual('simple_port_deduced_alarm', + port_neighbors[0][VProps.NAME]) + self.assertTrue(port_neighbors[0][VProps.VITRAGE_IS_DELETED]) query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM, VProps.VITRAGE_TYPE: NAGIOS_DATASOURCE} port_neighbors = entity_graph.neighbors(port_vertex.vertex_id, vertex_attr_filter=query) - self.assertEqual(port_neighbors[0][VProps.VITRAGE_CATEGORY], - EntityCategory.ALARM) - self.assertEqual(port_neighbors[0][VProps.VITRAGE_TYPE], - NAGIOS_DATASOURCE) - self.assertEqual(port_neighbors[0][VProps.NAME], 'PORT_PROBLEM') - self.assertEqual(port_neighbors[0][VProps.VITRAGE_IS_DELETED], False) - self.assertEqual(port_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER], - False) + self.assertEqual(EntityCategory.ALARM, + port_neighbors[0][VProps.VITRAGE_CATEGORY]) + self.assertEqual(NAGIOS_DATASOURCE, + port_neighbors[0][VProps.VITRAGE_TYPE]) + self.assertEqual('PORT_PROBLEM', port_neighbors[0][VProps.NAME]) + self.assertFalse(port_neighbors[0][VProps.VITRAGE_IS_DELETED]) + self.assertFalse(port_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER]) # ################### STEP 3 ################### # disable connection between port and alarm @@ -544,14 +543,14 @@ class TestScenarioEvaluator(TestFunctionalBase): port_neighbors = entity_graph.neighbors(port_vertex.vertex_id, vertex_attr_filter=query) self.assertEqual(1, len(port_neighbors)) - self.assertEqual(port_neighbors[0][VProps.VITRAGE_CATEGORY], - EntityCategory.ALARM) - self.assertEqual(port_neighbors[0][VProps.VITRAGE_TYPE], - VITRAGE_DATASOURCE) - self.assertEqual(port_neighbors[0][VProps.NAME], - 'simple_port_deduced_alarm') - self.assertEqual(port_neighbors[0][VProps.VITRAGE_IS_DELETED], - vitrage_is_deleted) + self.assertEqual(EntityCategory.ALARM, + port_neighbors[0][VProps.VITRAGE_CATEGORY]) + self.assertEqual(VITRAGE_DATASOURCE, + port_neighbors[0][VProps.VITRAGE_TYPE]) + self.assertEqual('simple_port_deduced_alarm', + port_neighbors[0][VProps.NAME]) + self.assertEqual(vitrage_is_deleted, + port_neighbors[0][VProps.VITRAGE_IS_DELETED]) query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM, VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE, VProps.VITRAGE_IS_DELETED: False} @@ -561,12 +560,12 @@ class TestScenarioEvaluator(TestFunctionalBase): VProps.VITRAGE_TYPE: NAGIOS_DATASOURCE} port_neighbors = entity_graph.neighbors(port_vertex.vertex_id, vertex_attr_filter=query) - self.assertEqual(port_neighbors[0][VProps.VITRAGE_CATEGORY], - EntityCategory.ALARM) - self.assertEqual(port_neighbors[0][VProps.VITRAGE_TYPE], - NAGIOS_DATASOURCE) - self.assertEqual(port_neighbors[0][VProps.NAME], 'PORT_PROBLEM') - self.assertEqual(port_neighbors[0][VProps.VITRAGE_IS_DELETED], False) + self.assertEqual(EntityCategory.ALARM, + port_neighbors[0][VProps.VITRAGE_CATEGORY]) + self.assertEqual(NAGIOS_DATASOURCE, + port_neighbors[0][VProps.VITRAGE_TYPE]) + self.assertEqual('PORT_PROBLEM', port_neighbors[0][VProps.NAME]) + self.assertFalse(port_neighbors[0][VProps.VITRAGE_IS_DELETED]) # ################### STEP 4 ################### # enable connection between port and alarm @@ -602,15 +601,16 @@ class TestScenarioEvaluator(TestFunctionalBase): self.assertEqual(2, len(port_neighbors)) for in_counter in range(0, 1): self.assertEqual( - port_neighbors[in_counter][VProps.VITRAGE_CATEGORY], - EntityCategory.ALARM) - self.assertEqual(port_neighbors[in_counter] - [VProps.VITRAGE_TYPE], VITRAGE_DATASOURCE) - self.assertEqual(port_neighbors[in_counter][VProps.NAME], - 'simple_port_deduced_alarm') + EntityCategory.ALARM, + port_neighbors[in_counter][VProps.VITRAGE_CATEGORY]) + self.assertEqual(VITRAGE_DATASOURCE, + port_neighbors[in_counter] + [VProps.VITRAGE_TYPE]) + self.assertEqual('simple_port_deduced_alarm', + port_neighbors[in_counter][VProps.NAME]) self.assertEqual( - port_neighbors[in_counter][VProps.VITRAGE_IS_DELETED], - vitrage_is_deleted) + vitrage_is_deleted, + port_neighbors[in_counter][VProps.VITRAGE_IS_DELETED]) query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM, VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE, @@ -621,12 +621,12 @@ class TestScenarioEvaluator(TestFunctionalBase): VProps.VITRAGE_TYPE: NAGIOS_DATASOURCE} port_neighbors = entity_graph.neighbors(port_vertex.vertex_id, vertex_attr_filter=query) - self.assertEqual(port_neighbors[0][VProps.VITRAGE_CATEGORY], - EntityCategory.ALARM) - self.assertEqual(port_neighbors[0][VProps.VITRAGE_TYPE], - NAGIOS_DATASOURCE) - self.assertEqual(port_neighbors[0][VProps.NAME], 'PORT_PROBLEM') - self.assertEqual(port_neighbors[0][VProps.VITRAGE_IS_DELETED], False) + self.assertEqual(EntityCategory.ALARM, + port_neighbors[0][VProps.VITRAGE_CATEGORY]) + self.assertEqual(NAGIOS_DATASOURCE, + port_neighbors[0][VProps.VITRAGE_TYPE]) + self.assertEqual('PORT_PROBLEM', port_neighbors[0][VProps.NAME]) + self.assertFalse(port_neighbors[0][VProps.VITRAGE_IS_DELETED]) # ################### STEP 5 ################### # disable PORT_PROBLEM alarm @@ -658,15 +658,15 @@ class TestScenarioEvaluator(TestFunctionalBase): self.assertEqual(2, len(port_neighbors)) for in_counter in range(0, 1): self.assertEqual( - port_neighbors[in_counter][VProps.VITRAGE_CATEGORY], - EntityCategory.ALARM) - self.assertEqual(port_neighbors[in_counter] - [VProps.VITRAGE_TYPE], VITRAGE_DATASOURCE) - self.assertEqual(port_neighbors[in_counter][VProps.NAME], - 'simple_port_deduced_alarm') + EntityCategory.ALARM, + port_neighbors[in_counter][VProps.VITRAGE_CATEGORY]) + self.assertEqual(VITRAGE_DATASOURCE, port_neighbors[in_counter] + [VProps.VITRAGE_TYPE]) + self.assertEqual('simple_port_deduced_alarm', + port_neighbors[in_counter][VProps.NAME]) self.assertEqual( - port_neighbors[in_counter][VProps.VITRAGE_IS_DELETED], - vitrage_is_deleted) + vitrage_is_deleted, + port_neighbors[in_counter][VProps.VITRAGE_IS_DELETED]) query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM, VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE, @@ -677,12 +677,12 @@ class TestScenarioEvaluator(TestFunctionalBase): VProps.VITRAGE_TYPE: NAGIOS_DATASOURCE} port_neighbors = entity_graph.neighbors(port_vertex.vertex_id, vertex_attr_filter=query) - self.assertEqual(port_neighbors[0][VProps.VITRAGE_CATEGORY], - EntityCategory.ALARM) - self.assertEqual(port_neighbors[0][VProps.VITRAGE_TYPE], - NAGIOS_DATASOURCE) - self.assertEqual(port_neighbors[0][VProps.NAME], 'PORT_PROBLEM') - self.assertEqual(port_neighbors[0][VProps.VITRAGE_IS_DELETED], True) + self.assertEqual(EntityCategory.ALARM, + port_neighbors[0][VProps.VITRAGE_CATEGORY]) + self.assertEqual(NAGIOS_DATASOURCE, + port_neighbors[0][VProps.VITRAGE_TYPE]) + self.assertEqual('PORT_PROBLEM', port_neighbors[0][VProps.NAME]) + self.assertTrue(port_neighbors[0][VProps.VITRAGE_IS_DELETED]) def test_complex_not_operator_deduced_alarm(self): """Handles a complex not operator use case @@ -763,12 +763,12 @@ class TestScenarioEvaluator(TestFunctionalBase): self.assertEqual(num_orig_edges + num_added_edges + num_deduced_edges, entity_graph.num_edges()) self.assertEqual(1, len(zone_neighbors)) - self.assertEqual(zone_neighbors[0][VProps.VITRAGE_CATEGORY], - EntityCategory.ALARM) - self.assertEqual(zone_neighbors[0][VProps.VITRAGE_TYPE], - VITRAGE_DATASOURCE) - self.assertEqual(zone_neighbors[0][VProps.NAME], - 'complex_zone_deduced_alarm') + self.assertEqual(EntityCategory.ALARM, + zone_neighbors[0][VProps.VITRAGE_CATEGORY]) + self.assertEqual(VITRAGE_DATASOURCE, + zone_neighbors[0][VProps.VITRAGE_TYPE]) + self.assertEqual('complex_zone_deduced_alarm', + zone_neighbors[0][VProps.NAME]) # ################### STEP 2 ################### # Add NETWORK_PROBLEM alarm @@ -797,26 +797,24 @@ class TestScenarioEvaluator(TestFunctionalBase): network_neighbors = entity_graph.neighbors(network_vertex.vertex_id, vertex_attr_filter=query) self.assertEqual(1, len(network_neighbors)) - self.assertEqual(network_neighbors[0][VProps.VITRAGE_CATEGORY], - EntityCategory.ALARM) - self.assertEqual(network_neighbors[0][VProps.VITRAGE_TYPE], - NAGIOS_DATASOURCE) - self.assertEqual(network_neighbors[0][VProps.NAME], 'NETWORK_PROBLEM') - self.assertEqual(network_neighbors[0][VProps.VITRAGE_IS_DELETED], - False) - self.assertEqual(network_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER], - False) + self.assertEqual(EntityCategory.ALARM, + network_neighbors[0][VProps.VITRAGE_CATEGORY]) + self.assertEqual(NAGIOS_DATASOURCE, + network_neighbors[0][VProps.VITRAGE_TYPE]) + self.assertEqual('NETWORK_PROBLEM', network_neighbors[0][VProps.NAME]) + self.assertFalse(network_neighbors[0][VProps.VITRAGE_IS_DELETED]) + self.assertFalse(network_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER]) zone_neighbors = entity_graph.neighbors(zone_vertex.vertex_id, vertex_attr_filter=query) self.assertEqual(1, len(zone_neighbors)) - self.assertEqual(zone_neighbors[0][VProps.VITRAGE_CATEGORY], - EntityCategory.ALARM) - self.assertEqual(zone_neighbors[0][VProps.VITRAGE_TYPE], - VITRAGE_DATASOURCE) - self.assertEqual(zone_neighbors[0][VProps.NAME], - 'complex_zone_deduced_alarm') - self.assertEqual(zone_neighbors[0][VProps.VITRAGE_IS_DELETED], True) + self.assertEqual(EntityCategory.ALARM, + zone_neighbors[0][VProps.VITRAGE_CATEGORY]) + self.assertEqual(VITRAGE_DATASOURCE, + zone_neighbors[0][VProps.VITRAGE_TYPE]) + self.assertEqual('complex_zone_deduced_alarm', + zone_neighbors[0][VProps.NAME]) + self.assertTrue(zone_neighbors[0][VProps.VITRAGE_IS_DELETED]) # ################### STEP 3 ################### # delete NETWORK_PROBLEM alarm @@ -839,12 +837,12 @@ class TestScenarioEvaluator(TestFunctionalBase): network_neighbors = entity_graph.neighbors(network_vertex.vertex_id, vertex_attr_filter=query) self.assertEqual(1, len(network_neighbors)) - self.assertEqual(network_neighbors[0][VProps.VITRAGE_CATEGORY], - EntityCategory.ALARM) - self.assertEqual(network_neighbors[0][VProps.VITRAGE_TYPE], - NAGIOS_DATASOURCE) - self.assertEqual(network_neighbors[0][VProps.NAME], 'NETWORK_PROBLEM') - self.assertEqual(network_neighbors[0][VProps.VITRAGE_IS_DELETED], True) + self.assertEqual(EntityCategory.ALARM, + network_neighbors[0][VProps.VITRAGE_CATEGORY]) + self.assertEqual(NAGIOS_DATASOURCE, + network_neighbors[0][VProps.VITRAGE_TYPE]) + self.assertEqual('NETWORK_PROBLEM', network_neighbors[0][VProps.NAME]) + self.assertTrue(network_neighbors[0][VProps.VITRAGE_IS_DELETED]) query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM, VProps.VITRAGE_IS_DELETED: True} @@ -855,14 +853,14 @@ class TestScenarioEvaluator(TestFunctionalBase): zone_neighbors = entity_graph.neighbors(zone_vertex.vertex_id, vertex_attr_filter=query) self.assertEqual(1, len(zone_neighbors)) - self.assertEqual(zone_neighbors[0][VProps.VITRAGE_CATEGORY], - EntityCategory.ALARM) - self.assertEqual(zone_neighbors[0][VProps.VITRAGE_TYPE], - VITRAGE_DATASOURCE) - self.assertEqual(zone_neighbors[0][VProps.NAME], - 'complex_zone_deduced_alarm') - self.assertEqual(zone_neighbors[0][VProps.VITRAGE_IS_DELETED], - vitrage_is_deleted) + self.assertEqual(EntityCategory.ALARM, + zone_neighbors[0][VProps.VITRAGE_CATEGORY]) + self.assertEqual(VITRAGE_DATASOURCE, + zone_neighbors[0][VProps.VITRAGE_TYPE]) + self.assertEqual('complex_zone_deduced_alarm', + zone_neighbors[0][VProps.NAME]) + self.assertEqual(vitrage_is_deleted, + zone_neighbors[0][VProps.VITRAGE_IS_DELETED]) query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM, VProps.VITRAGE_IS_DELETED: False} @@ -920,29 +918,26 @@ class TestScenarioEvaluator(TestFunctionalBase): instance_neighbors = entity_graph.neighbors(instances[0].vertex_id, vertex_attr_filter=query) self.assertEqual(1, len(instance_neighbors)) - self.assertEqual(instance_neighbors[0][VProps.VITRAGE_CATEGORY], - EntityCategory.RESOURCE) - self.assertEqual(instance_neighbors[0][VProps.VITRAGE_TYPE], - CINDER_VOLUME_DATASOURCE) - self.assertEqual(instance_neighbors[0][VProps.NAME], 'volume-1') - self.assertEqual(instance_neighbors[0][VProps.VITRAGE_IS_DELETED], - False) - self.assertEqual(instance_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER], - False) + self.assertEqual(EntityCategory.RESOURCE, + instance_neighbors[0][VProps.VITRAGE_CATEGORY]) + self.assertEqual(CINDER_VOLUME_DATASOURCE, + instance_neighbors[0][VProps.VITRAGE_TYPE]) + self.assertEqual('volume-1', instance_neighbors[0][VProps.NAME]) + self.assertFalse(instance_neighbors[0][VProps.VITRAGE_IS_DELETED]) + self.assertFalse(instance_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER]) query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM, VProps.VITRAGE_TYPE: VITRAGE_DATASOURCE} host_neighbors = entity_graph.neighbors(hosts[0].vertex_id, vertex_attr_filter=query) - self.assertEqual(host_neighbors[0][VProps.VITRAGE_CATEGORY], - EntityCategory.ALARM) - self.assertEqual(host_neighbors[0][VProps.VITRAGE_TYPE], - VITRAGE_DATASOURCE) - self.assertEqual(host_neighbors[0][VProps.NAME], - 'ha_warning_deduced_alarm') - self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_DELETED], False) - self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER], - False) + self.assertEqual(EntityCategory.ALARM, + host_neighbors[0][VProps.VITRAGE_CATEGORY]) + self.assertEqual(VITRAGE_DATASOURCE, + host_neighbors[0][VProps.VITRAGE_TYPE]) + self.assertEqual('ha_warning_deduced_alarm', + host_neighbors[0][VProps.NAME]) + self.assertFalse(host_neighbors[0][VProps.VITRAGE_IS_DELETED]) + self.assertFalse(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER]) # ################### STEP 2 ################### # Add cinder volume 2 @@ -972,15 +967,13 @@ class TestScenarioEvaluator(TestFunctionalBase): instance_neighbors = entity_graph.neighbors(instances[1].vertex_id, vertex_attr_filter=query) self.assertEqual(1, len(instance_neighbors)) - self.assertEqual(instance_neighbors[0][VProps.VITRAGE_CATEGORY], - EntityCategory.RESOURCE) - self.assertEqual(instance_neighbors[0][VProps.VITRAGE_TYPE], - CINDER_VOLUME_DATASOURCE) - self.assertEqual(instance_neighbors[0][VProps.NAME], 'volume-2') - self.assertEqual(instance_neighbors[0][VProps.VITRAGE_IS_DELETED], - False) - self.assertEqual(instance_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER], - False) + self.assertEqual(EntityCategory.RESOURCE, + instance_neighbors[0][VProps.VITRAGE_CATEGORY]) + self.assertEqual(CINDER_VOLUME_DATASOURCE, + instance_neighbors[0][VProps.VITRAGE_TYPE]) + self.assertEqual('volume-2', instance_neighbors[0][VProps.NAME]) + self.assertFalse(instance_neighbors[0][VProps.VITRAGE_IS_DELETED]) + self.assertFalse(instance_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER]) # check ha_error_deduced_alarm query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM, @@ -989,15 +982,14 @@ class TestScenarioEvaluator(TestFunctionalBase): host_neighbors = entity_graph.neighbors(hosts[0].vertex_id, vertex_attr_filter=query) self.assertEqual(1, len(host_neighbors)) - self.assertEqual(host_neighbors[0][VProps.VITRAGE_CATEGORY], - EntityCategory.ALARM) - self.assertEqual(host_neighbors[0][VProps.VITRAGE_TYPE], - VITRAGE_DATASOURCE) - self.assertEqual(host_neighbors[0][VProps.NAME], - 'ha_error_deduced_alarm') - self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_DELETED], False) - self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER], - False) + self.assertEqual(EntityCategory.ALARM, + host_neighbors[0][VProps.VITRAGE_CATEGORY]) + self.assertEqual(VITRAGE_DATASOURCE, + host_neighbors[0][VProps.VITRAGE_TYPE]) + self.assertEqual('ha_error_deduced_alarm', + host_neighbors[0][VProps.NAME]) + self.assertFalse(host_neighbors[0][VProps.VITRAGE_IS_DELETED]) + self.assertFalse(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER]) # check ha_warning_deduced_alarm query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM, @@ -1006,15 +998,14 @@ class TestScenarioEvaluator(TestFunctionalBase): host_neighbors = entity_graph.neighbors(hosts[0].vertex_id, vertex_attr_filter=query) self.assertEqual(1, len(host_neighbors)) - self.assertEqual(host_neighbors[0][VProps.VITRAGE_CATEGORY], - EntityCategory.ALARM) - self.assertEqual(host_neighbors[0][VProps.VITRAGE_TYPE], - VITRAGE_DATASOURCE) - self.assertEqual(host_neighbors[0][VProps.NAME], - 'ha_warning_deduced_alarm') - self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_DELETED], True) - self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER], - False) + self.assertEqual(EntityCategory.ALARM, + host_neighbors[0][VProps.VITRAGE_CATEGORY]) + self.assertEqual(VITRAGE_DATASOURCE, + host_neighbors[0][VProps.VITRAGE_TYPE]) + self.assertEqual('ha_warning_deduced_alarm', + host_neighbors[0][VProps.NAME]) + self.assertTrue(host_neighbors[0][VProps.VITRAGE_IS_DELETED]) + self.assertFalse(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER]) # ################### STEP 3 ################### # Remove Cinder Volume 2 @@ -1043,15 +1034,13 @@ class TestScenarioEvaluator(TestFunctionalBase): instance_neighbors = entity_graph.neighbors(instances[1].vertex_id, vertex_attr_filter=query) self.assertEqual(1, len(instance_neighbors)) - self.assertEqual(instance_neighbors[0][VProps.VITRAGE_CATEGORY], - EntityCategory.RESOURCE) - self.assertEqual(instance_neighbors[0][VProps.VITRAGE_TYPE], - CINDER_VOLUME_DATASOURCE) - self.assertEqual(instance_neighbors[0][VProps.NAME], 'volume-2') - self.assertEqual(instance_neighbors[0][VProps.VITRAGE_IS_DELETED], - False) - self.assertEqual(instance_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER], - False) + self.assertEqual(EntityCategory.RESOURCE, + instance_neighbors[0][VProps.VITRAGE_CATEGORY]) + self.assertEqual(CINDER_VOLUME_DATASOURCE, + instance_neighbors[0][VProps.VITRAGE_TYPE]) + self.assertEqual('volume-2', instance_neighbors[0][VProps.NAME]) + self.assertFalse(instance_neighbors[0][VProps.VITRAGE_IS_DELETED]) + self.assertFalse(instance_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER]) # check ha_error_deduced_alarm query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM, @@ -1060,15 +1049,14 @@ class TestScenarioEvaluator(TestFunctionalBase): host_neighbors = entity_graph.neighbors(hosts[0].vertex_id, vertex_attr_filter=query) self.assertEqual(1, len(host_neighbors)) - self.assertEqual(host_neighbors[0][VProps.VITRAGE_CATEGORY], - EntityCategory.ALARM) - self.assertEqual(host_neighbors[0][VProps.VITRAGE_TYPE], - VITRAGE_DATASOURCE) - self.assertEqual(host_neighbors[0][VProps.NAME], - 'ha_error_deduced_alarm') - self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_DELETED], True) - self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER], - False) + self.assertEqual(EntityCategory.ALARM, + host_neighbors[0][VProps.VITRAGE_CATEGORY]) + self.assertEqual(VITRAGE_DATASOURCE, + host_neighbors[0][VProps.VITRAGE_TYPE]) + self.assertEqual('ha_error_deduced_alarm', + host_neighbors[0][VProps.NAME]) + self.assertTrue(host_neighbors[0][VProps.VITRAGE_IS_DELETED]) + self.assertFalse(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER]) # check new ha_warning_deduced_alarm query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM, @@ -1078,15 +1066,14 @@ class TestScenarioEvaluator(TestFunctionalBase): host_neighbors = entity_graph.neighbors(hosts[0].vertex_id, vertex_attr_filter=query) self.assertEqual(1, len(host_neighbors)) - self.assertEqual(host_neighbors[0][VProps.VITRAGE_CATEGORY], - EntityCategory.ALARM) - self.assertEqual(host_neighbors[0][VProps.VITRAGE_TYPE], - VITRAGE_DATASOURCE) - self.assertEqual(host_neighbors[0][VProps.NAME], - 'ha_warning_deduced_alarm') - self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_DELETED], False) - self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER], - False) + self.assertEqual(EntityCategory.ALARM, + host_neighbors[0][VProps.VITRAGE_CATEGORY]) + self.assertEqual(VITRAGE_DATASOURCE, + host_neighbors[0][VProps.VITRAGE_TYPE]) + self.assertEqual('ha_warning_deduced_alarm', + host_neighbors[0][VProps.NAME]) + self.assertFalse(host_neighbors[0][VProps.VITRAGE_IS_DELETED]) + self.assertFalse(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER]) # check old deleted ha_warning_deduced_alarm query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM, @@ -1096,15 +1083,14 @@ class TestScenarioEvaluator(TestFunctionalBase): host_neighbors = entity_graph.neighbors(hosts[0].vertex_id, vertex_attr_filter=query) self.assertEqual(1, len(host_neighbors)) - self.assertEqual(host_neighbors[0][VProps.VITRAGE_CATEGORY], - EntityCategory.ALARM) - self.assertEqual(host_neighbors[0][VProps.VITRAGE_TYPE], - VITRAGE_DATASOURCE) - self.assertEqual(host_neighbors[0][VProps.NAME], - 'ha_warning_deduced_alarm') - self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_DELETED], True) - self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER], - False) + self.assertEqual(EntityCategory.ALARM, + host_neighbors[0][VProps.VITRAGE_CATEGORY]) + self.assertEqual(VITRAGE_DATASOURCE, + host_neighbors[0][VProps.VITRAGE_TYPE]) + self.assertEqual('ha_warning_deduced_alarm', + host_neighbors[0][VProps.NAME]) + self.assertTrue(host_neighbors[0][VProps.VITRAGE_IS_DELETED]) + self.assertFalse(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER]) # ################### STEP 4 ################### # Remove Cinder Volume 1 @@ -1133,15 +1119,13 @@ class TestScenarioEvaluator(TestFunctionalBase): instance_neighbors = entity_graph.neighbors(instances[0].vertex_id, vertex_attr_filter=query) self.assertEqual(1, len(instance_neighbors)) - self.assertEqual(instance_neighbors[0][VProps.VITRAGE_CATEGORY], - EntityCategory.RESOURCE) - self.assertEqual(instance_neighbors[0][VProps.VITRAGE_TYPE], - CINDER_VOLUME_DATASOURCE) - self.assertEqual(instance_neighbors[0][VProps.NAME], 'volume-1') - self.assertEqual(instance_neighbors[0][VProps.VITRAGE_IS_DELETED], - False) - self.assertEqual(instance_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER], - False) + self.assertEqual(EntityCategory.RESOURCE, + instance_neighbors[0][VProps.VITRAGE_CATEGORY]) + self.assertEqual(CINDER_VOLUME_DATASOURCE, + instance_neighbors[0][VProps.VITRAGE_TYPE]) + self.assertEqual('volume-1', instance_neighbors[0][VProps.NAME]) + self.assertFalse(instance_neighbors[0][VProps.VITRAGE_IS_DELETED]) + self.assertFalse(instance_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER]) # check ha_error_deduced_alarm query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM, @@ -1150,15 +1134,14 @@ class TestScenarioEvaluator(TestFunctionalBase): host_neighbors = entity_graph.neighbors(hosts[0].vertex_id, vertex_attr_filter=query) self.assertEqual(1, len(host_neighbors)) - self.assertEqual(host_neighbors[0][VProps.VITRAGE_CATEGORY], - EntityCategory.ALARM) - self.assertEqual(host_neighbors[0][VProps.VITRAGE_TYPE], - VITRAGE_DATASOURCE) - self.assertEqual(host_neighbors[0][VProps.NAME], - 'ha_error_deduced_alarm') - self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_DELETED], True) - self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER], - False) + self.assertEqual(EntityCategory.ALARM, + host_neighbors[0][VProps.VITRAGE_CATEGORY]) + self.assertEqual(VITRAGE_DATASOURCE, + host_neighbors[0][VProps.VITRAGE_TYPE]) + self.assertEqual('ha_error_deduced_alarm', + host_neighbors[0][VProps.NAME]) + self.assertTrue(host_neighbors[0][VProps.VITRAGE_IS_DELETED]) + self.assertFalse(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER]) # check old ha_warning_deduced_alarm query = {VProps.VITRAGE_CATEGORY: EntityCategory.ALARM, @@ -1168,25 +1151,23 @@ class TestScenarioEvaluator(TestFunctionalBase): vertex_attr_filter=query) self.assertEqual(2, len(host_neighbors)) - self.assertEqual(host_neighbors[0][VProps.VITRAGE_CATEGORY], - EntityCategory.ALARM) - self.assertEqual(host_neighbors[0][VProps.VITRAGE_TYPE], - VITRAGE_DATASOURCE) - self.assertEqual(host_neighbors[0][VProps.NAME], - 'ha_warning_deduced_alarm') - self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_DELETED], True) - self.assertEqual(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER], - False) + self.assertEqual(EntityCategory.ALARM, + host_neighbors[0][VProps.VITRAGE_CATEGORY]) + self.assertEqual(VITRAGE_DATASOURCE, + host_neighbors[0][VProps.VITRAGE_TYPE]) + self.assertEqual('ha_warning_deduced_alarm', + host_neighbors[0][VProps.NAME]) + self.assertTrue(host_neighbors[0][VProps.VITRAGE_IS_DELETED]) + self.assertFalse(host_neighbors[0][VProps.VITRAGE_IS_PLACEHOLDER]) - self.assertEqual(host_neighbors[1][VProps.VITRAGE_CATEGORY], - EntityCategory.ALARM) - self.assertEqual(host_neighbors[1][VProps.VITRAGE_TYPE], - VITRAGE_DATASOURCE) - self.assertEqual(host_neighbors[1][VProps.NAME], - 'ha_warning_deduced_alarm') - self.assertEqual(host_neighbors[1][VProps.VITRAGE_IS_DELETED], True) - self.assertEqual(host_neighbors[1][VProps.VITRAGE_IS_PLACEHOLDER], - False) + self.assertEqual(EntityCategory.ALARM, + host_neighbors[1][VProps.VITRAGE_CATEGORY]) + self.assertEqual(VITRAGE_DATASOURCE, + host_neighbors[1][VProps.VITRAGE_TYPE]) + self.assertEqual('ha_warning_deduced_alarm', + host_neighbors[1][VProps.NAME]) + self.assertTrue(host_neighbors[1][VProps.VITRAGE_IS_DELETED]) + self.assertFalse(host_neighbors[1][VProps.VITRAGE_IS_PLACEHOLDER]) def test_simple_or_operator_deduced_alarm(self): """Handles a simple not operator use case diff --git a/vitrage/tests/unit/datasources/aodh/test_aodh_driver.py b/vitrage/tests/unit/datasources/aodh/test_aodh_driver.py index 74b69a534..5c3f0abe5 100644 --- a/vitrage/tests/unit/datasources/aodh/test_aodh_driver.py +++ b/vitrage/tests/unit/datasources/aodh/test_aodh_driver.py @@ -118,7 +118,7 @@ class AodhDriverTest(base.BaseTest): self.assertEqual(entity[AodhProps.SEVERITY], alarm[AodhProps.SEVERITY]) self.assertIsNone(entity[AodhProps.RESOURCE_ID]) - self.assertEqual(entity[AodhProps.EVENT_TYPE], "*") + self.assertEqual("*", entity[AodhProps.EVENT_TYPE]) self.assertEqual(entity[DSProps.EVENT_TYPE], AodhEventType.CREATION) @@ -148,8 +148,7 @@ class AodhDriverTest(base.BaseTest): self.assertEqual( entity[AodhProps.EVENT_TYPE], alarm[AodhProps.DETAIL][AodhProps.RULE][AodhProps.EVENT_TYPE]) - self.assertEqual(entity[AodhProps.RESOURCE_ID], - "1") + self.assertEqual("1", entity[AodhProps.RESOURCE_ID]) self.assertEqual(entity[DSProps.EVENT_TYPE], AodhEventType.RULE_CHANGE) diff --git a/vitrage/tests/unit/datasources/cinder/test_cinder_volume_transformer.py b/vitrage/tests/unit/datasources/cinder/test_cinder_volume_transformer.py index 29a806d62..24e9322fb 100644 --- a/vitrage/tests/unit/datasources/cinder/test_cinder_volume_transformer.py +++ b/vitrage/tests/unit/datasources/cinder/test_cinder_volume_transformer.py @@ -80,22 +80,22 @@ class TestCinderVolumeTransformer(base.BaseTest): TransformerBase.KEY_SEPARATOR) expected_id_values = transformer._key_values(CINDER_VOLUME_DATASOURCE, volume_id) - self.assertEqual(tuple(observed_id_values), expected_id_values) + self.assertEqual(expected_id_values, tuple(observed_id_values)) observed_time = placeholder.get(VProps.VITRAGE_SAMPLE_TIMESTAMP) - self.assertEqual(observed_time, timestamp) + self.assertEqual(timestamp, observed_time) observed_type = placeholder.get(VProps.VITRAGE_TYPE) - self.assertEqual(observed_type, CINDER_VOLUME_DATASOURCE) + self.assertEqual(CINDER_VOLUME_DATASOURCE, observed_type) observed_entity_id = placeholder.get(VProps.ID) - self.assertEqual(observed_entity_id, volume_id) + self.assertEqual(volume_id, observed_entity_id) observed_vitrage_category = placeholder.get(VProps.VITRAGE_CATEGORY) - self.assertEqual(observed_vitrage_category, EntityCategory.RESOURCE) + self.assertEqual(EntityCategory.RESOURCE, observed_vitrage_category) vitrage_is_placeholder = placeholder.get(VProps.VITRAGE_IS_PLACEHOLDER) - self.assertEqual(vitrage_is_placeholder, True) + self.assertTrue(vitrage_is_placeholder) def test_key_values(self): LOG.debug('Cinder Volume transformer test: get key values') diff --git a/vitrage/tests/unit/datasources/heat/test_heat_stack_transformer.py b/vitrage/tests/unit/datasources/heat/test_heat_stack_transformer.py index bceca7de2..5f99d91b1 100644 --- a/vitrage/tests/unit/datasources/heat/test_heat_stack_transformer.py +++ b/vitrage/tests/unit/datasources/heat/test_heat_stack_transformer.py @@ -81,22 +81,22 @@ class TestHeatStackTransformer(base.BaseTest): TransformerBase.KEY_SEPARATOR) expected_id_values = transformer._key_values(HEAT_STACK_DATASOURCE, stack_id) - self.assertEqual(tuple(observed_id_values), expected_id_values) + self.assertEqual(expected_id_values, tuple(observed_id_values)) observed_time = placeholder.get(VProps.VITRAGE_SAMPLE_TIMESTAMP) - self.assertEqual(observed_time, timestamp) + self.assertEqual(timestamp, observed_time) observed_type = placeholder.get(VProps.VITRAGE_TYPE) - self.assertEqual(observed_type, HEAT_STACK_DATASOURCE) + self.assertEqual(HEAT_STACK_DATASOURCE, observed_type) observed_entity_id = placeholder.get(VProps.ID) - self.assertEqual(observed_entity_id, stack_id) + self.assertEqual(stack_id, observed_entity_id) observed_vitrage_category = placeholder.get(VProps.VITRAGE_CATEGORY) - self.assertEqual(observed_vitrage_category, EntityCategory.RESOURCE) + self.assertEqual(EntityCategory.RESOURCE, observed_vitrage_category) vitrage_is_placeholder = placeholder.get(VProps.VITRAGE_IS_PLACEHOLDER) - self.assertEqual(vitrage_is_placeholder, True) + self.assertTrue(vitrage_is_placeholder) def test_key_values(self): LOG.debug('Heat Stack transformer test: get key values') diff --git a/vitrage/tests/unit/datasources/nova/test_nova_host_transformer.py b/vitrage/tests/unit/datasources/nova/test_nova_host_transformer.py index 0fb39b777..0167372fc 100644 --- a/vitrage/tests/unit/datasources/nova/test_nova_host_transformer.py +++ b/vitrage/tests/unit/datasources/nova/test_nova_host_transformer.py @@ -80,22 +80,22 @@ class NovaHostTransformerTest(base.BaseTest): expected_id_values = host_transformer._key_values( NOVA_HOST_DATASOURCE, host_name) - self.assertEqual(tuple(observed_id_values), expected_id_values) + self.assertEqual(expected_id_values, tuple(observed_id_values)) observed_time = placeholder.get(VProps.VITRAGE_SAMPLE_TIMESTAMP) - self.assertEqual(observed_time, timestamp) + self.assertEqual(timestamp, observed_time) observed_subtype = placeholder.get(VProps.VITRAGE_TYPE) - self.assertEqual(observed_subtype, NOVA_HOST_DATASOURCE) + self.assertEqual(NOVA_HOST_DATASOURCE, observed_subtype) observed_entity_id = placeholder.get(VProps.ID) - self.assertEqual(observed_entity_id, host_name) + self.assertEqual(host_name, observed_entity_id) observed_vitrage_category = placeholder.get(VProps.VITRAGE_CATEGORY) - self.assertEqual(observed_vitrage_category, EntityCategory.RESOURCE) + self.assertEqual(EntityCategory.RESOURCE, observed_vitrage_category) vitrage_is_placeholder = placeholder.get(VProps.VITRAGE_IS_PLACEHOLDER) - self.assertEqual(vitrage_is_placeholder, True) + self.assertTrue(vitrage_is_placeholder) def test_key_values(self): diff --git a/vitrage/tests/unit/datasources/nova/test_nova_instance_transformer.py b/vitrage/tests/unit/datasources/nova/test_nova_instance_transformer.py index a5410b2ca..5a8fad186 100644 --- a/vitrage/tests/unit/datasources/nova/test_nova_instance_transformer.py +++ b/vitrage/tests/unit/datasources/nova/test_nova_instance_transformer.py @@ -79,22 +79,22 @@ class NovaInstanceTransformerTest(base.BaseTest): TransformerBase.KEY_SEPARATOR) expected_id_values = transformer._key_values(NOVA_INSTANCE_DATASOURCE, instance_id) - self.assertEqual(tuple(observed_id_values), expected_id_values) + self.assertEqual(expected_id_values, tuple(observed_id_values)) observed_time = placeholder.get(VProps.VITRAGE_SAMPLE_TIMESTAMP) - self.assertEqual(observed_time, timestamp) + self.assertEqual(timestamp, observed_time) observed_type = placeholder.get(VProps.VITRAGE_TYPE) - self.assertEqual(observed_type, NOVA_INSTANCE_DATASOURCE) + self.assertEqual(NOVA_INSTANCE_DATASOURCE, observed_type) observed_entity_id = placeholder.get(VProps.ID) - self.assertEqual(observed_entity_id, instance_id) + self.assertEqual(instance_id, observed_entity_id) observed_vitrage_category = placeholder.get(VProps.VITRAGE_CATEGORY) - self.assertEqual(observed_vitrage_category, EntityCategory.RESOURCE) + self.assertEqual(EntityCategory.RESOURCE, observed_vitrage_category) vitrage_is_placeholder = placeholder.get(VProps.VITRAGE_IS_PLACEHOLDER) - self.assertEqual(vitrage_is_placeholder, True) + self.assertTrue(vitrage_is_placeholder) def test_snapshot_event_transform(self): LOG.debug('Test tactual transform action for ' diff --git a/vitrage/tests/unit/datasources/nova/test_nova_zone_transformer.py b/vitrage/tests/unit/datasources/nova/test_nova_zone_transformer.py index 61f5a1820..907831a41 100644 --- a/vitrage/tests/unit/datasources/nova/test_nova_zone_transformer.py +++ b/vitrage/tests/unit/datasources/nova/test_nova_zone_transformer.py @@ -80,22 +80,22 @@ class NovaZoneTransformerTest(base.BaseTest): TransformerBase.KEY_SEPARATOR) expected_id_values = self.transformers[NOVA_ZONE_DATASOURCE].\ _key_values(NOVA_ZONE_DATASOURCE, zone_name) - self.assertEqual(tuple(observed_id_values), expected_id_values) + self.assertEqual(expected_id_values, tuple(observed_id_values)) observed_time = placeholder.get(VProps.VITRAGE_SAMPLE_TIMESTAMP) - self.assertEqual(observed_time, timestamp) + self.assertEqual(timestamp, observed_time) observed_subtype = placeholder.get(VProps.VITRAGE_TYPE) - self.assertEqual(observed_subtype, NOVA_ZONE_DATASOURCE) + self.assertEqual(NOVA_ZONE_DATASOURCE, observed_subtype) observed_entity_id = placeholder.get(VProps.ID) - self.assertEqual(observed_entity_id, zone_name) + self.assertEqual(zone_name, observed_entity_id) observed_vitrage_category = placeholder.get(VProps.VITRAGE_CATEGORY) - self.assertEqual(observed_vitrage_category, EntityCategory.RESOURCE) + self.assertEqual(EntityCategory.RESOURCE, observed_vitrage_category) vitrage_is_placeholder = placeholder.get(VProps.VITRAGE_IS_PLACEHOLDER) - self.assertEqual(vitrage_is_placeholder, True) + self.assertTrue(vitrage_is_placeholder) def test_key_values(self): LOG.debug('Zone transformer test: get key values') @@ -208,13 +208,12 @@ class NovaZoneTransformerTest(base.BaseTest): self.assertEqual(cluster_neighbor.vertex[VProps.VITRAGE_ID], cluster_neighbor.vertex.vertex_id) - self.assertEqual(False, - cluster_neighbor.vertex[VProps.VITRAGE_IS_DELETED]) + self.assertFalse(cluster_neighbor.vertex[VProps.VITRAGE_IS_DELETED]) self.assertEqual(EntityCategory.RESOURCE, cluster_neighbor.vertex[VProps.VITRAGE_CATEGORY]) self.assertEqual(CLUSTER_ID, cluster_neighbor.vertex[VProps.ID]) - self.assertEqual(False, cluster_neighbor.vertex[ + self.assertFalse(cluster_neighbor.vertex[ VProps.VITRAGE_IS_PLACEHOLDER]) self.assertEqual(OPENSTACK_CLUSTER, cluster_neighbor.vertex[VProps.VITRAGE_TYPE]) diff --git a/vitrage/tests/unit/datasources/static/test_static_transformer.py b/vitrage/tests/unit/datasources/static/test_static_transformer.py index c37423105..537f15401 100644 --- a/vitrage/tests/unit/datasources/static/test_static_transformer.py +++ b/vitrage/tests/unit/datasources/static/test_static_transformer.py @@ -67,22 +67,22 @@ class TestStaticTransformer(base.BaseTest): observed_entity_id = placeholder.vertex_id expected_entity_id = 'RESOURCE:static:12345' - self.assertEqual(observed_entity_id, expected_entity_id) + self.assertEqual(expected_entity_id, observed_entity_id) observed_time = placeholder.get(VProps.VITRAGE_SAMPLE_TIMESTAMP) - self.assertEqual(observed_time, self.timestamp) + self.assertEqual(self.timestamp, observed_time) observed_subtype = placeholder.get(VProps.VITRAGE_TYPE) - self.assertEqual(observed_subtype, self.entity_type) + self.assertEqual(self.entity_type, observed_subtype) observed_entity_id = placeholder.get(VProps.ID) - self.assertEqual(observed_entity_id, self.entity_id) + self.assertEqual(self.entity_id, observed_entity_id) observed_vitrage_category = placeholder.get(VProps.VITRAGE_CATEGORY) - self.assertEqual(observed_vitrage_category, EntityCategory.RESOURCE) + self.assertEqual(EntityCategory.RESOURCE, observed_vitrage_category) vitrage_is_placeholder = placeholder.get(VProps.VITRAGE_IS_PLACEHOLDER) - self.assertEqual(vitrage_is_placeholder, True) + self.assertTrue(vitrage_is_placeholder) def test_snapshot_transform(self): vals_list = mock_driver.simple_static_generators(snapshot_events=1) @@ -110,7 +110,7 @@ class TestStaticTransformer(base.BaseTest): event[DSProps.SAMPLE_DATE]) for k, v in event.get(StaticFields.METADATA, {}): - self.assertEqual(vertex[k], v) + self.assertEqual(v, vertex[k]) def _validate_common_props(self, vertex, event): self.assertEqual(vertex[VProps.VITRAGE_CATEGORY], diff --git a/vitrage/tests/unit/datasources/static_physical/test_static_physical_driver.py b/vitrage/tests/unit/datasources/static_physical/test_static_physical_driver.py index db4640d21..4bba9fd70 100644 --- a/vitrage/tests/unit/datasources/static_physical/test_static_physical_driver.py +++ b/vitrage/tests/unit/datasources/static_physical/test_static_physical_driver.py @@ -113,24 +113,24 @@ class TestStaticPhysicalDriver(base.BaseTest): # Test Assertions status = any(change[StaticFields.TYPE] == SWITCH and change[StaticFields.ID] == '12345' for change in changes) - self.assertEqual(False, status) + self.assertFalse(status) status = any(change[StaticFields.TYPE] == SWITCH and change[StaticFields.ID] == '23456' and change[DSProps.EVENT_TYPE] == GraphAction.DELETE_ENTITY for change in changes) - self.assertEqual(True, status) + self.assertTrue(status) status = any(change[StaticFields.TYPE] == SWITCH and change[StaticFields.ID] == '34567' for change in changes) - self.assertEqual(True, status) + self.assertTrue(status) status = any(change[StaticFields.TYPE] == SWITCH and change[StaticFields.ID] == '45678' for change in changes) - self.assertEqual(True, status) + self.assertTrue(status) status = any(change[StaticFields.TYPE] == SWITCH and change[StaticFields.ID] == '56789' for change in changes) - self.assertEqual(True, status) + self.assertTrue(status) self.assertEqual(4, len(changes)) diff --git a/vitrage/tests/unit/datasources/static_physical/test_static_physical_transformer.py b/vitrage/tests/unit/datasources/static_physical/test_static_physical_transformer.py index 946ea8ec4..c14137dce 100644 --- a/vitrage/tests/unit/datasources/static_physical/test_static_physical_transformer.py +++ b/vitrage/tests/unit/datasources/static_physical/test_static_physical_transformer.py @@ -81,22 +81,22 @@ class TestStaticPhysicalTransformer(base.BaseTest): expected_id_values = \ self.transformers[STATIC_PHYSICAL_DATASOURCE]._key_values( switch_type, switch_name) - self.assertEqual(tuple(observed_id_values), expected_id_values) + self.assertEqual(expected_id_values, tuple(observed_id_values)) observed_time = placeholder.get(VProps.VITRAGE_SAMPLE_TIMESTAMP) - self.assertEqual(observed_time, timestamp) + self.assertEqual(timestamp, observed_time) observed_subtype = placeholder.get(VProps.VITRAGE_TYPE) - self.assertEqual(observed_subtype, switch_type) + self.assertEqual(switch_type, observed_subtype) observed_entity_id = placeholder.get(VProps.ID) - self.assertEqual(observed_entity_id, switch_name) + self.assertEqual(switch_name, observed_entity_id) observed_vitrage_category = placeholder.get(VProps.VITRAGE_CATEGORY) - self.assertEqual(observed_vitrage_category, EntityCategory.RESOURCE) + self.assertEqual(EntityCategory.RESOURCE, observed_vitrage_category) vitrage_is_placeholder = placeholder.get(VProps.VITRAGE_IS_PLACEHOLDER) - self.assertEqual(vitrage_is_placeholder, True) + self.assertTrue(vitrage_is_placeholder) def test_key_values(self): LOG.debug('Static Physical transformer test: get key values') diff --git a/vitrage/tests/unit/datasources/test_datasource_update_method.py b/vitrage/tests/unit/datasources/test_datasource_update_method.py index a13ec1622..704f9b50b 100644 --- a/vitrage/tests/unit/datasources/test_datasource_update_method.py +++ b/vitrage/tests/unit/datasources/test_datasource_update_method.py @@ -190,5 +190,5 @@ class DatasourceUpdateMethod(base.BaseTest): self.assertNotIn(ZABBIX_DATASOURCE_PULL_NO_INTERVAL, pull_drivers) def test_datasources_notification_topic(self): - self.assertEqual(self.conf.datasources.notification_topic, - 'vitrage_notifications') + self.assertEqual('vitrage_notifications', + self.conf.datasources.notification_topic) diff --git a/vitrage/tests/unit/datasources/test_rescheduler_functions.py b/vitrage/tests/unit/datasources/test_rescheduler_functions.py index 221ab0fcb..3cc3bf950 100644 --- a/vitrage/tests/unit/datasources/test_rescheduler_functions.py +++ b/vitrage/tests/unit/datasources/test_rescheduler_functions.py @@ -95,7 +95,7 @@ class ReschedulerTester(base.BaseTest): fault_interval=FAULT_INTERVAL, times=RESCHEDULING_TIMES) # Test assertions - self.assertEqual(len(self.rescheduler.scheduler.queue), TASKS_NUM) + self.assertEqual(TASKS_NUM, len(self.rescheduler.scheduler.queue)) self.reset_test_params() def test_reset(self): @@ -111,7 +111,7 @@ class ReschedulerTester(base.BaseTest): # Test action self.rescheduler.reset() # Test assertions - self.assertEqual(len(self.rescheduler.scheduler.queue), 0) + self.assertEqual(0, len(self.rescheduler.scheduler.queue)) self.reset_test_params() def test_rescheduling(self): diff --git a/vitrage/tests/unit/entity_graph/processor/test_processor.py b/vitrage/tests/unit/entity_graph/processor/test_processor.py index ae894fa9b..d57facee7 100644 --- a/vitrage/tests/unit/entity_graph/processor/test_processor.py +++ b/vitrage/tests/unit/entity_graph/processor/test_processor.py @@ -187,7 +187,7 @@ class TestProcessor(TestEntityGraphUnitBase): vertex2.vertex_id, 'backup') self.assertEqual(3, processor.entity_graph.num_edges()) - self.assertEqual(True, edge_from_graph[EProps.VITRAGE_IS_DELETED]) + self.assertTrue(edge_from_graph[EProps.VITRAGE_IS_DELETED]) def test_remove_deleted_entity(self): # setup @@ -254,9 +254,9 @@ class TestProcessor(TestEntityGraphUnitBase): vertex.vertex_id, neighbor_edge.label) self.assertIsNotNone(old_edge) - self.assertEqual(old_edge[EProps.VITRAGE_IS_DELETED], True) + self.assertTrue(old_edge[EProps.VITRAGE_IS_DELETED]) self.assertIsNotNone(new_edge) - self.assertEqual(new_edge[EProps.VITRAGE_IS_DELETED], False) + self.assertFalse(new_edge[EProps.VITRAGE_IS_DELETED]) # update instance with the same neighbor processor._update_neighbors(vertex, neighbors) @@ -291,7 +291,7 @@ class TestProcessor(TestEntityGraphUnitBase): neighbor_edge.label) self.assertIsNone(old_edge) self.assertIsNotNone(new_edge) - self.assertEqual(new_edge[EProps.VITRAGE_IS_DELETED], False) + self.assertFalse(new_edge[EProps.VITRAGE_IS_DELETED]) # update instance with the same neighbor processor._update_neighbors(vertex, neighbors) diff --git a/vitrage/tests/unit/evaluator/template_validation/content/base.py b/vitrage/tests/unit/evaluator/template_validation/content/base.py index 3afaa1b20..ebaa15c4e 100644 --- a/vitrage/tests/unit/evaluator/template_validation/content/base.py +++ b/vitrage/tests/unit/evaluator/template_validation/content/base.py @@ -39,7 +39,7 @@ class ValidatorTest(base.BaseTest): self.assertTrue(result.is_valid_config) self.assertEqual(result.comment, status_msgs[0]) - self.assertEqual(result.status_code, 0) + self.assertEqual(0, result.status_code) def _assert_fault_result(self, result, status_code): diff --git a/vitrage/tests/unit/evaluator/template_validation/test_template_syntax_validator.py b/vitrage/tests/unit/evaluator/template_validation/test_template_syntax_validator.py index ee0f8b822..279dd476f 100644 --- a/vitrage/tests/unit/evaluator/template_validation/test_template_syntax_validator.py +++ b/vitrage/tests/unit/evaluator/template_validation/test_template_syntax_validator.py @@ -222,7 +222,7 @@ class TemplateSyntaxValidatorTest(base.BaseTest): # Test assertions self.assertFalse(result.is_valid_config) self.assertTrue(result.comment.startswith(status_msgs[expected_code])) - self.assertEqual(result.status_code, expected_code) + self.assertEqual(expected_code, result.status_code) def _test_execution_with_correct_result(self, template): @@ -232,7 +232,7 @@ class TemplateSyntaxValidatorTest(base.BaseTest): # Test assertions self.assertTrue(result.is_valid_config) self.assertEqual(result.comment, status_msgs[0]) - self.assertEqual(result.status_code, 0) + self.assertEqual(0, result.status_code) @staticmethod def _hide_useless_logging_messages(): diff --git a/vitrage/tests/unit/evaluator/test_scenario_repository.py b/vitrage/tests/unit/evaluator/test_scenario_repository.py index ccc9d17c6..afd8b8a3e 100644 --- a/vitrage/tests/unit/evaluator/test_scenario_repository.py +++ b/vitrage/tests/unit/evaluator/test_scenario_repository.py @@ -123,11 +123,11 @@ class EquivalentScenarioTest(base.BaseTest): for key, scenarios in entity_scenarios.items(): if (VProps.VITRAGE_CATEGORY, EntityCategory.ALARM) in key: # scenarios expanded on the other alarm - self.assertEqual(len(scenarios), 2) + self.assertEqual(2, len(scenarios)) if (VProps.VITRAGE_CATEGORY, EntityCategory.RESOURCE) in key: # Scenarios expanded on the two alarms. Each alarm is expanded # to two equivalent alarms. Thus 2 x 2 = 4 in total - self.assertEqual(len(scenarios), 4) + self.assertEqual(4, len(scenarios)) # each relationship is expand to two. Thus 2 x 2 = 4 in total relationships = self.scenario_repository.relationship_scenarios.keys() - self.assertEqual(len(relationships), 4) + self.assertEqual(4, len(relationships)) diff --git a/vitrage/tests/unit/evaluator/test_template_data.py b/vitrage/tests/unit/evaluator/test_template_data.py index dd42f09b6..a41ae79ac 100644 --- a/vitrage/tests/unit/evaluator/test_template_data.py +++ b/vitrage/tests/unit/evaluator/test_template_data.py @@ -191,12 +191,12 @@ class BasicTemplateTest(base.BaseTest): :param entities """ self.assertIsNotNone(scenarios) - self.assertEqual(len(scenarios), 1) + self.assertEqual(1, len(scenarios)) scenario = scenarios[0] condition = scenario.condition - self.assertEqual(len(condition), 1) + self.assertEqual(1, len(condition)) condition_var = condition[0][0] self.assertIsInstance(condition_var, ConditionVar) @@ -206,16 +206,16 @@ class BasicTemplateTest(base.BaseTest): actions = scenario.actions self.assert_is_not_empty(scenario.actions) - self.assertEqual(len(actions), 1) + self.assertEqual(1, len(actions)) action = actions[0] self.assertEqual(action.type, ActionType.SET_STATE) targets = action.targets - self.assertEqual(len(targets), 1) - self.assertEqual(targets['target'], 'resource') + self.assertEqual(1, len(targets)) + self.assertEqual('resource', targets['target']) properties = action.properties - self.assertEqual(len(properties), 1) + self.assertEqual(1, len(properties)) self.assertEqual(properties['state'], OperationalResourceState.SUBOPTIMAL) diff --git a/vitrage/tests/unit/notifier/snmp_notifier/test_snmp_sender_with_severity_map.py b/vitrage/tests/unit/notifier/snmp_notifier/test_snmp_sender_with_severity_map.py index eca77bfad..cca25a824 100644 --- a/vitrage/tests/unit/notifier/snmp_notifier/test_snmp_sender_with_severity_map.py +++ b/vitrage/tests/unit/notifier/snmp_notifier/test_snmp_sender_with_severity_map.py @@ -56,8 +56,8 @@ class SnmpNotifierTest(base.BaseTest): oids, var_lst = self.snmp_sender._build_oids() - self.assertEqual(len(oids), 4) - self.assertEqual(len(var_lst), 3) + self.assertEqual(4, len(oids)) + self.assertEqual(3, len(var_lst)) self.assertIn(VProps.NAME, oids) self.assertIn(VProps.VITRAGE_IS_DELETED, oids) @@ -76,7 +76,7 @@ class SnmpNotifierTest(base.BaseTest): var_binds = self.snmp_sender._get_var_binds(common.alarm_data) - self.assertEqual(len(var_binds), 3) + self.assertEqual(3, len(var_binds)) self.assertIn((oid_with_alarm_objects + '.' + common.NAME_OID, OctetString(common.alarm_data.get(VProps.NAME, diff --git a/vitrage/tests/unit/notifier/snmp_notifier/test_snmp_sender_without_severity_map.py b/vitrage/tests/unit/notifier/snmp_notifier/test_snmp_sender_without_severity_map.py index 1c3947dc9..f1bcdb153 100644 --- a/vitrage/tests/unit/notifier/snmp_notifier/test_snmp_sender_without_severity_map.py +++ b/vitrage/tests/unit/notifier/snmp_notifier/test_snmp_sender_without_severity_map.py @@ -55,8 +55,8 @@ class SnmpNotifierTest(base.BaseTest): oids, var_lst = self.snmp_sender._build_oids() - self.assertEqual(len(oids), 4) - self.assertEqual(len(var_lst), 3) + self.assertEqual(4, len(oids)) + self.assertEqual(3, len(var_lst)) self.assertIn(VProps.NAME, oids) self.assertIn(VProps.VITRAGE_IS_DELETED, oids) diff --git a/vitrage_tempest_tests/tests/api/rca/base.py b/vitrage_tempest_tests/tests/api/rca/base.py index 0a6dcdf29..9f8a9ee0c 100644 --- a/vitrage_tempest_tests/tests/api/rca/base.py +++ b/vitrage_tempest_tests/tests/api/rca/base.py @@ -83,9 +83,9 @@ class BaseRcaTest(BaseAlarmsTest): [VITRAGE_DATASOURCE, VITRAGE_ALARM_NAME, OperationalAlarmSeverity.WARNING]) - self.assertEqual(len(rca), 3) - self.assertEqual(len(resource_alarm), 1) - self.assertEqual(len(deduce_alarms), 2) + self.assertEqual(3, len(rca)) + self.assertEqual(1, len(resource_alarm)) + self.assertEqual(2, len(deduce_alarms)) def _validate_deduce_alarms(self, alarms, instances): """Validate alarm existence """ @@ -106,9 +106,9 @@ class BaseRcaTest(BaseAlarmsTest): NOVA_INSTANCE_DATASOURCE, utils.uni2str(instances[1].id)]) - self.assertEqual(len(alarms), 3) - self.assertEqual(len(deduce_alarms_1), 1) - self.assertEqual(len(deduce_alarms_2), 1) + self.assertEqual(3, len(alarms)) + self.assertEqual(1, len(deduce_alarms_1)) + self.assertEqual(1, len(deduce_alarms_2)) def _validate_relationship(self, links, alarms): self.assertNotEqual(len(links), 0, 'The links list is empty') @@ -126,7 +126,7 @@ class BaseRcaTest(BaseAlarmsTest): or target_alarm_name != VITRAGE_ALARM_NAME: flag = False - self.assertEqual(len(alarms), 3) + self.assertEqual(3, len(alarms)) self.assertTrue(flag) def _validate_set_state(self, topology, instances): @@ -159,9 +159,9 @@ class BaseRcaTest(BaseAlarmsTest): OperationalResourceState.SUBOPTIMAL, OperationalResourceState.SUBOPTIMAL]) - self.assertEqual(len(host), 1) - self.assertEqual(len(vm1), 1) - self.assertEqual(len(vm2), 1) + self.assertEqual(1, len(host)) + self.assertEqual(1, len(vm1)) + self.assertEqual(1, len(vm2)) def _validate_notifier(self, alarms, vitrage_alarms): self.assertNotEqual(len(alarms), 0, 'The aodh alarms list is empty') @@ -182,8 +182,8 @@ class BaseRcaTest(BaseAlarmsTest): validation += 1 break - self.assertEqual(len(vitrage_alarms), validation) - self.assertEqual(len(alarms), 3) + self.assertEqual(validation, len(vitrage_alarms)) + self.assertEqual(3, len(alarms)) def _get_hostname(self): return self._get_value(item=self._get_host(), key=VProps.ID) diff --git a/vitrage_tempest_tests/tests/api/templates/base.py b/vitrage_tempest_tests/tests/api/templates/base.py index 30c236349..ba367edbd 100644 --- a/vitrage_tempest_tests/tests/api/templates/base.py +++ b/vitrage_tempest_tests/tests/api/templates/base.py @@ -108,10 +108,10 @@ class BaseTemplateTest(BaseApiTest): self, template, validation, path): self.assertNotEqual(len(validation), 0, 'The template validation is empty') - self.assertEqual(validation['file path'], path) - self.assertEqual(validation['status code'], 0) - self.assertEqual(validation['status'], self.OK_STATUS) - self.assertEqual(validation['message'], self.OK_MSG) + self.assertEqual(path, validation['file path']) + self.assertEqual(0, validation['status code']) + self.assertEqual(self.OK_STATUS, validation['status']) + self.assertEqual(self.OK_MSG, validation['message']) self.assertEqual(validation['message'], template['status details']) def _run_template_validation( @@ -119,14 +119,14 @@ class BaseTemplateTest(BaseApiTest): self.assertIn(path, validation['file path']) if negative: - self.assertEqual(validation['status code'], 3) - self.assertEqual(validation['status'], self.ERROR_STATUS) + self.assertEqual(3, validation['status code']) + self.assertEqual(self.ERROR_STATUS, validation['status']) self.assertNotEqual(validation['message'], self.OK_MSG) return - self.assertEqual(validation['status code'], 0) - self.assertEqual(validation['status'], self.OK_STATUS) - self.assertEqual(validation['message'], self.OK_MSG) + self.assertEqual(0, validation['status code']) + self.assertEqual(self.OK_STATUS, validation['status']) + self.assertEqual(self.OK_MSG, validation['message']) def _compare_template_show(self, api_templates, cli_templates): self.assertNotEqual(len(api_templates), 0, @@ -157,8 +157,8 @@ class BaseTemplateTest(BaseApiTest): self.assertIn( template_show['metadata']['name'], template_content) self.assertEqual( - len(template_show['definitions']['entities']), entities) + entities, len(template_show['definitions']['entities'])) self.assertEqual( - len(template_show['definitions']['relationships']), relationships) + relationships, len(template_show['definitions']['relationships'])) self.assertEqual( - len(template_show['scenarios']), scenarios) + scenarios, len(template_show['scenarios'])) diff --git a/vitrage_tempest_tests/tests/api/templates/test_template.py b/vitrage_tempest_tests/tests/api/templates/test_template.py index f5a6d1456..728b2288d 100644 --- a/vitrage_tempest_tests/tests/api/templates/test_template.py +++ b/vitrage_tempest_tests/tests/api/templates/test_template.py @@ -78,8 +78,8 @@ class TestValidate(BaseTemplateTest): validation = self.vitrage_client.template.validate(path=path) self.assertIsNone(validation) except Exception as up: - self.assertEqual(up.strerror, 'No such file or directory') - self.assertEqual(up.errno, 2) + self.assertEqual('No such file or directory', up.strerror) + self.assertEqual(2, up.errno) def test_templates_validate_corrupted_templates(self): """templates_validate test @@ -90,7 +90,7 @@ class TestValidate(BaseTemplateTest): try: path = self.TEST_PATH + self.ERROR_FILE validation = self.vitrage_client.template.validate(path=path) - self.assertEqual(len(validation['results']), 1) + self.assertEqual(1, len(validation['results'])) self._run_template_validation( validation['results'][0], path, negative=True) except Exception: @@ -104,7 +104,7 @@ class TestValidate(BaseTemplateTest): try: path = self.TEST_PATH + self.OK_FILE validation = self.vitrage_client.template.validate(path=path) - self.assertEqual(len(validation['results']), 1) + self.assertEqual(1, len(validation['results'])) self._run_template_validation( validation['results'][0], path) except Exception: diff --git a/vitrage_tempest_tests/tests/api/topology/test_topology.py b/vitrage_tempest_tests/tests/api/topology/test_topology.py index 229f801a4..5a766536f 100644 --- a/vitrage_tempest_tests/tests/api/topology/test_topology.py +++ b/vitrage_tempest_tests/tests/api/topology/test_topology.py @@ -348,8 +348,8 @@ class TestTopology(BaseTopologyTest): except ClientException as e: self.assertEqual(403, e.code) self.assertEqual( - str(e.message), - "Graph-type 'graph' requires a 'root' with 'depth'") + "Graph-type 'graph' requires a 'root' with 'depth'", + str(e.message)) finally: self._rollback_to_default()