From c10f06e2e84644c800a00c1a7ccf456f3ded6f08 Mon Sep 17 00:00:00 2001 From: hardik Date: Fri, 25 Sep 2015 09:51:00 +0530 Subject: [PATCH] Fix order of arguments in assertEqual Some tests used incorrect order assertEqual(observed, expected). The correct order expected by testtools is assertEqual(expected, observed). Change-Id: I72e1d8a6b52fa6dbb85b57438aef92ad13735880 Partial-Bug: #1259292 --- .../tests/functional/cli/v2/cli_tests_v2.py | 26 +++++++++---------- mistralclient/tests/unit/base_shell_test.py | 2 +- mistralclient/tests/unit/test_client.py | 4 +-- mistralclient/tests/unit/test_shell.py | 18 ++++++------- .../tests/unit/v2/test_cli_workbooks.py | 2 +- .../tests/unit/v2/test_cli_workflows.py | 2 +- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/mistralclient/tests/functional/cli/v2/cli_tests_v2.py b/mistralclient/tests/functional/cli/v2/cli_tests_v2.py index 2415d32c..2bd7a62a 100644 --- a/mistralclient/tests/functional/cli/v2/cli_tests_v2.py +++ b/mistralclient/tests/functional/cli/v2/cli_tests_v2.py @@ -343,7 +343,7 @@ class ExecutionCLITests(base_v2.MistralClientTestBase): self.assertEqual(self.direct_wf['Name'], wf) self.assertIsNotNone(created_at) - self.assertEqual(description, "execution test") + self.assertEqual("execution test", description) execs = self.mistral_admin('execution-list') self.assertIn(exec_id, [ex['ID'] for ex in execs]) @@ -385,7 +385,7 @@ class ExecutionCLITests(base_v2.MistralClientTestBase): description = self.get_value_of_field(execution, 'Description') - self.assertEqual(description, "execution update test") + self.assertEqual("execution update test", description) def test_execution_get(self): execution = self.execution_create(self.direct_wf['Name']) @@ -540,14 +540,14 @@ class ActionCLITests(base_v2.MistralClientTestBase): action_2 = self.get_item_info( get_from=init_acts, get_by='Name', value='farewell') - self.assertEqual(action_1['Tags'], '') - self.assertEqual(action_2['Tags'], '') + self.assertEqual('', action_1['Tags']) + self.assertEqual('', action_2['Tags']) - self.assertEqual(action_1['Is system'], 'False') - self.assertEqual(action_2['Is system'], 'False') + self.assertEqual('False', action_1['Is system']) + self.assertEqual('False', action_2['Is system']) - self.assertEqual(action_1['Input'], 'name') - self.assertEqual(action_2['Input'], 'None') + self.assertEqual('name', action_1['Input']) + self.assertEqual('None', action_2['Input']) acts = self.mistral_admin('action-list') self.assertIn(action_1['Name'], [action['Name'] for action in acts]) @@ -584,7 +584,7 @@ class ActionCLITests(base_v2.MistralClientTestBase): updated_action = self.get_item_info( get_from=acts, get_by='Name', value='greeting') - self.assertEqual(updated_action['Tags'], 'tag, tag1') + self.assertEqual('tag, tag1', updated_action['Tags']) self.assertEqual(created_action['Created at'].split(".")[0], updated_action['Created at']) self.assertEqual(created_action['Name'], updated_action['Name']) @@ -635,7 +635,7 @@ class EnvironmentCLITests(base_v2.MistralClientTestBase): env_updated_at = self.get_value_of_field(env, 'Updated at') self.assertIsNotNone(env_created_at) - self.assertEqual(env_updated_at, 'None') + self.assertEqual('None', env_updated_at) self.create_file('env_upd.yaml', 'name: env\n' @@ -653,7 +653,7 @@ class EnvironmentCLITests(base_v2.MistralClientTestBase): self.assertEqual(env_name, updated_env_name) self.assertNotEqual(env_desc, updated_env_desc) - self.assertEqual(updated_env_desc, 'Updated env') + self.assertEqual('Updated env', updated_env_desc) self.assertEqual(env_created_at.split('.')[0], updated_env_created_at) self.assertIsNotNone(updated_env_updated_at) @@ -719,8 +719,8 @@ class ActionExecutionCLITests(base_v2.MistralClientTestBase): act_ex_from_list['ID'], self.get_value_of_field(act_ex, 'ID') ) - self.assertEqual(wf_name, self.direct_wf['Name']) - self.assertEqual(status, 'SUCCESS') + self.assertEqual(self.direct_wf['Name'], wf_name) + self.assertEqual('SUCCESS', status) def test_act_execution_create_delete(self): action_ex = self.mistral_admin( diff --git a/mistralclient/tests/unit/base_shell_test.py b/mistralclient/tests/unit/base_shell_test.py index d45baf65..b7cb2d82 100644 --- a/mistralclient/tests/unit/base_shell_test.py +++ b/mistralclient/tests/unit/base_shell_test.py @@ -35,7 +35,7 @@ class BaseShellTests(testtools.TestCase): _shell.run(argstr.split()) except SystemExit: exc_type, exc_value, exc_traceback = sys.exc_info() - self.assertEqual(exc_value.code, 0) + self.assertEqual(0, exc_value.code) finally: stdout = sys.stdout.getvalue() stderr = sys.stderr.getvalue() diff --git a/mistralclient/tests/unit/test_client.py b/mistralclient/tests/unit/test_client.py index 7bf4aa77..0d8e2166 100644 --- a/mistralclient/tests/unit/test_client.py +++ b/mistralclient/tests/unit/test_client.py @@ -28,5 +28,5 @@ class BaseClientTests(testtools.TestCase): auth_url="http://localhost:35357/v3") self.assertTrue(mock.called) params = mock.call_args - self.assertEqual(params[0][0], - 'http://localhost:8989/v2') + self.assertEqual('http://localhost:8989/v2', + params[0][0]) diff --git a/mistralclient/tests/unit/test_shell.py b/mistralclient/tests/unit/test_shell.py index 7fcbe6b3..661f7acf 100644 --- a/mistralclient/tests/unit/test_shell.py +++ b/mistralclient/tests/unit/test_shell.py @@ -26,7 +26,7 @@ class TestShell(base.BaseShellTests): ) self.assertTrue(mock.called) params = mock.call_args - self.assertEqual(params[1]['mistral_url'], '') + self.assertEqual('', params[1]['mistral_url']) @mock.patch('mistralclient.api.client.client') def test_command_with_mistral_url(self, mock): @@ -35,8 +35,8 @@ class TestShell(base.BaseShellTests): ) self.assertTrue(mock.called) params = mock.call_args - self.assertEqual(params[1]['mistral_url'], - 'http://localhost:8989/v2') + self.assertEqual('http://localhost:8989/v2', + params[1]['mistral_url']) @mock.patch('mistralclient.api.client.determine_client_version') def test_mistral_version(self, mock): @@ -45,39 +45,39 @@ class TestShell(base.BaseShellTests): ) self.assertTrue(mock.called) mistral_version = mock.call_args - self.assertEqual(mistral_version[0][0], 'v1') + self.assertEqual('v1', mistral_version[0][0]) @mock.patch('mistralclient.api.client.determine_client_version') def test_no_mistral_version(self, mock): self.shell('workbook-list') self.assertTrue(mock.called) mistral_version = mock.call_args - self.assertEqual(mistral_version[0][0], 'v2') + self.assertEqual('v2', mistral_version[0][0]) @mock.patch('mistralclient.api.client.client') def test_service_type(self, mock): self.shell('--os-mistral-service-type=test workbook-list') self.assertTrue(mock.called) parmters = mock.call_args - self.assertEqual(parmters[1]['service_type'], 'test') + self.assertEqual('test', parmters[1]['service_type']) @mock.patch('mistralclient.api.client.client') def test_no_service_type(self, mock): self.shell('workbook-list') self.assertTrue(mock.called) params = mock.call_args - self.assertEqual(params[1]['service_type'], 'workflowv2') + self.assertEqual('workflowv2', params[1]['service_type']) @mock.patch('mistralclient.api.client.client') def test_endpoint_type(self, mock): self.shell('--os-mistral-endpoint-type=adminURL workbook-list') self.assertTrue(mock.called) params = mock.call_args - self.assertEqual(params[1]['endpoint_type'], 'adminURL') + self.assertEqual('adminURL', params[1]['endpoint_type']) @mock.patch('mistralclient.api.client.client') def test_no_endpoint_type(self, mock): self.shell('workbook-list') self.assertTrue(mock.called) params = mock.call_args - self.assertEqual(params[1]['endpoint_type'], 'publicURL') + self.assertEqual('publicURL', params[1]['endpoint_type']) diff --git a/mistralclient/tests/unit/v2/test_cli_workbooks.py b/mistralclient/tests/unit/v2/test_cli_workbooks.py index 6234d490..bf8d7ff4 100644 --- a/mistralclient/tests/unit/v2/test_cli_workbooks.py +++ b/mistralclient/tests/unit/v2/test_cli_workbooks.py @@ -116,7 +116,7 @@ class TestCLIWorkbooksV2(base.BaseCommandTest): result = self.call(workbook_cmd.Validate, app_args=['wb.yaml']) - self.assertEqual(result[1], (True, None)) + self.assertEqual((True, None), result[1]) @mock.patch('argparse.open', create=True) @mock.patch('mistralclient.api.v2.workbooks.WorkbookManager.validate') diff --git a/mistralclient/tests/unit/v2/test_cli_workflows.py b/mistralclient/tests/unit/v2/test_cli_workflows.py index 02de23d9..2bfce20f 100644 --- a/mistralclient/tests/unit/v2/test_cli_workflows.py +++ b/mistralclient/tests/unit/v2/test_cli_workflows.py @@ -159,7 +159,7 @@ class TestCLIWorkflowsV2(base.BaseCommandTest): result = self.call(workflow_cmd.Validate, app_args=['wf.yaml']) - self.assertEqual(result[1], (True, None)) + self.assertEqual((True, None), result[1]) @mock.patch('argparse.open', create=True) @mock.patch('mistralclient.api.v2.workflows.WorkflowManager.validate')