summaryrefslogtreecommitdiff
path: root/tests/unit/utils.py
diff options
context:
space:
mode:
authorAlistair Coles <alistair.coles@hp.com>2015-04-28 16:56:44 +0100
committerAlistair Coles <alistair.coles@hp.com>2015-04-28 16:58:23 +0100
commita39e18ff5ac5d8705baef4328ea8433583f8d656 (patch)
tree80d4b5cad255f31dcf8f9fa8a7e0327ffe5d4a22 /tests/unit/utils.py
parente2f41a6635618157c8cd8c3db88ec511490d3876 (diff)
downloadpython-swiftclient-a39e18ff5ac5d8705baef4328ea8433583f8d656.tar.gz
Add test for timeout being passed to keystone client
Extends existing unit test for timeout being passed to get_auth to cover v2.0 auth when keystone client should get the timeout kwarg. Related-Bug: 1447847 Change-Id: Ie9cfc86fa2156b94b45d290ac12e3f71b20d6c4f
Diffstat (limited to 'tests/unit/utils.py')
-rw-r--r--tests/unit/utils.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/unit/utils.py b/tests/unit/utils.py
index 4958c13..de37d86 100644
--- a/tests/unit/utils.py
+++ b/tests/unit/utils.py
@@ -480,3 +480,52 @@ class CaptureOutput(object):
def __getattr__(self, name):
return getattr(self.out, name)
+
+
+class FakeKeystone(object):
+ '''
+ Fake keystone client module. Returns given endpoint url and auth token.
+ '''
+ def __init__(self, endpoint, token):
+ self.calls = []
+ self.auth_version = None
+ self.endpoint = endpoint
+ self.token = token
+
+ class _Client():
+ def __init__(self, endpoint, token, **kwargs):
+ self.auth_token = token
+ self.endpoint = endpoint
+ self.service_catalog = self.ServiceCatalog(endpoint)
+
+ class ServiceCatalog(object):
+ def __init__(self, endpoint):
+ self.calls = []
+ self.endpoint_url = endpoint
+
+ def url_for(self, **kwargs):
+ self.calls.append(kwargs)
+ return self.endpoint_url
+
+ def Client(self, **kwargs):
+ self.calls.append(kwargs)
+ self.client = self._Client(endpoint=self.endpoint, token=self.token,
+ **kwargs)
+ return self.client
+
+ class Unauthorized(Exception):
+ pass
+
+ class AuthorizationFailure(Exception):
+ pass
+
+ class EndpointNotFound(Exception):
+ pass
+
+
+def _make_fake_import_keystone_client(fake_import):
+ def _fake_import_keystone_client(auth_version):
+ fake_import.auth_version = auth_version
+ return fake_import, fake_import
+
+ return _fake_import_keystone_client