From 386525516a1e918064e103b4a07fc987898b7abd Mon Sep 17 00:00:00 2001 From: pengyuesheng Date: Fri, 21 Jun 2019 10:14:03 +0800 Subject: [PATCH] Add the unit test for executions detail Change-Id: Ib2d9edd1b554935c4b1171db09065999403dc51f --- mistraldashboard/executions/tests.py | 16 ++++++++++++++++ mistraldashboard/test/test_data/mistral_data.py | 10 ++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/mistraldashboard/executions/tests.py b/mistraldashboard/executions/tests.py index 7557e32..1421c18 100644 --- a/mistraldashboard/executions/tests.py +++ b/mistraldashboard/executions/tests.py @@ -38,3 +38,19 @@ class ExecutionsTest(test.TestCase): marker=None, sort_dirs='desc', paginate=True) + + @helpers.create_mocks({api: ('execution_get', 'task_list')}) + def test_detail(self): + execution = self.mistralclient_executions.list()[0] + tasks = self.mistralclient_tasks.list() + self.mock_execution_get.return_value = execution + self.mock_task_list.return_value = tasks + url = reverse('horizon:mistral:executions:detail', + args=[execution.id]) + res = self.client.get(url) + + self.assertTemplateUsed(res, 'mistral/executions/detail.html') + self.mock_execution_get.assert_called_once_with( + helpers.IsHttpRequest(), execution.id) + self.mock_task_list.assert_called_once_with( + helpers.IsHttpRequest(), execution.id) diff --git a/mistraldashboard/test/test_data/mistral_data.py b/mistraldashboard/test/test_data/mistral_data.py index 12bd3a7..fcf6ca4 100644 --- a/mistraldashboard/test/test_data/mistral_data.py +++ b/mistraldashboard/test/test_data/mistral_data.py @@ -83,12 +83,10 @@ def data(TEST): 'workflow_name': 'my_wf', 'description': '', 'state': 'RUNNING', - 'input': { - 'person': { - 'first_name': 'John', - 'last_name': 'Doe' - } - }} + 'input': '{"person": {"first_name": "John", "last_name": "Doe"}}', + 'output': "1", + 'params': "1", + } ) TEST.mistralclient_executions.add(execution_1)