Merge "fixed internal client things"
This commit is contained in:
commit
8cacf5aaf8
@ -186,6 +186,8 @@ class InternalClient(object):
|
||||
"""
|
||||
|
||||
resp = self.make_request('HEAD', path, {}, acceptable_statuses)
|
||||
if resp.status_int // 100 != 2:
|
||||
return {}
|
||||
metadata_prefix = metadata_prefix.lower()
|
||||
metadata = {}
|
||||
for k, v in resp.headers.iteritems():
|
||||
|
@ -31,9 +31,9 @@ def unicode_string(start, length):
|
||||
|
||||
|
||||
def path_parts():
|
||||
account = unicode_string(1000, 4) + ' ' + unicode_string(1000, 4)
|
||||
container = unicode_string(1000, 4) + ' ' + unicode_string(1000, 4)
|
||||
obj = unicode_string(1000, 4) + ' ' + unicode_string(1000, 4)
|
||||
account = unicode_string(1000, 4) + ' ' + unicode_string(1100, 4)
|
||||
container = unicode_string(2000, 4) + ' ' + unicode_string(2100, 4)
|
||||
obj = unicode_string(3000, 4) + ' ' + unicode_string(3100, 4)
|
||||
return account, container, obj
|
||||
|
||||
|
||||
@ -354,6 +354,7 @@ class TestInternalClient(unittest.TestCase):
|
||||
class Response(object):
|
||||
def __init__(self, headers):
|
||||
self.headers = headers
|
||||
self.status_int = 200
|
||||
|
||||
class InternalClient(internal_client.InternalClient):
|
||||
def __init__(self, test, path, resp_headers):
|
||||
@ -392,6 +393,23 @@ class TestInternalClient(unittest.TestCase):
|
||||
self.assertEquals(exp_metadata, metadata)
|
||||
self.assertEquals(1, client.make_request_called)
|
||||
|
||||
def test_get_metadata_invalid_status(self):
|
||||
class Response(object):
|
||||
def __init__(self):
|
||||
self.status_int = 404
|
||||
self.headers = {'some_key': 'some_value'}
|
||||
|
||||
class InternalClient(internal_client.InternalClient):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def make_request(self, *a, **kw):
|
||||
return Response()
|
||||
|
||||
client = InternalClient()
|
||||
metadata = client._get_metadata('path')
|
||||
self.assertEquals({}, metadata)
|
||||
|
||||
def test_make_path(self):
|
||||
account, container, obj = path_parts()
|
||||
path = make_path(account, container, obj)
|
||||
|
Loading…
x
Reference in New Issue
Block a user