Add mock manilaclient to APITestCase class

Change-Id: Iab9ad61bd73aecc7ee973328449442eb11ed84f0
This commit is contained in:
Igor Malinovskiy 2015-06-17 15:18:56 +03:00
parent 6c2c2769d6
commit 915cdc554c

View File

@ -14,7 +14,9 @@
import os
from django.utils import unittest
import mock
from manila_ui import api
from manila_ui.test.test_data import utils
from openstack_dashboard.test import helpers
@ -40,4 +42,15 @@ class BaseAdminViewTests(ManilaTestsMixin, helpers.BaseAdminViewTests):
class APITestCase(ManilaTestsMixin, helpers.APITestCase):
pass
def setUp(self):
super(APITestCase, self).setUp()
self._original_manilaclient = api.manila.manilaclient
api.manila.manilaclient = lambda request: self.stub_manilaclient()
def stub_manilaclient(self):
# NOTE(u_glide): Create empty mock if test case doesn't have
# predefined manilaclient
if not hasattr(self, "manilaclient"):
self.manilaclient = mock.Mock()
return self.manilaclient