From c440cdd69fa536fe1f0ac374e41849a0559b2714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Antal?= Date: Tue, 1 Mar 2016 18:14:05 +0100 Subject: [PATCH] Fixed wrongly used assertEqual method In several places, assertEqual is used the following way: assertEqual(observed, expected) However, the correct way to use assertEqual is: assertEqual(expected, observed) Change-Id: I5a7442f4adf98bf7bc73cef1d17d20da39d9a7f8 Closes-Bug: #1551861 --- watcher/tests/api/test_utils.py | 2 +- watcher/tests/api/v1/test_actions.py | 13 +++-- watcher/tests/api/v1/test_actions_plans.py | 2 +- watcher/tests/api/v1/test_audits.py | 2 +- .../tests/applier/actions/test_migration.py | 2 +- .../test_trigger_action_plan_endpoint.py | 2 +- watcher/tests/applier/test_applier_manager.py | 4 +- .../test_default_workflow_engine.py | 16 +++--- watcher/tests/cmd/test_api.py | 4 +- watcher/tests/cmd/test_applier.py | 4 +- watcher/tests/cmd/test_db_manage.py | 4 +- watcher/tests/cmd/test_decision_engine.py | 4 +- watcher/tests/common/loader/test_loader.py | 2 +- .../common/messaging/test_messaging_core.py | 14 +++--- .../messaging/test_messaging_handler.py | 4 +- .../tests/common/test_ceilometer_helper.py | 10 ++-- watcher/tests/common/test_nova_helper.py | 6 +-- .../decision_engine/model/test_disk_info.py | 4 +- .../decision_engine/model/test_mapping.py | 36 ++++++------- .../tests/decision_engine/model/test_model.py | 10 ++-- .../model/test_named_element.py | 4 +- .../tests/decision_engine/model/test_vm.py | 4 +- .../planner/test_default_planner.py | 10 ++-- .../solution/test_default_solution.py | 10 ++-- .../selector/test_strategy_selector.py | 2 +- .../strategies/test_basic_consolidation.py | 50 +++++++++---------- .../strategies/test_outlet_temp_control.py | 20 ++++---- watcher/tests/objects/test_action.py | 2 +- watcher/tests/objects/test_action_plan.py | 2 +- watcher/tests/objects/test_audit.py | 2 +- watcher/tests/objects/test_audit_template.py | 2 +- watcher/tests/objects/test_objects.py | 26 +++++----- .../tests/api/admin/test_action.py | 19 +++---- .../tests/api/admin/test_action_plan.py | 8 +-- .../tests/api/admin/test_api_discovery.py | 2 +- .../tests/api/admin/test_audit.py | 4 +- .../tests/api/admin/test_audit_template.py | 2 +- .../tests/api/admin/test_goal.py | 4 +- .../scenario/test_execute_basic_optim.py | 4 +- .../scenario/test_execute_dummy_optim.py | 8 +-- 40 files changed, 163 insertions(+), 167 deletions(-) diff --git a/watcher/tests/api/test_utils.py b/watcher/tests/api/test_utils.py index 3a84be21f..a889eba4d 100644 --- a/watcher/tests/api/test_utils.py +++ b/watcher/tests/api/test_utils.py @@ -44,7 +44,7 @@ class TestApiUtilsValidScenarios(base.TestCase): cfg.CONF.set_override("max_limit", self.max_limit, group="api", enforce_type=True) actual_limit = v1_utils.validate_limit(self.limit) - self.assertEqual(actual_limit, self.expected) + self.assertEqual(self.expected, actual_limit) class TestApiUtilsInvalidScenarios(base.TestCase): diff --git a/watcher/tests/api/v1/test_actions.py b/watcher/tests/api/v1/test_actions.py index 0387fcdfa..8e88b39ed 100644 --- a/watcher/tests/api/v1/test_actions.py +++ b/watcher/tests/api/v1/test_actions.py @@ -310,16 +310,15 @@ class TestListAction(api_base.FunctionalTest): self.assertEqual(len(ap2_action_list), len(response['actions'])) # We deleted them so that's normal - self.assertEqual( - [act for act in response['actions'] - if act['action_plan_uuid'] == action_plan1.uuid], - []) + self.assertEqual([], + [act for act in response['actions'] + if act['action_plan_uuid'] == action_plan1.uuid]) # Here are the 2 actions left self.assertEqual( + set([act.as_dict()['uuid'] for act in ap2_action_list]), set([act['uuid'] for act in response['actions'] - if act['action_plan_uuid'] == action_plan2.uuid]), - set([act.as_dict()['uuid'] for act in ap2_action_list])) + if act['action_plan_uuid'] == action_plan2.uuid])) def test_many_with_next_uuid(self): action_list = [] @@ -584,7 +583,7 @@ class TestDelete(api_base.FunctionalTest): return_deleted_at = timeutils.strtime(action['deleted_at']) self.assertEqual(timeutils.strtime(test_time), return_deleted_at) - self.assertEqual(action['state'], 'DELETED') + self.assertEqual('DELETED', action['state']) def test_delete_action_not_found(self): uuid = utils.generate_uuid() diff --git a/watcher/tests/api/v1/test_actions_plans.py b/watcher/tests/api/v1/test_actions_plans.py index d7663b5ee..136c91c1c 100644 --- a/watcher/tests/api/v1/test_actions_plans.py +++ b/watcher/tests/api/v1/test_actions_plans.py @@ -334,7 +334,7 @@ class TestDelete(api_base.FunctionalTest): self.assertTrue(ap_response.json['error_message']) # Nor does the action - self.assertEqual(len(acts_response['actions']), 0) + self.assertEqual(0, len(acts_response['actions'])) self.assertEqual(404, act_response.status_int) self.assertEqual('application/json', act_response.content_type) self.assertTrue(act_response.json['error_message']) diff --git a/watcher/tests/api/v1/test_audits.py b/watcher/tests/api/v1/test_audits.py index e10d3869e..782dbac7b 100644 --- a/watcher/tests/api/v1/test_audits.py +++ b/watcher/tests/api/v1/test_audits.py @@ -564,7 +564,7 @@ class TestDelete(api_base.FunctionalTest): return_deleted_at = timeutils.strtime(audit['deleted_at']) self.assertEqual(timeutils.strtime(test_time), return_deleted_at) - self.assertEqual(audit['state'], 'DELETED') + self.assertEqual('DELETED', audit['state']) def test_delete_audit_not_found(self): uuid = utils.generate_uuid() diff --git a/watcher/tests/applier/actions/test_migration.py b/watcher/tests/applier/actions/test_migration.py index 6bee69c34..766250fb2 100644 --- a/watcher/tests/applier/actions/test_migration.py +++ b/watcher/tests/applier/actions/test_migration.py @@ -152,7 +152,7 @@ class TestMigration(base.TestCase): exc = self.assertRaises( exception.InstanceNotFound, self.action.execute) self.m_helper.find_instance.assert_called_once_with(self.INSTANCE_UUID) - self.assertEqual(exc.kwargs["name"], self.INSTANCE_UUID) + self.assertEqual(self.INSTANCE_UUID, exc.kwargs["name"]) def test_execute_live_migration(self): self.m_helper.find_instance.return_value = self.INSTANCE_UUID diff --git a/watcher/tests/applier/messaging/test_trigger_action_plan_endpoint.py b/watcher/tests/applier/messaging/test_trigger_action_plan_endpoint.py index 2231dd8f9..cb6bf907f 100644 --- a/watcher/tests/applier/messaging/test_trigger_action_plan_endpoint.py +++ b/watcher/tests/applier/messaging/test_trigger_action_plan_endpoint.py @@ -38,4 +38,4 @@ class TestTriggerActionPlan(base.TestCase): action_plan_uuid = utils.generate_uuid() expected_uuid = self.endpoint.launch_action_plan(self.context, action_plan_uuid) - self.assertEqual(action_plan_uuid, expected_uuid) + self.assertEqual(expected_uuid, action_plan_uuid) diff --git a/watcher/tests/applier/test_applier_manager.py b/watcher/tests/applier/test_applier_manager.py index 9502c9da0..a890486ca 100644 --- a/watcher/tests/applier/test_applier_manager.py +++ b/watcher/tests/applier/test_applier_manager.py @@ -35,5 +35,5 @@ class TestApplierManager(base.TestCase): def test_connect(self, m_messaging, m_thread): self.applier.connect() self.applier.join() - self.assertEqual(m_messaging.call_count, 2) - self.assertEqual(m_thread.call_count, 1) + self.assertEqual(2, m_messaging.call_count) + self.assertEqual(1, m_thread.call_count) diff --git a/watcher/tests/applier/workflow_engine/test_default_workflow_engine.py b/watcher/tests/applier/workflow_engine/test_default_workflow_engine.py index 99e1aa903..0b45effab 100644 --- a/watcher/tests/applier/workflow_engine/test_default_workflow_engine.py +++ b/watcher/tests/applier/workflow_engine/test_default_workflow_engine.py @@ -66,7 +66,7 @@ class TestDefaultWorkFlowEngine(base.DbTestCase): def test_execute(self): actions = mock.MagicMock() result = self.engine.execute(actions) - self.assertEqual(result, True) + self.assertEqual(True, result) def create_action(self, action_type, parameters, next): action = { @@ -85,7 +85,7 @@ class TestDefaultWorkFlowEngine(base.DbTestCase): def check_action_state(self, action, expected_state): to_check = objects.Action.get_by_uuid(self.context, action.uuid) - self.assertEqual(to_check.state, expected_state) + self.assertEqual(expected_state, to_check.state) def check_actions_state(self, actions, expected_state): for a in actions: @@ -94,12 +94,12 @@ class TestDefaultWorkFlowEngine(base.DbTestCase): def test_execute_with_no_actions(self): actions = [] result = self.engine.execute(actions) - self.assertEqual(result, True) + self.assertEqual(True, result) def test_execute_with_one_action(self): actions = [self.create_action("nop", {'message': 'test'}, None)] result = self.engine.execute(actions) - self.assertEqual(result, True) + self.assertEqual(True, result) self.check_actions_state(actions, objects.action.State.SUCCEEDED) def test_execute_with_two_actions(self): @@ -111,7 +111,7 @@ class TestDefaultWorkFlowEngine(base.DbTestCase): actions.append(next) result = self.engine.execute(actions) - self.assertEqual(result, True) + self.assertEqual(True, result) self.check_actions_state(actions, objects.action.State.SUCCEEDED) def test_execute_with_three_actions(self): @@ -128,7 +128,7 @@ class TestDefaultWorkFlowEngine(base.DbTestCase): actions.append(next2) result = self.engine.execute(actions) - self.assertEqual(result, True) + self.assertEqual(True, result) self.check_actions_state(actions, objects.action.State.SUCCEEDED) def test_execute_with_exception(self): @@ -145,7 +145,7 @@ class TestDefaultWorkFlowEngine(base.DbTestCase): actions.append(next2) result = self.engine.execute(actions) - self.assertEqual(result, False) + self.assertEqual(False, result) self.check_action_state(first, objects.action.State.SUCCEEDED) self.check_action_state(next, objects.action.State.SUCCEEDED) self.check_action_state(next2, objects.action.State.FAILED) @@ -162,5 +162,5 @@ class TestDefaultWorkFlowEngine(base.DbTestCase): namespace=FakeAction.namespace()) actions = [self.create_action("dontcare", {}, None)] result = self.engine.execute(actions) - self.assertEqual(result, False) + self.assertEqual(False, result) self.check_action_state(actions[0], objects.action.State.FAILED) diff --git a/watcher/tests/cmd/test_api.py b/watcher/tests/cmd/test_api.py index 0d855562f..a7397c4fc 100644 --- a/watcher/tests/cmd/test_api.py +++ b/watcher/tests/cmd/test_api.py @@ -54,7 +54,7 @@ class TestApi(BaseTestCase): def test_run_api_app(self, m_make, m_make_app): m_make_app.return_value = load_test_app(config=api_config.PECAN_CONFIG) api.main() - self.assertEqual(m_make.call_count, 1) + self.assertEqual(1, m_make.call_count) @patch("watcher.api.app.pecan.make_app") @patch.object(BaseServer, "serve_forever", Mock()) @@ -63,4 +63,4 @@ class TestApi(BaseTestCase): cfg.CONF.set_default("host", "localhost", group="api") m_make_app.return_value = load_test_app(config=api_config.PECAN_CONFIG) api.main() - self.assertEqual(m_make.call_count, 1) + self.assertEqual(1, m_make.call_count) diff --git a/watcher/tests/cmd/test_applier.py b/watcher/tests/cmd/test_applier.py index 84f60ac68..205403f61 100644 --- a/watcher/tests/cmd/test_applier.py +++ b/watcher/tests/cmd/test_applier.py @@ -47,5 +47,5 @@ class TestApplier(BaseTestCase): @patch.object(ApplierManager, "join") def test_run_applier_app(self, m_connect, m_join): applier.main() - self.assertEqual(m_connect.call_count, 1) - self.assertEqual(m_join.call_count, 1) + self.assertEqual(1, m_connect.call_count) + self.assertEqual(1, m_join.call_count) diff --git a/watcher/tests/cmd/test_db_manage.py b/watcher/tests/cmd/test_db_manage.py index b0380ee46..95b54e92e 100644 --- a/watcher/tests/cmd/test_db_manage.py +++ b/watcher/tests/cmd/test_db_manage.py @@ -48,7 +48,7 @@ class TestDBManageRunApp(TestCase): m_sys.argv = list(filter(None, ["watcher-db-manage", self.command])) dbmanage.main() - self.assertEqual(m_func.call_count, 1) + self.assertEqual(1, m_func.call_count) m_prepare_service.assert_called_once_with( ["watcher-db-manage", self.expected]) @@ -97,4 +97,4 @@ class TestDBManageRunCommand(TestCase): def test_run_db_version(self, m_version): dbmanage.DBCommand.version() - self.assertEqual(m_version.call_count, 1) + self.assertEqual(1, m_version.call_count) diff --git a/watcher/tests/cmd/test_decision_engine.py b/watcher/tests/cmd/test_decision_engine.py index baabfdb85..54612bd1a 100644 --- a/watcher/tests/cmd/test_decision_engine.py +++ b/watcher/tests/cmd/test_decision_engine.py @@ -49,5 +49,5 @@ class TestDecisionEngine(BaseTestCase): @patch.object(DecisionEngineManager, "join") def test_run_de_app(self, m_connect, m_join): decisionengine.main() - self.assertEqual(m_connect.call_count, 1) - self.assertEqual(m_join.call_count, 1) + self.assertEqual(1, m_connect.call_count) + self.assertEqual(1, m_join.call_count) diff --git a/watcher/tests/common/loader/test_loader.py b/watcher/tests/common/loader/test_loader.py index 79c45b89b..09c5723f7 100644 --- a/watcher/tests/common/loader/test_loader.py +++ b/watcher/tests/common/loader/test_loader.py @@ -42,7 +42,7 @@ class TestLoader(BaseTestCase): loader_manager = DefaultLoader(namespace='TESTING') loaded_driver = loader_manager.load(name='fake') - self.assertEqual(loaded_driver.get_name(), FakeLoadable.get_name()) + self.assertEqual(FakeLoadable.get_name(), loaded_driver.get_name()) @mock.patch("watcher.common.loader.default.DriverManager") def test_load_driver_bad_plugin(self, m_driver_manager): diff --git a/watcher/tests/common/messaging/test_messaging_core.py b/watcher/tests/common/messaging/test_messaging_core.py index da735c821..52e70eab1 100644 --- a/watcher/tests/common/messaging/test_messaging_core.py +++ b/watcher/tests/common/messaging/test_messaging_core.py @@ -32,13 +32,13 @@ class TestMessagingCore(base.TestCase): def test_connect(self, m_handler): messaging = messaging_core.MessagingCore("", "", "") messaging.connect() - self.assertEqual(m_handler.call_count, 2) + self.assertEqual(2, m_handler.call_count) @mock.patch.object(messaging_handler, "MessagingHandler") def test_disconnect(self, m_handler): messaging = messaging_core.MessagingCore("", "", "") messaging.disconnect() - self.assertEqual(m_handler.call_count, 2) + self.assertEqual(2, m_handler.call_count) def test_build_topic_handler(self): topic_name = "MyTopic" @@ -102,9 +102,9 @@ class TestMessagingCore(base.TestCase): topic = messaging.build_topic_handler("test_topic") self.assertIsInstance(topic, messaging_handler.MessagingHandler) - self.assertEqual(messaging.publisher_id, "pub_id") - self.assertEqual(topic.publisher_id, "pub_id") + self.assertEqual("pub_id", messaging.publisher_id) + self.assertEqual("pub_id", topic.publisher_id) - self.assertEqual( - messaging.conductor_topic_handler.topic_name, "test_topic") - self.assertEqual(topic.topic_name, "test_topic") + self.assertEqual("test_topic", + messaging.conductor_topic_handler.topic_name) + self.assertEqual("test_topic", topic.topic_name) diff --git a/watcher/tests/common/messaging/test_messaging_handler.py b/watcher/tests/common/messaging/test_messaging_handler.py index 94fadc1d5..2dddeb13c 100644 --- a/watcher/tests/common/messaging/test_messaging_handler.py +++ b/watcher/tests/common/messaging/test_messaging_handler.py @@ -70,8 +70,8 @@ class TestMessagingHandler(base.TestCase): serializer=None, ) - self.assertEqual(handler.endpoints, [self.ENDPOINT]) + self.assertEqual([self.ENDPOINT], handler.endpoints) handler.remove_endpoint(self.ENDPOINT) - self.assertEqual(handler.endpoints, []) + self.assertEqual([], handler.endpoints) diff --git a/watcher/tests/common/test_ceilometer_helper.py b/watcher/tests/common/test_ceilometer_helper.py index 3430c2c6f..095cf406b 100644 --- a/watcher/tests/common/test_ceilometer_helper.py +++ b/watcher/tests/common/test_ceilometer_helper.py @@ -44,7 +44,7 @@ class TestCeilometerHelper(base.BaseTestCase): user_ids=["user_ids"], tenant_ids=["tenant_ids"], resource_ids=["resource_ids"]) - self.assertEqual(query, expected) + self.assertEqual(expected, query) def test_statistic_aggregation(self, mock_ceilometer): cm = ceilometer_helper.CeilometerHelper() @@ -60,7 +60,7 @@ class TestCeilometerHelper(base.BaseTestCase): meter_name="cpu_util", period="7300" ) - self.assertEqual(val, expected_result) + self.assertEqual(expected_result, val) def test_get_last_sample(self, mock_ceilometer): ceilometer = mock.MagicMock() @@ -74,7 +74,7 @@ class TestCeilometerHelper(base.BaseTestCase): resource_id="id", meter_name="compute.node.percent" ) - self.assertEqual(val, expected_result) + self.assertEqual(expected_result, val) def test_get_last_sample_none(self, mock_ceilometer): ceilometer = mock.MagicMock() @@ -86,7 +86,7 @@ class TestCeilometerHelper(base.BaseTestCase): resource_id="id", meter_name="compute.node.percent" ) - self.assertEqual(val, expected) + self.assertEqual(expected, val) def test_statistic_list(self, mock_ceilometer): ceilometer = mock.MagicMock() @@ -95,4 +95,4 @@ class TestCeilometerHelper(base.BaseTestCase): mock_ceilometer.return_value = ceilometer cm = ceilometer_helper.CeilometerHelper() val = cm.statistic_list(meter_name="cpu_util") - self.assertEqual(val, expected_value) + self.assertEqual(expected_value, val) diff --git a/watcher/tests/common/test_nova_helper.py b/watcher/tests/common/test_nova_helper.py index f705e6b2f..da522f743 100644 --- a/watcher/tests/common/test_nova_helper.py +++ b/watcher/tests/common/test_nova_helper.py @@ -51,7 +51,7 @@ class TestNovaHelper(base.TestCase): nova_util.nova.servers.list.return_value = [server] result = nova_util.stop_instance(instance_id) - self.assertEqual(result, True) + self.assertEqual(True, result) def test_set_host_offline(self, mock_glance, mock_cinder, mock_neutron, mock_nova): @@ -60,7 +60,7 @@ class TestNovaHelper(base.TestCase): nova_util.nova.hosts = mock.MagicMock() nova_util.nova.hosts.get.return_value = host result = nova_util.set_host_offline("rennes") - self.assertEqual(result, True) + self.assertEqual(True, result) @mock.patch.object(time, 'sleep', mock.Mock()) def test_live_migrate_instance(self, mock_glance, mock_cinder, @@ -85,7 +85,7 @@ class TestNovaHelper(base.TestCase): self.instance_uuid, self.destination_hypervisor) - self.assertEqual(is_success, False) + self.assertEqual(False, is_success) @mock.patch.object(time, 'sleep', mock.Mock()) def test_watcher_non_live_migrate_instance_volume( diff --git a/watcher/tests/decision_engine/model/test_disk_info.py b/watcher/tests/decision_engine/model/test_disk_info.py index caf459335..7498b332d 100644 --- a/watcher/tests/decision_engine/model/test_disk_info.py +++ b/watcher/tests/decision_engine/model/test_disk_info.py @@ -25,9 +25,9 @@ class TestDiskInfo(base.BaseTestCase): def test_all(self): disk_information = DiskInfo() disk_information.set_size(1024) - self.assertEqual(disk_information.get_size(), 1024) + self.assertEqual(1024, disk_information.get_size()) disk_information.set_scheduler = "scheduler_qcq" disk_information.set_device_name("nom_qcq") - self.assertEqual(disk_information.get_device_name(), "nom_qcq") + self.assertEqual("nom_qcq", disk_information.get_device_name()) diff --git a/watcher/tests/decision_engine/model/test_mapping.py b/watcher/tests/decision_engine/model/test_mapping.py index 9101b89c5..e92b04403 100644 --- a/watcher/tests/decision_engine/model/test_mapping.py +++ b/watcher/tests/decision_engine/model/test_mapping.py @@ -40,35 +40,35 @@ class TestMapping(base.BaseTestCase): if vm.uuid != self.VM1_UUID: vm = vms[keys[1]] node = model.mapping.get_node_from_vm(vm) - self.assertEqual(node.uuid, 'Node_0') + self.assertEqual('Node_0', node.uuid) def test_get_node_from_vm_id(self): fake_cluster = faker_cluster_state.FakerModelCollector() model = fake_cluster.generate_scenario_3_with_2_hypervisors() hyps = model.mapping.get_node_vms_from_id("BLABLABLA") - self.assertEqual(hyps.__len__(), 0) + self.assertEqual(0, hyps.__len__()) def test_get_all_vms(self): fake_cluster = faker_cluster_state.FakerModelCollector() model = fake_cluster.generate_scenario_3_with_2_hypervisors() vms = model.get_all_vms() - self.assertEqual(vms.__len__(), 2) - self.assertEqual(vms[self.VM1_UUID].state, - vm_state.VMState.ACTIVE.value) - self.assertEqual(vms[self.VM1_UUID].uuid, self.VM1_UUID) - self.assertEqual(vms[self.VM2_UUID].state, - vm_state.VMState.ACTIVE.value) - self.assertEqual(vms[self.VM2_UUID].uuid, self.VM2_UUID) + self.assertEqual(2, vms.__len__()) + self.assertEqual(vm_state.VMState.ACTIVE.value, + vms[self.VM1_UUID].state) + self.assertEqual(self.VM1_UUID, vms[self.VM1_UUID].uuid) + self.assertEqual(vm_state.VMState.ACTIVE.value, + vms[self.VM2_UUID].state) + self.assertEqual(self.VM2_UUID, vms[self.VM2_UUID].uuid) def test_get_mapping(self): fake_cluster = faker_cluster_state.FakerModelCollector() model = fake_cluster.generate_scenario_3_with_2_hypervisors() mapping_vm = model.mapping.get_mapping_vm() - self.assertEqual(mapping_vm.__len__(), 2) - self.assertEqual(mapping_vm[self.VM1_UUID], 'Node_0') - self.assertEqual(mapping_vm[self.VM2_UUID], 'Node_1') + self.assertEqual(2, mapping_vm.__len__()) + self.assertEqual('Node_0', mapping_vm[self.VM1_UUID]) + self.assertEqual('Node_1', mapping_vm[self.VM2_UUID]) def test_migrate_vm(self): fake_cluster = faker_cluster_state.FakerModelCollector() @@ -80,10 +80,10 @@ class TestMapping(base.BaseTestCase): vm1 = vms[keys[1]] hyp1 = model.mapping.get_node_from_vm_id(vm1.uuid) - self.assertEqual(model.mapping.migrate_vm(vm1, hyp1, hyp1), False) - self.assertEqual(model.mapping.migrate_vm(vm1, hyp0, hyp0), False) - self.assertEqual(model.mapping.migrate_vm(vm1, hyp1, hyp0), True) - self.assertEqual(model.mapping.migrate_vm(vm1, hyp0, hyp1), True) + self.assertEqual(False, model.mapping.migrate_vm(vm1, hyp1, hyp1)) + self.assertEqual(False, model.mapping.migrate_vm(vm1, hyp0, hyp0)) + self.assertEqual(True, model.mapping.migrate_vm(vm1, hyp1, hyp0)) + self.assertEqual(True, model.mapping.migrate_vm(vm1, hyp0, hyp1)) def test_unmap_from_id_log_warning(self): fake_cluster = faker_cluster_state.FakerModelCollector() @@ -108,5 +108,5 @@ class TestMapping(base.BaseTestCase): hyp0 = model.mapping.get_node_from_vm_id(vm0.uuid) model.mapping.unmap_from_id(hyp0.uuid, vm0.uuid) - self.assertEqual(len(model.mapping.get_node_vms_from_id( - hyp0.uuid)), 0) + self.assertEqual(0, len(model.mapping.get_node_vms_from_id( + hyp0.uuid))) diff --git a/watcher/tests/decision_engine/model/test_model.py b/watcher/tests/decision_engine/model/test_model.py index 8bbfce7af..cdee9fa83 100644 --- a/watcher/tests/decision_engine/model/test_model.py +++ b/watcher/tests/decision_engine/model/test_model.py @@ -33,9 +33,9 @@ class TestModel(base.BaseTestCase): fake_cluster = FakerModelCollector() model = fake_cluster.generate_scenario_1() - self.assertEqual(len(model._hypervisors), 5) - self.assertEqual(len(model._vms), 35) - self.assertEqual(len(model.get_mapping().get_mapping()), 5) + self.assertEqual(5, len(model._hypervisors)) + self.assertEqual(35, len(model._vms)) + self.assertEqual(5, len(model.get_mapping().get_mapping())) def test_add_hypervisor(self): model = ModelRoot() @@ -43,7 +43,7 @@ class TestModel(base.BaseTestCase): hypervisor = Hypervisor() hypervisor.uuid = id model.add_hypervisor(hypervisor) - self.assertEqual(model.get_hypervisor_from_id(id), hypervisor) + self.assertEqual(hypervisor, model.get_hypervisor_from_id(id)) def test_delete_hypervisor(self): model = ModelRoot() @@ -51,7 +51,7 @@ class TestModel(base.BaseTestCase): hypervisor = Hypervisor() hypervisor.uuid = id model.add_hypervisor(hypervisor) - self.assertEqual(model.get_hypervisor_from_id(id), hypervisor) + self.assertEqual(hypervisor, model.get_hypervisor_from_id(id)) model.remove_hypervisor(hypervisor) self.assertRaises(exception.HypervisorNotFound, model.get_hypervisor_from_id, id) diff --git a/watcher/tests/decision_engine/model/test_named_element.py b/watcher/tests/decision_engine/model/test_named_element.py index 76181a0c0..90786a997 100644 --- a/watcher/tests/decision_engine/model/test_named_element.py +++ b/watcher/tests/decision_engine/model/test_named_element.py @@ -24,9 +24,9 @@ class TestNamedElement(base.BaseTestCase): def test_namedelement(self): id = ComputeResource() id.uuid = "BLABLABLA" - self.assertEqual(id.uuid, "BLABLABLA") + self.assertEqual("BLABLABLA", id.uuid) def test_set_get_human_id(self): id = ComputeResource() id.human_id = "BLABLABLA" - self.assertEqual(id.human_id, "BLABLABLA") + self.assertEqual("BLABLABLA", id.human_id) diff --git a/watcher/tests/decision_engine/model/test_vm.py b/watcher/tests/decision_engine/model/test_vm.py index e1527dc12..d55f1cf17 100644 --- a/watcher/tests/decision_engine/model/test_vm.py +++ b/watcher/tests/decision_engine/model/test_vm.py @@ -25,6 +25,6 @@ class TestVm(base.BaseTestCase): def test_namedelement(self): vm = VM() vm.state = VMState.ACTIVE - self.assertEqual(vm.state, VMState.ACTIVE) + self.assertEqual(VMState.ACTIVE, vm.state) vm.human_id = "human_05" - self.assertEqual(vm.human_id, "human_05") + self.assertEqual("human_05", vm.human_id) diff --git a/watcher/tests/decision_engine/planner/test_default_planner.py b/watcher/tests/decision_engine/planner/test_default_planner.py index b9e206e4d..1ace1a30c 100644 --- a/watcher/tests/decision_engine/planner/test_default_planner.py +++ b/watcher/tests/decision_engine/planner/test_default_planner.py @@ -79,10 +79,10 @@ class TestActionScheduling(base.DbTestCase): ) self.assertIsNotNone(action_plan.uuid) - self.assertEqual(m_create_action.call_count, 1) + self.assertEqual(1, m_create_action.call_count) filters = {'action_plan_id': action_plan.id} actions = objects.Action.dbapi.get_action_list(self.context, filters) - self.assertEqual(actions[0].action_type, "migrate") + self.assertEqual("migrate", actions[0].action_type) def test_schedule_two_actions(self): default_planner = pbase.DefaultPlanner() @@ -108,12 +108,12 @@ class TestActionScheduling(base.DbTestCase): self.context, audit.id, solution ) self.assertIsNotNone(action_plan.uuid) - self.assertEqual(m_create_action.call_count, 2) + self.assertEqual(2, m_create_action.call_count) # check order filters = {'action_plan_id': action_plan.id} actions = objects.Action.dbapi.get_action_list(self.context, filters) - self.assertEqual(actions[0].action_type, "nop") - self.assertEqual(actions[1].action_type, "migrate") + self.assertEqual("nop", actions[0].action_type) + self.assertEqual("migrate", actions[1].action_type) class TestDefaultPlanner(base.DbTestCase): diff --git a/watcher/tests/decision_engine/solution/test_default_solution.py b/watcher/tests/decision_engine/solution/test_default_solution.py index 7632644a3..0c67333ad 100644 --- a/watcher/tests/decision_engine/solution/test_default_solution.py +++ b/watcher/tests/decision_engine/solution/test_default_solution.py @@ -28,14 +28,14 @@ class TestDefaultSolution(base.BaseTestCase): solution.add_action(action_type="nop", resource_id="b199db0c-1408-4d52-b5a5-5ca14de0ff36", input_parameters=parameters) - self.assertEqual(len(solution.actions), 1) + self.assertEqual(1, len(solution.actions)) expected_action_type = "nop" expected_parameters = { "src_uuid_hypervisor": "server1", "dst_uuid_hypervisor": "server2", "resource_id": "b199db0c-1408-4d52-b5a5-5ca14de0ff36" } - self.assertEqual(solution.actions[0].get('action_type'), - expected_action_type) - self.assertEqual(solution.actions[0].get('input_parameters'), - expected_parameters) + self.assertEqual(expected_action_type, + solution.actions[0].get('action_type')) + self.assertEqual(expected_parameters, + solution.actions[0].get('input_parameters')) diff --git a/watcher/tests/decision_engine/strategy/selector/test_strategy_selector.py b/watcher/tests/decision_engine/strategy/selector/test_strategy_selector.py index 516bbbec5..3fc756428 100644 --- a/watcher/tests/decision_engine/strategy/selector/test_strategy_selector.py +++ b/watcher/tests/decision_engine/strategy/selector/test_strategy_selector.py @@ -46,4 +46,4 @@ class TestStrategySelector(TestCase): self.assertRaises(WatcherException, self.strategy_selector.define_from_goal, "DUMMY") - self.assertEqual(mock_call.call_count, 0) + self.assertEqual(0, mock_call.call_count) diff --git a/watcher/tests/decision_engine/strategy/strategies/test_basic_consolidation.py b/watcher/tests/decision_engine/strategy/strategies/test_basic_consolidation.py index 80b72f01b..3f925c429 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_basic_consolidation.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_basic_consolidation.py @@ -41,7 +41,7 @@ class TestBasicConsolidation(base.BaseTestCase): size_cluster = len( self.fake_cluster.generate_scenario_1().get_all_hypervisors()) size_cluster_assert = 5 - self.assertEqual(size_cluster, size_cluster_assert) + self.assertEqual(size_cluster_assert, size_cluster) def test_basic_consolidation_score_hypervisor(self): cluster = self.fake_cluster.generate_scenario_1() @@ -50,20 +50,17 @@ class TestBasicConsolidation(base.BaseTestCase): statistic_aggregation=self.fake_metrics.mock_get_statistics) node_1_score = 0.023333333333333317 - self.assertEqual( - sercon.calculate_score_node( - cluster.get_hypervisor_from_id("Node_1"), - cluster), node_1_score) + self.assertEqual(node_1_score, sercon.calculate_score_node( + cluster.get_hypervisor_from_id("Node_1"), + cluster)) node_2_score = 0.26666666666666666 - self.assertEqual( - sercon.calculate_score_node( - cluster.get_hypervisor_from_id("Node_2"), - cluster), node_2_score) + self.assertEqual(node_2_score, sercon.calculate_score_node( + cluster.get_hypervisor_from_id("Node_2"), + cluster)) node_0_score = 0.023333333333333317 - self.assertEqual( - sercon.calculate_score_node( - cluster.get_hypervisor_from_id("Node_0"), - cluster), node_0_score) + self.assertEqual(node_0_score, sercon.calculate_score_node( + cluster.get_hypervisor_from_id("Node_0"), + cluster)) def test_basic_consolidation_score_vm(self): cluster = self.fake_cluster.generate_scenario_1() @@ -72,21 +69,20 @@ class TestBasicConsolidation(base.BaseTestCase): statistic_aggregation=self.fake_metrics.mock_get_statistics) vm_0 = cluster.get_vm_from_id("VM_0") vm_0_score = 0.023333333333333317 - self.assertEqual(sercon.calculate_score_vm(vm_0, cluster), vm_0_score) + self.assertEqual(vm_0_score, sercon.calculate_score_vm(vm_0, cluster)) vm_1 = cluster.get_vm_from_id("VM_1") vm_1_score = 0.023333333333333317 - self.assertEqual(sercon.calculate_score_vm(vm_1, cluster), - vm_1_score) + self.assertEqual(vm_1_score, sercon.calculate_score_vm(vm_1, cluster)) vm_2 = cluster.get_vm_from_id("VM_2") vm_2_score = 0.033333333333333326 - self.assertEqual(sercon.calculate_score_vm(vm_2, cluster), vm_2_score) + self.assertEqual(vm_2_score, sercon.calculate_score_vm(vm_2, cluster)) vm_6 = cluster.get_vm_from_id("VM_6") vm_6_score = 0.02666666666666669 - self.assertEqual(sercon.calculate_score_vm(vm_6, cluster), vm_6_score) + self.assertEqual(vm_6_score, sercon.calculate_score_vm(vm_6, cluster)) vm_7 = cluster.get_vm_from_id("VM_7") vm_7_score = 0.013333333333333345 - self.assertEqual(sercon.calculate_score_vm(vm_7, cluster), vm_7_score) + self.assertEqual(vm_7_score, sercon.calculate_score_vm(vm_7, cluster)) def test_basic_consolidation_score_vm_disk(self): cluster = self.fake_cluster.generate_scenario_5_with_vm_disk_0() @@ -95,7 +91,7 @@ class TestBasicConsolidation(base.BaseTestCase): statistic_aggregation=self.fake_metrics.mock_get_statistics) vm_0 = cluster.get_vm_from_id("VM_0") vm_0_score = 0.023333333333333355 - self.assertEqual(sercon.calculate_score_vm(vm_0, cluster), vm_0_score) + self.assertEqual(vm_0_score, sercon.calculate_score_vm(vm_0, cluster)) def test_basic_consolidation_weight(self): cluster = self.fake_cluster.generate_scenario_1() @@ -109,9 +105,9 @@ class TestBasicConsolidation(base.BaseTestCase): # mem 8 Go mem = 8 vm_0_weight_assert = 3.1999999999999997 - self.assertEqual(sercon.calculate_weight(cluster, vm_0, cores, disk, - mem), - vm_0_weight_assert) + self.assertEqual(vm_0_weight_assert, + sercon.calculate_weight(cluster, vm_0, cores, disk, + mem)) def test_calculate_migration_efficacy(self): sercon = strategies.BasicConsolidation() @@ -162,7 +158,7 @@ class TestBasicConsolidation(base.BaseTestCase): threshold_cores = sercon.get_threshold_cores() sercon.set_threshold_cores(threshold_cores + 1) - self.assertEqual(sercon.get_threshold_cores(), threshold_cores + 1) + self.assertEqual(threshold_cores + 1, sercon.get_threshold_cores()) def test_number_of(self): sercon = strategies.BasicConsolidation() @@ -186,8 +182,8 @@ class TestBasicConsolidation(base.BaseTestCase): num_migrations = actions_counter.get("migrate", 0) num_hypervisor_state_change = actions_counter.get( "change_hypervisor_state", 0) - self.assertEqual(num_migrations, expected_num_migrations) - self.assertEqual(num_hypervisor_state_change, expected_power_state) + self.assertEqual(expected_num_migrations, num_migrations) + self.assertEqual(expected_power_state, num_hypervisor_state_change) # calculate_weight def test_execute_no_workload(self): @@ -204,7 +200,7 @@ class TestBasicConsolidation(base.BaseTestCase): as mock_score_call: mock_score_call.return_value = 0 solution = sercon.execute(model) - self.assertEqual(solution.efficacy, 100) + self.assertEqual(100, solution.efficacy) def test_check_parameters(self): sercon = strategies.BasicConsolidation() diff --git a/watcher/tests/decision_engine/strategy/strategies/test_outlet_temp_control.py b/watcher/tests/decision_engine/strategy/strategies/test_outlet_temp_control.py index 71e9cbd56..9578f1c52 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_outlet_temp_control.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_outlet_temp_control.py @@ -51,7 +51,7 @@ class TestOutletTempControl(base.BaseTestCase): cap_mem, cap_disk) - self.assertEqual((cores_used, mem_used, disk_used), (10, 2, 20)) + self.assertEqual((10, 2, 20), (cores_used, mem_used, disk_used)) def test_group_hosts_by_outlet_temp(self): model = self.fake_cluster.generate_scenario_3_with_2_hypervisors() @@ -59,8 +59,8 @@ class TestOutletTempControl(base.BaseTestCase): strategy.ceilometer = mock.MagicMock( statistic_aggregation=self.fake_metrics.mock_get_statistics) h1, h2 = strategy.group_hosts_by_outlet_temp(model) - self.assertEqual(h1[0]['hv'].uuid, 'Node_1') - self.assertEqual(h2[0]['hv'].uuid, 'Node_0') + self.assertEqual('Node_1', h1[0]['hv'].uuid) + self.assertEqual('Node_0', h2[0]['hv'].uuid) def test_choose_vm_to_migrate(self): model = self.fake_cluster.generate_scenario_3_with_2_hypervisors() @@ -69,9 +69,9 @@ class TestOutletTempControl(base.BaseTestCase): statistic_aggregation=self.fake_metrics.mock_get_statistics) h1, h2 = strategy.group_hosts_by_outlet_temp(model) vm_to_mig = strategy.choose_vm_to_migrate(model, h1) - self.assertEqual(vm_to_mig[0].uuid, 'Node_1') - self.assertEqual(vm_to_mig[1].uuid, - "a4cab39b-9828-413a-bf88-f76921bf1517") + self.assertEqual('Node_1', vm_to_mig[0].uuid) + self.assertEqual('a4cab39b-9828-413a-bf88-f76921bf1517', + vm_to_mig[1].uuid) def test_filter_dest_servers(self): model = self.fake_cluster.generate_scenario_3_with_2_hypervisors() @@ -81,8 +81,8 @@ class TestOutletTempControl(base.BaseTestCase): h1, h2 = strategy.group_hosts_by_outlet_temp(model) vm_to_mig = strategy.choose_vm_to_migrate(model, h1) dest_hosts = strategy.filter_dest_servers(model, h2, vm_to_mig[1]) - self.assertEqual(len(dest_hosts), 1) - self.assertEqual(dest_hosts[0]['hv'].uuid, 'Node_0') + self.assertEqual(1, len(dest_hosts)) + self.assertEqual('Node_0', dest_hosts[0]['hv'].uuid) def test_exception_model(self): strategy = strategies.OutletTempControl() @@ -111,7 +111,7 @@ class TestOutletTempControl(base.BaseTestCase): generate_scenario_4_with_1_hypervisor_no_vm() solution = strategy.execute(model) - self.assertEqual(solution.actions, []) + self.assertEqual([], solution.actions) def test_execute(self): strategy = strategies.OutletTempControl() @@ -123,7 +123,7 @@ class TestOutletTempControl(base.BaseTestCase): [action.get('action_type') for action in solution.actions]) num_migrations = actions_counter.get("migrate", 0) - self.assertEqual(num_migrations, 1) + self.assertEqual(1, num_migrations) def test_check_parameters(self): outlet = strategies.OutletTempControl() diff --git a/watcher/tests/objects/test_action.py b/watcher/tests/objects/test_action.py index 31ce76fe3..99406b06f 100644 --- a/watcher/tests/objects/test_action.py +++ b/watcher/tests/objects/test_action.py @@ -57,7 +57,7 @@ class TestActionObject(base.DbTestCase): autospec=True) as mock_get_list: mock_get_list.return_value = [self.fake_action] actions = objects.Action.list(self.context) - self.assertEqual(mock_get_list.call_count, 1) + self.assertEqual(1, mock_get_list.call_count) self.assertThat(actions, HasLength(1)) self.assertIsInstance(actions[0], objects.Action) self.assertEqual(self.context, actions[0]._context) diff --git a/watcher/tests/objects/test_action_plan.py b/watcher/tests/objects/test_action_plan.py index 9b615720f..df10880bc 100644 --- a/watcher/tests/objects/test_action_plan.py +++ b/watcher/tests/objects/test_action_plan.py @@ -57,7 +57,7 @@ class TestActionPlanObject(base.DbTestCase): autospec=True) as mock_get_list: mock_get_list.return_value = [self.fake_action_plan] action_plans = objects.ActionPlan.list(self.context) - self.assertEqual(mock_get_list.call_count, 1) + self.assertEqual(1, mock_get_list.call_count) self.assertThat(action_plans, HasLength(1)) self.assertIsInstance(action_plans[0], objects.ActionPlan) self.assertEqual(self.context, action_plans[0]._context) diff --git a/watcher/tests/objects/test_audit.py b/watcher/tests/objects/test_audit.py index 72392539e..64937b54a 100644 --- a/watcher/tests/objects/test_audit.py +++ b/watcher/tests/objects/test_audit.py @@ -57,7 +57,7 @@ class TestAuditObject(base.DbTestCase): autospec=True) as mock_get_list: mock_get_list.return_value = [self.fake_audit] audits = objects.Audit.list(self.context) - self.assertEqual(mock_get_list.call_count, 1) + self.assertEqual(1, mock_get_list.call_count, 1) self.assertThat(audits, HasLength(1)) self.assertIsInstance(audits[0], objects.Audit) self.assertEqual(self.context, audits[0]._context) diff --git a/watcher/tests/objects/test_audit_template.py b/watcher/tests/objects/test_audit_template.py index 5d9b14325..1e378c403 100644 --- a/watcher/tests/objects/test_audit_template.py +++ b/watcher/tests/objects/test_audit_template.py @@ -70,7 +70,7 @@ class TestAuditTemplateObject(base.DbTestCase): autospec=True) as mock_get_list: mock_get_list.return_value = [self.fake_audit_template] audit_templates = objects.AuditTemplate.list(self.context) - self.assertEqual(mock_get_list.call_count, 1) + self.assertEqual(1, mock_get_list.call_count) self.assertThat(audit_templates, HasLength(1)) self.assertIsInstance(audit_templates[0], objects.AuditTemplate) self.assertEqual(self.context, audit_templates[0]._context) diff --git a/watcher/tests/objects/test_objects.py b/watcher/tests/objects/test_objects.py index 51e8a61ed..b88d3772c 100644 --- a/watcher/tests/objects/test_objects.py +++ b/watcher/tests/objects/test_objects.py @@ -118,39 +118,39 @@ class TestUtils(test_base.TestCase): def test_datetime_or_none(self): naive_dt = datetime.datetime.now() dt = timeutils.parse_isotime(timeutils.isotime(naive_dt)) - self.assertEqual(utils.datetime_or_none(dt), dt) - self.assertEqual(utils.datetime_or_none(dt), - naive_dt.replace(tzinfo=iso8601.iso8601.Utc(), - microsecond=0)) + self.assertEqual(dt, utils.datetime_or_none(dt)) + self.assertEqual(naive_dt.replace(tzinfo=iso8601.iso8601.Utc(), + microsecond=0), + utils.datetime_or_none(dt)) self.assertIsNone(utils.datetime_or_none(None)) self.assertRaises(ValueError, utils.datetime_or_none, 'foo') def test_datetime_or_str_or_none(self): dts = timeutils.isotime() dt = timeutils.parse_isotime(dts) - self.assertEqual(utils.datetime_or_str_or_none(dt), dt) + self.assertEqual(dt, utils.datetime_or_str_or_none(dt)) self.assertIsNone(utils.datetime_or_str_or_none(None)) - self.assertEqual(utils.datetime_or_str_or_none(dts), dt) + self.assertEqual(dt, utils.datetime_or_str_or_none(dts)) self.assertRaises(ValueError, utils.datetime_or_str_or_none, 'foo') def test_int_or_none(self): - self.assertEqual(utils.int_or_none(1), 1) - self.assertEqual(utils.int_or_none('1'), 1) + self.assertEqual(1, utils.int_or_none(1)) + self.assertEqual(1, utils.int_or_none('1')) self.assertIsNone(utils.int_or_none(None)) self.assertRaises(ValueError, utils.int_or_none, 'foo') def test_str_or_none(self): class Obj(object): pass - self.assertEqual(utils.str_or_none('foo'), 'foo') - self.assertEqual(utils.str_or_none(1), '1') + self.assertEqual('foo', utils.str_or_none('foo')) + self.assertEqual('1', utils.str_or_none(1)) self.assertIsNone(utils.str_or_none(None)) def test_ip_or_none(self): ip4 = netaddr.IPAddress('1.2.3.4', 4) ip6 = netaddr.IPAddress('1::2', 6) - self.assertEqual(utils.ip_or_none(4)('1.2.3.4'), ip4) - self.assertEqual(utils.ip_or_none(6)('1::2'), ip6) + self.assertEqual(ip4, utils.ip_or_none(4)('1.2.3.4')) + self.assertEqual(ip6, utils.ip_or_none(6)('1::2')) self.assertIsNone(utils.ip_or_none(4)(None)) self.assertIsNone(utils.ip_or_none(6)(None)) self.assertRaises(netaddr.AddrFormatError, utils.ip_or_none(4), 'foo') @@ -170,7 +170,7 @@ class TestUtils(test_base.TestCase): def test_dt_deserializer(self): dt = timeutils.parse_isotime('1955-11-05T00:00:00Z') - self.assertEqual(utils.dt_deserializer(timeutils.isotime(dt)), dt) + self.assertEqual(dt, utils.dt_deserializer(timeutils.isotime(dt))) self.assertIsNone(utils.dt_deserializer(None)) self.assertRaises(ValueError, utils.dt_deserializer, 'foo') diff --git a/watcher_tempest_plugin/tests/api/admin/test_action.py b/watcher_tempest_plugin/tests/api/admin/test_action.py index 0056b5fae..36e07cc71 100644 --- a/watcher_tempest_plugin/tests/api/admin/test_action.py +++ b/watcher_tempest_plugin/tests/api/admin/test_action.py @@ -47,9 +47,10 @@ class TestShowListAction(base.BaseInfraOptimTest): _, action = self.client.show_action( self.action_plan["first_action_uuid"]) - self.assertEqual(action['uuid'], self.action_plan["first_action_uuid"]) - self.assertEqual(action['action_type'], "nop") - self.assertEqual(action['state'], "PENDING") + self.assertEqual(self.action_plan["first_action_uuid"], + action['uuid']) + self.assertEqual("nop", action['action_type']) + self.assertEqual("PENDING", action['state']) @test.attr(type='smoke') def test_show_action_with_links(self): @@ -81,9 +82,9 @@ class TestShowListAction(base.BaseInfraOptimTest): act['action_type'] for act in body['actions']) # A dummy strategy generates 2 "nop" actions and 1 "sleep" action - self.assertEqual(len(body['actions']), 3) - self.assertEqual(action_counter.get("nop"), 2) - self.assertEqual(action_counter.get("sleep"), 1) + self.assertEqual(3, len(body['actions'])) + self.assertEqual(2, action_counter.get("nop")) + self.assertEqual(1, action_counter.get("sleep")) @test.attr(type="smoke") def test_list_actions_by_audit(self): @@ -97,6 +98,6 @@ class TestShowListAction(base.BaseInfraOptimTest): act['action_type'] for act in body['actions']) # A dummy strategy generates 2 "nop" actions and 1 "sleep" action - self.assertEqual(len(body['actions']), 3) - self.assertEqual(action_counter.get("nop"), 2) - self.assertEqual(action_counter.get("sleep"), 1) + self.assertEqual(3, len(body['actions'])) + self.assertEqual(2, action_counter.get("nop")) + self.assertEqual(1, action_counter.get("sleep")) diff --git a/watcher_tempest_plugin/tests/api/admin/test_action_plan.py b/watcher_tempest_plugin/tests/api/admin/test_action_plan.py index 7ff7adc8d..44846c89a 100644 --- a/watcher_tempest_plugin/tests/api/admin/test_action_plan.py +++ b/watcher_tempest_plugin/tests/api/admin/test_action_plan.py @@ -43,8 +43,8 @@ class TestCreateDeleteExecuteActionPlan(base.BaseInfraOptimTest): _, action_plan = self.client.show_action_plan(action_plan['uuid']) - self.assertEqual(action_plan['audit_uuid'], audit['uuid']) - self.assertEqual(action_plan['state'], 'RECOMMENDED') + self.assertEqual(audit['uuid'], action_plan['audit_uuid']) + self.assertEqual('RECOMMENDED', action_plan['state']) @test.attr(type='smoke') def test_delete_action_plan(self): @@ -98,7 +98,7 @@ class TestCreateDeleteExecuteActionPlan(base.BaseInfraOptimTest): _, finished_ap = self.client.show_action_plan(action_plan['uuid']) self.assertIn(updated_ap['state'], ('PENDING', 'ONGOING')) - self.assertEqual(finished_ap['state'], 'SUCCEEDED') + self.assertEqual('SUCCEEDED', finished_ap['state']) class TestShowListActionPlan(base.BaseInfraOptimTest): @@ -164,5 +164,5 @@ class TestShowListActionPlan(base.BaseInfraOptimTest): next_marker = body['action_plans'][-1]['uuid'] - self.assertEqual(len(body['action_plans']), 3) + self.assertEqual(3, len(body['action_plans'])) self.assertIn(next_marker, body['next']) diff --git a/watcher_tempest_plugin/tests/api/admin/test_api_discovery.py b/watcher_tempest_plugin/tests/api/admin/test_api_discovery.py index fceacda9c..58051c8aa 100644 --- a/watcher_tempest_plugin/tests/api/admin/test_api_discovery.py +++ b/watcher_tempest_plugin/tests/api/admin/test_api_discovery.py @@ -35,7 +35,7 @@ class TestApiDiscovery(base.BaseInfraOptimTest): def test_default_version(self): _, descr = self.client.get_api_description() default_version = descr['default_version'] - self.assertEqual(default_version['id'], 'v1') + self.assertEqual('v1', default_version['id']) @test.attr(type='smoke') def test_version_1_resources(self): diff --git a/watcher_tempest_plugin/tests/api/admin/test_audit.py b/watcher_tempest_plugin/tests/api/admin/test_audit.py index b4d2c4ddc..6292e2ced 100644 --- a/watcher_tempest_plugin/tests/api/admin/test_audit.py +++ b/watcher_tempest_plugin/tests/api/admin/test_audit.py @@ -101,7 +101,7 @@ class TestCreateUpdateDeleteAudit(base.BaseInfraOptimTest): _, audit = self.client.show_audit(body['uuid']) initial_audit_state = audit.pop('state') - self.assertEqual(initial_audit_state, 'PENDING') + self.assertEqual('PENDING', initial_audit_state) self.assert_expected(audit, body) @@ -176,7 +176,7 @@ class TestShowListAudit(base.BaseInfraOptimTest): _, body = self.client.list_audits(limit=3) next_marker = body['audits'][-1]['uuid'] - self.assertEqual(len(body['audits']), 3) + self.assertEqual(3, len(body['audits'])) self.assertIn(next_marker, body['next']) @test.attr(type='smoke') diff --git a/watcher_tempest_plugin/tests/api/admin/test_audit_template.py b/watcher_tempest_plugin/tests/api/admin/test_audit_template.py index 9a4911049..f6995c770 100644 --- a/watcher_tempest_plugin/tests/api/admin/test_audit_template.py +++ b/watcher_tempest_plugin/tests/api/admin/test_audit_template.py @@ -121,7 +121,7 @@ class TestAuditTemplate(base.BaseInfraOptimTest): _, body = self.client.list_audit_templates(limit=3) next_marker = body['audit_templates'][-1]['uuid'] - self.assertEqual(len(body['audit_templates']), 3) + self.assertEqual(3, len(body['audit_templates'])) self.assertIn(next_marker, body['next']) @test.attr(type='smoke') diff --git a/watcher_tempest_plugin/tests/api/admin/test_goal.py b/watcher_tempest_plugin/tests/api/admin/test_goal.py index 913566e62..c3e734d23 100644 --- a/watcher_tempest_plugin/tests/api/admin/test_goal.py +++ b/watcher_tempest_plugin/tests/api/admin/test_goal.py @@ -39,8 +39,8 @@ class TestShowListGoal(base.BaseInfraOptimTest): def test_show_goal(self): _, goal = self.client.show_goal(self.DUMMY_GOAL) - self.assertEqual(goal['name'], self.DUMMY_GOAL) - self.assertEqual(goal['strategy'], "dummy") + self.assertEqual(self.DUMMY_GOAL, goal['name']) + self.assertEqual("dummy", goal['strategy']) @test.attr(type='smoke') def test_show_goal_with_links(self): diff --git a/watcher_tempest_plugin/tests/scenario/test_execute_basic_optim.py b/watcher_tempest_plugin/tests/scenario/test_execute_basic_optim.py index 92bc0e5ac..1f20a864d 100644 --- a/watcher_tempest_plugin/tests/scenario/test_execute_basic_optim.py +++ b/watcher_tempest_plugin/tests/scenario/test_execute_basic_optim.py @@ -140,7 +140,7 @@ class TestExecuteBasicStrategy(base.BaseInfraOptimScenarioTest): action_plan_uuid=finished_ap["uuid"]) self.assertIn(updated_ap['state'], ('PENDING', 'ONGOING')) - self.assertEqual(finished_ap['state'], 'SUCCEEDED') + self.assertEqual('SUCCEEDED', finished_ap['state']) for action in action_list['actions']: - self.assertEqual(action.get('state'), 'SUCCEEDED') + self.assertEqual('SUCCEEDED', action.get('state')) diff --git a/watcher_tempest_plugin/tests/scenario/test_execute_dummy_optim.py b/watcher_tempest_plugin/tests/scenario/test_execute_dummy_optim.py index df7d4eeee..1db2a520c 100644 --- a/watcher_tempest_plugin/tests/scenario/test_execute_dummy_optim.py +++ b/watcher_tempest_plugin/tests/scenario/test_execute_dummy_optim.py @@ -71,9 +71,9 @@ class TestExecuteDummyStrategy(base.BaseInfraOptimScenarioTest): act['action_type'] for act in action_list['actions']) self.assertIn(updated_ap['state'], ('PENDING', 'ONGOING')) - self.assertEqual(finished_ap['state'], 'SUCCEEDED') + self.assertEqual('SUCCEEDED', finished_ap['state']) # A dummy strategy generates 2 "nop" actions and 1 "sleep" action - self.assertEqual(len(action_list['actions']), 3) - self.assertEqual(action_counter.get("nop"), 2) - self.assertEqual(action_counter.get("sleep"), 1) + self.assertEqual(3, len(action_list['actions'])) + self.assertEqual(2, action_counter.get("nop")) + self.assertEqual(1, action_counter.get("sleep"))