[verify] Fix `rally verify rerun`

CLI layer transmits the wrong arguments to API. This patch fixes transmission
of "conccurency" and "deployment_id". To avoid such issues in future, proper
mocks is used.

Note:
	several tests became crazy after switching to `mock.create_autospec`.
	Switching from assert_has_calls to call_args_list fixes an issue.
Conflicts:
	rally/cli/commands/verify.py
	tests/unit/cli/commands/test_verify.py

Change-Id: Idf41e13d873ca3058fdff17b30225096ab7a8c89
(cherry picked from commit 51458420a9)
This commit is contained in:
Andrey Kurilin 2017-03-24 19:26:57 +02:00
parent 00d07efdd0
commit 93701bab17
4 changed files with 20 additions and 18 deletions

View File

@ -536,11 +536,9 @@ class VerifyCommands(object):
def rerun(self, api, verification_uuid=None, deployment=None, tags=None,
concur=None, failed=False, detailed=False, do_use=True):
"""Rerun tests from a verification for a specific deployment."""
verification, results = api.verification.rerun(verification_uuid,
deployment=deployment,
failed=failed,
tags=tags,
concur=concur)
verification, results = api.verification.rerun(
verification_uuid, deployment_id=deployment, failed=failed,
tags=tags, concurrency=concur)
if detailed:
self._print_details_after_run(results)

View File

@ -109,6 +109,8 @@ class TaskCommandsTestCase(test.TestCase):
mock_open.side_effect = [
mock.mock_open(read_data="{'test': {}").return_value
]
self.fake_api.task.render_template.return_value = "||"
self.assertRaises(task.FailedToLoadTask,
self.task._load_task, self.fake_api, "in_task")

View File

@ -79,8 +79,8 @@ class VerifyCommandsTestCase(test.TestCase):
self.verify.list_verifiers(self.fake_api, "foo")
self.verify.list_verifiers(self.fake_api)
self.fake_api.verifier.list.assert_has_calls([mock.call(None),
mock.call("foo")])
self.assertEqual([mock.call(None), mock.call("foo"), mock.call(None)],
self.fake_api.verifier.list.call_args_list)
@mock.patch("rally.cli.commands.verify.envutils.get_global")
def test_show_verifier(self, mock_get_global):
@ -225,8 +225,9 @@ class VerifyCommandsTestCase(test.TestCase):
self.fake_api.verifier.list_extensions.return_value = []
self.verify.list_verifier_exts(self.fake_api, "v_id")
self.fake_api.verifier.list_extensions.assert_has_calls(
[mock.call("v_id"), mock.call("v_id")])
self.assertEqual(
[mock.call("v_id"), mock.call("v_id")],
self.fake_api.verifier.list_extensions.call_args_list)
def test_delete_verifier_ext(self):
self.verify.delete_verifier_ext(self.fake_api, "v_id", "ext_name")
@ -361,7 +362,8 @@ class VerifyCommandsTestCase(test.TestCase):
self.verify.rerun(self.fake_api, "v_uuid", "d_id", failed=True,)
self.fake_api.verification.rerun.assert_called_once_with(
"v_uuid", deployment="d_id", failed=True, tags=None, concur=None)
"v_uuid", concurrency=None,
deployment_id="d_id", failed=True, tags=None)
def test_show(self):
deployment_name = "Some Deploy"
@ -485,10 +487,10 @@ class VerifyCommandsTestCase(test.TestCase):
self.verify.list(self.fake_api, "v_id", "d_id", "foo", "bar")
self.verify.list(self.fake_api)
self.fake_api.verification.list.assert_has_calls(
[mock.call("v_id", "d_id", None, None),
mock.call("v_id", "d_id", "foo", "bar"),
mock.call(None, None, None, None)])
self.assertEqual([mock.call("v_id", "d_id", None, None),
mock.call("v_id", "d_id", "foo", "bar"),
mock.call(None, None, None, None)],
self.fake_api.verification.list.call_args_list)
def test_delete(self):
self.verify.delete(self.fake_api, "v_uuid")

View File

@ -1858,10 +1858,10 @@ class FakeTask(dict):
class FakeAPI(object):
def __init__(self):
self._deployment = mock.Mock(spec=api._Deployment)
self._task = mock.Mock(spec=api._Task)
self._verifier = mock.Mock(spec=api._Verifier)
self._verification = mock.Mock(spec=api._Verification)
self._deployment = mock.create_autospec(api._Deployment)
self._task = mock.create_autospec(api._Task)
self._verifier = mock.create_autospec(api._Verifier)
self._verification = mock.create_autospec(api._Verification)
@property
def deployment(self):