From e1138f08aef5aee2ac6f817c1bd57c57a6d6225b Mon Sep 17 00:00:00 2001 From: Brian Curtin Date: Thu, 5 Mar 2015 13:42:01 -0600 Subject: [PATCH] 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 --- openstack/object_store/v1/container.py | 11 ++++++----- openstack/tests/object_store/v1/test_container.py | 10 +++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/openstack/object_store/v1/container.py b/openstack/object_store/v1/container.py index 2d637e2d..bdb3403f 100644 --- a/openstack/object_store/v1/container.py +++ b/openstack/object_store/v1/container.py @@ -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 diff --git a/openstack/tests/object_store/v1/test_container.py b/openstack/tests/object_store/v1/test_container.py index cb4a777d..ff666c94 100644 --- a/openstack/tests/object_store/v1/test_container.py +++ b/openstack/tests/object_store/v1/test_container.py @@ -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)