summaryrefslogtreecommitdiff
path: root/tests/unit/test_swiftclient.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/test_swiftclient.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/test_swiftclient.py')
-rw-r--r--tests/unit/test_swiftclient.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/unit/test_swiftclient.py b/tests/unit/test_swiftclient.py
index 397ecaf..801abc6 100644
--- a/tests/unit/test_swiftclient.py
+++ b/tests/unit/test_swiftclient.py
@@ -30,7 +30,8 @@ from hashlib import md5
from six.moves.urllib.parse import urlparse
from six.moves import reload_module
-from .utils import MockHttpTest, fake_get_auth_keystone, StubResponse
+from .utils import (MockHttpTest, fake_get_auth_keystone, StubResponse,
+ FakeKeystone, _make_fake_import_keystone_client)
from swiftclient.utils import EMPTY_ETAG
from swiftclient import client as c
@@ -1443,6 +1444,7 @@ class TestConnection(MockHttpTest):
conn._request = my_request_handler
return url, conn
+ # v1 auth
conn = c.Connection(
'http://auth.example.com', 'user', 'password', timeout=33.0)
with mock.patch.multiple('swiftclient.client',
@@ -1453,6 +1455,26 @@ class TestConnection(MockHttpTest):
# 1 call is through get_auth, 1 call is HEAD for account
self.assertEqual(timeouts, [33.0, 33.0])
+ # v2 auth
+ timeouts = []
+ conn = c.Connection(
+ 'http://auth.example.com', 'user', 'password', timeout=33.0,
+ os_options=dict(tenant_name='tenant'), auth_version=2.0)
+ fake_ks = FakeKeystone(endpoint='http://some_url', token='secret')
+ with mock.patch('swiftclient.client._import_keystone_client',
+ _make_fake_import_keystone_client(fake_ks)):
+ with mock.patch.multiple('swiftclient.client',
+ http_connection=shim_connection,
+ sleep=mock.DEFAULT):
+ conn.head_account()
+
+ # check timeout is passed to keystone client
+ self.assertEqual(1, len(fake_ks.calls))
+ self.assertTrue('timeout' in fake_ks.calls[0])
+ self.assertEqual(33.0, fake_ks.calls[0].get('timeout'))
+ # check timeout passed to HEAD for account
+ self.assertEqual(timeouts, [33.0])
+
def test_reset_stream(self):
class LocalContents(object):