fix the Bug of test in executions panel

Change-Id: Ie23519d7223384fea2f80cd319ad4a64b8a5a59b
This commit is contained in:
pengyuesheng 2019-06-14 14:05:33 +08:00
parent 13e1709805
commit 4e62ddd132

View File

@ -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)