Move the panel mocks to a separate method on TestCase

We need to remove the panel mocks in Tuskar-UI tests, because they
import and register the admin panel as their side effect. To do that
easily, I'm moving that part into a separate method.

Partial-bug: #1384683
Change-Id: Ica366c0b9f680049a74e94007a563ffdb492e4f4
This commit is contained in:
Radomir Dopieralski 2014-10-23 13:23:41 +02:00
parent 8a3bd01b55
commit dece4cc345

View File

@ -151,12 +151,16 @@ class TestCase(horizon_helpers.TestCase):
middleware.HorizonMiddleware().process_request(self.request)
AuthenticationMiddleware().process_request(self.request)
self.patchers = {}
self.add_panel_mocks()
os.environ["HORIZON_TEST_RUN"] = "True"
def add_panel_mocks(self):
"""Global mocks on panels that get called on all views."""
self.patchers['aggregates'] = mock.patch(
'openstack_dashboard.dashboards.admin'
'.aggregates.panel.Aggregates.can_access',
mock.Mock(return_value=True))
self.patchers['aggregates'].start()
os.environ["HORIZON_TEST_RUN"] = "True"
def tearDown(self):
self.mox.UnsetStubs()