Consistent resource.prop for timestamps and booleans (key manager)

This patch set updates all key manager objects to use consistent
resource.prop for timestamps and booleans. In particular, the
following changes were made:
  - Clarify documentation for timestamp and boolean attributes
  - Use 'is_' prefix and boolean type for boolean attributes
  - Use '_at' suffix and timestamp type for timestamp attributes

Change-Id: I512f5a72a6cc3edbaeaa48b8e3677a0db9da68e9
Partial-Bug: #1544584
This commit is contained in:
Richard Theis 2016-03-15 13:13:57 -05:00
parent 1004b4594d
commit e75ec30947
4 changed files with 33 additions and 15 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)