diff --git a/test/functional/swift_test_client.py b/test/functional/swift_test_client.py index 3b68d3a441..b0e5f7150c 100644 --- a/test/functional/swift_test_client.py +++ b/test/functional/swift_test_client.py @@ -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