From 4e62ddd132bb5561e5f6cb8e35223f1bad490d30 Mon Sep 17 00:00:00 2001 From: pengyuesheng Date: Fri, 14 Jun 2019 14:05:33 +0800 Subject: [PATCH] fix the Bug of test in executions panel Change-Id: Ie23519d7223384fea2f80cd319ad4a64b8a5a59b --- mistraldashboard/executions/tests.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/mistraldashboard/executions/tests.py b/mistraldashboard/executions/tests.py index 3cbea17..7557e32 100644 --- a/mistraldashboard/executions/tests.py +++ b/mistraldashboard/executions/tests.py @@ -13,8 +13,10 @@ # under the License. from django.urls import reverse -import mock +from openstack_dashboard.test import helpers + +from mistraldashboard import api from mistraldashboard.test import helpers as test INDEX_URL = reverse('horizon:mistral:executions:index') @@ -22,9 +24,17 @@ INDEX_URL = reverse('horizon:mistral:executions:index') class ExecutionsTest(test.TestCase): + @helpers.create_mocks({api: ('pagination_list',)}) def test_index(self): - with mock.patch('mistraldashboard.api.pagination_list', - return_value=self.mistralclient_executions.list()): - res = self.client.get(INDEX_URL) - + self.mock_pagination_list.return_value =\ + [self.mistralclient_executions.list(), False, False] + res = self.client.get(INDEX_URL) self.assertTemplateUsed(res, 'mistral/executions/index.html') + self.assertItemsEqual(res.context['table'].data, + self.mistralclient_executions.list()) + self.mock_pagination_list.assert_called_once_with( + entity="executions", + request=helpers.IsHttpRequest(), + marker=None, + sort_dirs='desc', + paginate=True)