swiftclient Connection : default optional arguments to None
Default the authurl/user/key constructor arguments for the Connection class to None, as these are not required in the preauthurl/preauthtoken case Change-Id: I445a5d365212c365ecc691c0a670a226e2b7954a
This commit is contained in:
parent
2be776c2e5
commit
656b80bef3
@ -921,9 +921,10 @@ def delete_object(url, token=None, container=None, name=None, http_conn=None,
|
||||
class Connection(object):
|
||||
"""Convenience class to make requests that will also retry the request"""
|
||||
|
||||
def __init__(self, authurl, user, key, retries=5, preauthurl=None,
|
||||
preauthtoken=None, snet=False, starting_backoff=1,
|
||||
tenant_name=None, os_options=None, auth_version="1"):
|
||||
def __init__(self, authurl=None, user=None, key=None, retries=5,
|
||||
preauthurl=None, preauthtoken=None, snet=False,
|
||||
starting_backoff=1, tenant_name=None, os_options=None,
|
||||
auth_version="1"):
|
||||
"""
|
||||
:param authurl: authentication URL
|
||||
:param user: user name to authenticate as
|
||||
@ -931,7 +932,8 @@ class Connection(object):
|
||||
:param retries: Number of times to retry the request before failing
|
||||
:param preauthurl: storage URL (if you have already authenticated)
|
||||
:param preauthtoken: authentication token (if you have already
|
||||
authenticated)
|
||||
authenticated) note authurl/user/key/tenant_name
|
||||
are not required when specifying preauthtoken
|
||||
:param snet: use SERVICENET internal network default is False
|
||||
:param auth_version: OpenStack auth version, default is 1.0
|
||||
:param tenant_name: The tenant/account name, required when connecting
|
||||
|
@ -407,6 +407,20 @@ class TestConnection(MockHttpTest):
|
||||
conn = c.Connection('http://www.test.com', 'asdf', 'asdf')
|
||||
self.assertEquals(conn.retries, 5)
|
||||
|
||||
def test_instance_kwargs(self):
|
||||
args = {'user': 'ausername',
|
||||
'key': 'secretpass',
|
||||
'authurl': 'http://www.test.com',
|
||||
'tenant_name': 'atenant'}
|
||||
conn = c.Connection(**args)
|
||||
self.assertEquals(type(conn), c.Connection)
|
||||
|
||||
def test_instance_kwargs_token(self):
|
||||
args = {'preauthtoken': 'atoken123',
|
||||
'preauthurl': 'http://www.test.com:8080/v1/AUTH_123456'}
|
||||
conn = c.Connection(**args)
|
||||
self.assertEquals(type(conn), c.Connection)
|
||||
|
||||
def test_retry(self):
|
||||
c.http_connection = self.fake_http_connection(500)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user