Set int type on several container headers

Several header values for counts and sizes were returning strings.
They are now created with type=int in their respective resource.header.

Change-Id: Ie84343381da6772491a245ae69a07be4477ff3f7
This commit is contained in:
Brian Curtin
2015-03-05 13:42:01 -06:00
parent 69e0db4c9f
commit e1138f08ae
2 changed files with 11 additions and 10 deletions

View File

@@ -31,11 +31,12 @@ class Container(resource.Resource):
# Account data (when id=None)
#: The total number of bytes that are stored in Object Storage for
#: the account.
account_bytes_used = resource.header("x-account-bytes-used")
account_bytes_used = resource.header("x-account-bytes-used", type=int)
#: The number of containers.
account_container_count = resource.header("x-account-container-count")
account_container_count = resource.header("x-account-container-count",
type=int)
#: The number of objects in the account.
account_object_count = resource.header("x-account-object-count")
account_object_count = resource.header("x-account-object-count", type=int)
#: The secret key value for temporary URLs. If not set,
#: this header is not returned by this operation.
meta_temp_url_key = resource.header("x-account-meta-temp-url-key")
@@ -54,9 +55,9 @@ class Container(resource.Resource):
# Container metadata (when id=name)
#: The number of objects.
object_count = resource.header("x-container-object-count")
object_count = resource.header("x-container-object-count", type=int)
#: The count of bytes used in total.
bytes_used = resource.header("x-container-bytes-used")
bytes_used = resource.header("x-container-bytes-used", type=int)
# Request headers (when id=None)
#: If set to True, Object Storage queries all replicas to return the

View File

@@ -69,11 +69,11 @@ class TestAccount(testtools.TestCase):
def test_make_it(self):
sot = container.Container.new(**{'headers': ACCOUNT_EXAMPLE})
self.assertIsNone(sot.id)
self.assertEqual(ACCOUNT_EXAMPLE['x-account-bytes-used'],
self.assertEqual(int(ACCOUNT_EXAMPLE['x-account-bytes-used']),
sot.account_bytes_used)
self.assertEqual(ACCOUNT_EXAMPLE['x-account-container-count'],
self.assertEqual(int(ACCOUNT_EXAMPLE['x-account-container-count']),
sot.account_container_count)
self.assertEqual(ACCOUNT_EXAMPLE['x-account-object-count'],
self.assertEqual(int(ACCOUNT_EXAMPLE['x-account-object-count']),
sot.account_object_count)
@@ -123,9 +123,9 @@ class TestContainer(testtools.TestCase):
self.assertEqual(CONT_EXAMPLE['bytes'], sot.bytes)
# Attributes from header
self.assertEqual(HEAD_EXAMPLE['x-container-object-count'],
self.assertEqual(int(HEAD_EXAMPLE['x-container-object-count']),
sot.object_count)
self.assertEqual(HEAD_EXAMPLE['x-container-bytes-used'],
self.assertEqual(int(HEAD_EXAMPLE['x-container-bytes-used']),
sot.bytes_used)
self.assertEqual(HEAD_EXAMPLE['x-container-read'],
sot.read_ACL)