fix the Bug of test in cron_triggers panel

Change-Id: I788247280aa377d571bfd8fd9d7d40ef9ae5e096
This commit is contained in:
pengyuesheng 2019-06-14 13:49:43 +08:00
parent 13e1709805
commit 20bd211450

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:cron_triggers:index')
@ -22,10 +24,12 @@ INDEX_URL = reverse('horizon:mistral:cron_triggers:index')
class CronTriggersTest(test.TestCase):
@helpers.create_mocks({api: ('cron_trigger_list',)})
def test_index(self):
with mock.patch('mistraldashboard.api.cron_trigger_list',
return_value=self.
mistralclient_cron_triggers.list()):
res = self.client.get(INDEX_URL)
self.mock_cron_trigger_list.return_value =\
self.mistralclient_cron_triggers.list()
res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, 'mistral/cron_triggers/index.html')
self.mock_cron_trigger_list.assert_called_once_with(
helpers.IsHttpRequest())