Merge "functests: Only convert headers that should be ints to be ints"
This commit is contained in:
commit
c9acb0a717
@ -366,26 +366,39 @@ class Base(object):
|
||||
if optional_fields is None:
|
||||
optional_fields = ()
|
||||
|
||||
def is_int_header(header):
|
||||
if header.startswith('x-account-storage-policy-') and \
|
||||
header.endswith(('-bytes-used', '-object-count')):
|
||||
return True
|
||||
return header in (
|
||||
'content-length',
|
||||
'x-account-container-count',
|
||||
'x-account-object-count',
|
||||
'x-account-bytes-used',
|
||||
'x-container-object-count',
|
||||
'x-container-bytes-used',
|
||||
)
|
||||
|
||||
headers = dict(self.conn.response.getheaders())
|
||||
ret = {}
|
||||
|
||||
for field in required_fields:
|
||||
if field[1] not in headers:
|
||||
for return_key, header in required_fields:
|
||||
if header not in headers:
|
||||
raise ValueError("%s was not found in response header" %
|
||||
(field[1]))
|
||||
(header,))
|
||||
|
||||
try:
|
||||
ret[field[0]] = int(headers[field[1]])
|
||||
except ValueError:
|
||||
ret[field[0]] = headers[field[1]]
|
||||
if is_int_header(header):
|
||||
ret[return_key] = int(headers[header])
|
||||
else:
|
||||
ret[return_key] = headers[header]
|
||||
|
||||
for field in optional_fields:
|
||||
if field[1] not in headers:
|
||||
for return_key, header in optional_fields:
|
||||
if header not in headers:
|
||||
continue
|
||||
try:
|
||||
ret[field[0]] = int(headers[field[1]])
|
||||
except ValueError:
|
||||
ret[field[0]] = headers[field[1]]
|
||||
if is_int_header(header):
|
||||
ret[return_key] = int(headers[header])
|
||||
else:
|
||||
ret[return_key] = headers[header]
|
||||
|
||||
return ret
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user