diff --git a/openstack/key_manager/v1/container.py b/openstack/key_manager/v1/container.py index b66f73b07..4d83447fd 100644 --- a/openstack/key_manager/v1/container.py +++ b/openstack/key_manager/v1/container.py @@ -10,6 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. +from openstack import format from openstack.key_manager import key_manager_service from openstack import resource @@ -30,8 +31,9 @@ class Container(resource.Resource): # Properties #: A URI for this container container_ref = resource.prop('container_ref') - #: The timestamp when this container was created - created_at = resource.prop('created') + #: The timestamp when this container was created. + #: *Type: datetime object parsed from ISO 8601 formatted string* + created_at = resource.prop('created', type=format.ISO8601) #: The name of this container name = resource.prop('name') #: A list of references to secrets in this container @@ -40,5 +42,6 @@ class Container(resource.Resource): status = resource.prop('status') #: The type of this container type = resource.prop('type') - #: The timestamp when this container was updated - updated_at = resource.prop('updated') + #: The timestamp when this container was updated. + #: *Type: datetime object parsed from ISO 8601 formatted string* + updated_at = resource.prop('updated', type=format.ISO8601) diff --git a/openstack/key_manager/v1/secret.py b/openstack/key_manager/v1/secret.py index efa32d542..d142ff8ce 100644 --- a/openstack/key_manager/v1/secret.py +++ b/openstack/key_manager/v1/secret.py @@ -10,6 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. +from openstack import format from openstack.key_manager import key_manager_service from openstack import resource @@ -37,7 +38,8 @@ class Secret(resource.Resource): #: A list of content types content_types = resource.prop('content_types') #: Once this timestamp has past, the secret will no longer be available. - expires_at = resource.prop('expiration') + #: *Type: datetime object parsed from ISO 8601 formatted string* + expires_at = resource.prop('expiration', type=format.ISO8601) #: The type/mode of the algorithm associated with the secret information. mode = resource.prop('mode') #: The name of the secret set by the user @@ -46,5 +48,6 @@ class Secret(resource.Resource): secret_ref = resource.prop('secret_ref') #: The status of this secret status = resource.prop('status') - #: A timestamp when this secret was updated - updated_at = resource.prop('updated') + #: A timestamp when this secret was updated. + #: *Type: datetime object parsed from ISO 8601 formatted string* + updated_at = resource.prop('updated', type=format.ISO8601) diff --git a/openstack/tests/unit/key_manager/v1/test_container.py b/openstack/tests/unit/key_manager/v1/test_container.py index c1cad45f1..6aa7277ac 100644 --- a/openstack/tests/unit/key_manager/v1/test_container.py +++ b/openstack/tests/unit/key_manager/v1/test_container.py @@ -10,6 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. +import datetime + import testtools from openstack.key_manager.v1 import container @@ -17,12 +19,12 @@ from openstack.key_manager.v1 import container IDENTIFIER = 'http://localhost/containers/IDENTIFIER' EXAMPLE = { 'container_ref': IDENTIFIER, - 'created': '2', + 'created': '2015-03-09T12:14:57.233772', 'name': '3', 'secret_refs': '4', 'status': '5', 'type': '6', - 'updated': '7', + 'updated': '2015-03-09T12:15:57.233772', } @@ -43,10 +45,14 @@ class TestContainer(testtools.TestCase): def test_make_it(self): sot = container.Container(EXAMPLE) self.assertEqual(EXAMPLE['container_ref'], sot.container_ref) - self.assertEqual(EXAMPLE['created'], sot.created_at) + dt = datetime.datetime(2015, 3, 9, 12, 14, 57, 233772).replace( + tzinfo=None) + self.assertEqual(dt, sot.created_at.replace(tzinfo=None)) self.assertEqual(EXAMPLE['name'], sot.name) self.assertEqual(EXAMPLE['secret_refs'], sot.secret_refs) self.assertEqual(EXAMPLE['status'], sot.status) self.assertEqual(EXAMPLE['type'], sot.type) - self.assertEqual(EXAMPLE['updated'], sot.updated_at) + dt = datetime.datetime(2015, 3, 9, 12, 15, 57, 233772).replace( + tzinfo=None) + self.assertEqual(dt, sot.updated_at.replace(tzinfo=None)) self.assertEqual(EXAMPLE['container_ref'], sot.id) diff --git a/openstack/tests/unit/key_manager/v1/test_secret.py b/openstack/tests/unit/key_manager/v1/test_secret.py index f418f62e8..6a7e9a24f 100644 --- a/openstack/tests/unit/key_manager/v1/test_secret.py +++ b/openstack/tests/unit/key_manager/v1/test_secret.py @@ -10,6 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. +import datetime + import testtools from openstack.key_manager.v1 import secret @@ -19,12 +21,12 @@ EXAMPLE = { 'algorithm': '1', 'bit_length': '2', 'content_types': '3', - 'expiration': '4', + 'expiration': '2017-03-09T12:14:57.233772', 'mode': '5', 'name': '6', 'secret_ref': IDENTIFIER, 'status': '8', - 'updated': '9', + 'updated': '2015-03-09T12:15:57.233772', } @@ -47,10 +49,14 @@ class TestSecret(testtools.TestCase): self.assertEqual(EXAMPLE['algorithm'], sot.algorithm) self.assertEqual(EXAMPLE['bit_length'], sot.bit_length) self.assertEqual(EXAMPLE['content_types'], sot.content_types) - self.assertEqual(EXAMPLE['expiration'], sot.expires_at) + dt = datetime.datetime(2017, 3, 9, 12, 14, 57, 233772).replace( + tzinfo=None) + self.assertEqual(dt, sot.expires_at.replace(tzinfo=None)) self.assertEqual(EXAMPLE['mode'], sot.mode) self.assertEqual(EXAMPLE['name'], sot.name) self.assertEqual(EXAMPLE['secret_ref'], sot.secret_ref) self.assertEqual(EXAMPLE['status'], sot.status) - self.assertEqual(EXAMPLE['updated'], sot.updated_at) + dt = datetime.datetime(2015, 3, 9, 12, 15, 57, 233772).replace( + tzinfo=None) + self.assertEqual(dt, sot.updated_at.replace(tzinfo=None)) self.assertEqual(EXAMPLE['secret_ref'], sot.id)