tests: Convert remaining mox tests to mock (pt. 2.3)
More flattening. Change-Id: I18a2714104de7655c46302070a78511b563b8678 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
3422bed83f
commit
2a59abc74e
|
@ -65,14 +65,6 @@ class OpenStackAuthTestsMixin(object):
|
||||||
|
|
||||||
class OpenStackAuthFederatedTestsMixin(object):
|
class OpenStackAuthFederatedTestsMixin(object):
|
||||||
"""Common functions for federation"""
|
"""Common functions for federation"""
|
||||||
def _mock_unscoped_federated_list_projects(self, client, projects):
|
|
||||||
client.federation = self.mox.CreateMockAnything()
|
|
||||||
client.federation.projects = self.mox.CreateMockAnything()
|
|
||||||
client.federation.projects.list().AndReturn(projects)
|
|
||||||
|
|
||||||
def _mock_unscoped_list_domains(self, client, domains):
|
|
||||||
client.auth = self.mox.CreateMockAnything()
|
|
||||||
client.auth.domains().AndReturn(domains)
|
|
||||||
|
|
||||||
def _mock_unscoped_token_client(self, unscoped, auth_url=None,
|
def _mock_unscoped_token_client(self, unscoped, auth_url=None,
|
||||||
client=True, plugin=None):
|
client=True, plugin=None):
|
||||||
|
@ -103,11 +95,20 @@ class OpenStackAuthFederatedTestsMixin(object):
|
||||||
|
|
||||||
def _mock_federated_client_list_projects(self, unscoped_auth, projects):
|
def _mock_federated_client_list_projects(self, unscoped_auth, projects):
|
||||||
client = self._mock_unscoped_token_client(None, plugin=unscoped_auth)
|
client = self._mock_unscoped_token_client(None, plugin=unscoped_auth)
|
||||||
self._mock_unscoped_federated_list_projects(client, projects)
|
|
||||||
|
# _mock_unscoped_federated_list_projects
|
||||||
|
|
||||||
|
client.federation = self.mox.CreateMockAnything()
|
||||||
|
client.federation.projects = self.mox.CreateMockAnything()
|
||||||
|
client.federation.projects.list().AndReturn(projects)
|
||||||
|
|
||||||
def _mock_federated_client_list_domains(self, unscoped_auth, domains):
|
def _mock_federated_client_list_domains(self, unscoped_auth, domains):
|
||||||
client = self._mock_unscoped_token_client(None, plugin=unscoped_auth)
|
client = self._mock_unscoped_token_client(None, plugin=unscoped_auth)
|
||||||
self._mock_unscoped_list_domains(client, domains)
|
|
||||||
|
# _mock_unscoped_list_domains
|
||||||
|
|
||||||
|
client.auth = self.mox.CreateMockAnything()
|
||||||
|
client.auth.domains().AndReturn(domains)
|
||||||
|
|
||||||
|
|
||||||
class OpenStackAuthTestsV3(OpenStackAuthTestsMixin,
|
class OpenStackAuthTestsV3(OpenStackAuthTestsMixin,
|
||||||
|
@ -376,10 +377,20 @@ class OpenStackAuthTestsV3(OpenStackAuthTestsMixin,
|
||||||
auth_url=plugin.auth_url)
|
auth_url=plugin.auth_url)
|
||||||
client = self._mock_unscoped_token_client(None, plugin.auth_url,
|
client = self._mock_unscoped_token_client(None, plugin.auth_url,
|
||||||
plugin=sp_unscoped_auth)
|
plugin=sp_unscoped_auth)
|
||||||
self._mock_unscoped_list_domains(client, domains)
|
|
||||||
|
# _mock_unscoped_list_domains
|
||||||
|
|
||||||
|
client.auth = self.mox.CreateMockAnything()
|
||||||
|
client.auth.domains().AndReturn(domains)
|
||||||
|
|
||||||
client = self._mock_unscoped_token_client(None, plugin.auth_url,
|
client = self._mock_unscoped_token_client(None, plugin.auth_url,
|
||||||
plugin=sp_unscoped_auth)
|
plugin=sp_unscoped_auth)
|
||||||
self._mock_unscoped_federated_list_projects(client, sp_projects)
|
|
||||||
|
# _mock_unscoped_federated_list_projects
|
||||||
|
|
||||||
|
client.federation = self.mox.CreateMockAnything()
|
||||||
|
client.federation.projects = self.mox.CreateMockAnything()
|
||||||
|
client.federation.projects.list().AndReturn(sp_projects)
|
||||||
|
|
||||||
# _mock_scoped_client_for_tenant
|
# _mock_scoped_client_for_tenant
|
||||||
|
|
||||||
|
@ -452,7 +463,12 @@ class OpenStackAuthTestsV3(OpenStackAuthTestsMixin,
|
||||||
unscoped_auth = self._mock_plugin(unscoped)
|
unscoped_auth = self._mock_plugin(unscoped)
|
||||||
client = self._mock_unscoped_token_client(None, auth_url=auth_url,
|
client = self._mock_unscoped_token_client(None, auth_url=auth_url,
|
||||||
plugin=unscoped_auth)
|
plugin=unscoped_auth)
|
||||||
self._mock_unscoped_list_domains(client, domains)
|
|
||||||
|
# _mock_unscoped_list_domains
|
||||||
|
|
||||||
|
client.auth = self.mox.CreateMockAnything()
|
||||||
|
client.auth.domains().AndReturn(domains)
|
||||||
|
|
||||||
client = self._mock_unscoped_token_client(None, auth_url=auth_url,
|
client = self._mock_unscoped_token_client(None, auth_url=auth_url,
|
||||||
plugin=unscoped_auth)
|
plugin=unscoped_auth)
|
||||||
self._mock_unscoped_list_projects(client, user, projects)
|
self._mock_unscoped_list_projects(client, user, projects)
|
||||||
|
|
Loading…
Reference in New Issue