Merge "Consistent resource.prop for timestamps and booleans (identity)"

This commit is contained in:
Jenkins 2016-03-21 17:11:18 +00:00 committed by Gerrit Code Review
commit 176df5511d
20 changed files with 42 additions and 30 deletions

View File

@ -10,6 +10,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from openstack import format
from openstack.identity import identity_service from openstack.identity import identity_service
from openstack import resource from openstack import resource
@ -41,8 +42,8 @@ class Extension(resource.Resource):
#: *Type: string* #: *Type: string*
namespace = resource.prop('namespace') namespace = resource.prop('namespace')
#: The last time the extension has been modified (update date). #: The last time the extension has been modified (update date).
#: *Type: date* #: *Type: datetime object parsed from ISO 8601 formatted string*
updated = resource.prop('updated') updated_at = resource.prop('updated', type=format.ISO8601)
@classmethod @classmethod
def list(cls, session, **params): def list(cls, session, **params):

View File

@ -31,8 +31,8 @@ class Role(resource.Resource):
# Properties # Properties
#: The description of the role. *Type: string* #: The description of the role. *Type: string*
description = resource.prop('description') description = resource.prop('description')
#: Setting this attribute to ``False`` prevents this role from being
#: available in the role list. *Type: bool*
is_enabled = resource.prop('enabled', type=format.BoolStr)
#: Unique role name. *Type: string* #: Unique role name. *Type: string*
name = resource.prop('name') name = resource.prop('name')
#: Setting this attribute to ``False`` prevents this role from being
#: available in the role list.
enabled = resource.prop('enabled', type=format.BoolStr)

View File

@ -34,6 +34,6 @@ class Tenant(resource.Resource):
#: against this tenant. Additionally, all pre-existing tokens authorized #: against this tenant. Additionally, all pre-existing tokens authorized
#: for the tenant are immediately invalidated. Re-enabling a tenant #: for the tenant are immediately invalidated. Re-enabling a tenant
#: does not re-enable pre-existing tokens. *Type: bool* #: does not re-enable pre-existing tokens. *Type: bool*
enabled = resource.prop('enabled', type=bool) is_enabled = resource.prop('enabled', type=bool)
#: Unique tenant name. *Type: string* #: Unique tenant name. *Type: string*
name = resource.prop('name') name = resource.prop('name')

View File

@ -34,6 +34,6 @@ class User(resource.Resource):
#: receiving authorization. Additionally, all pre-existing tokens held by #: receiving authorization. Additionally, all pre-existing tokens held by
#: the user are immediately invalidated. Re-enabling a user does not #: the user are immediately invalidated. Re-enabling a user does not
#: re-enable pre-existing tokens. *Type: bool* #: re-enable pre-existing tokens. *Type: bool*
enabled = resource.prop('enabled', type=bool) is_enabled = resource.prop('enabled', type=bool)
#: The name of this user. *Type: string* #: The name of this user. *Type: string*
name = resource.prop('name') name = resource.prop('name')

View File

@ -38,6 +38,6 @@ class Domain(resource.Resource):
#: to the above entities are immediately invalidated. #: to the above entities are immediately invalidated.
#: Re-enabling a domain does not re-enable pre-existing tokens. #: Re-enabling a domain does not re-enable pre-existing tokens.
#: *Type: bool* #: *Type: bool*
enabled = resource.prop('enabled', type=bool) is_enabled = resource.prop('enabled', type=bool)
#: The globally unique name of this domain. *Type: string* #: The globally unique name of this domain. *Type: string*
name = resource.prop('name') name = resource.prop('name')

View File

@ -29,9 +29,6 @@ class Endpoint(resource.Resource):
patch_update = True patch_update = True
# Properties # Properties
#: Setting this value to ``False`` prevents the endpoint from appearing
#: in the service catalog. *Type: bool*
enabled = resource.prop('enabled', type=bool)
#: Describes the interface of the endpoint according to one of the #: Describes the interface of the endpoint according to one of the
#: following values: #: following values:
#: #:
@ -44,6 +41,9 @@ class Endpoint(resource.Resource):
#: #:
#: *Type: string* #: *Type: string*
interface = resource.prop('interface') interface = resource.prop('interface')
#: Setting this value to ``False`` prevents the endpoint from appearing
#: in the service catalog. *Type: bool*
is_enabled = resource.prop('enabled', type=bool)
#: Represents the containing region ID of the service endpoint. #: Represents the containing region ID of the service endpoint.
#: *New in v3.2* *Type: string* #: *New in v3.2* *Type: string*
region_id = resource.prop('region_id') region_id = resource.prop('region_id')

View File

@ -40,6 +40,6 @@ class Project(resource.Resource):
#: against this project. Additionally, all pre-existing tokens authorized #: against this project. Additionally, all pre-existing tokens authorized
#: for the project are immediately invalidated. Re-enabling a project #: for the project are immediately invalidated. Re-enabling a project
#: does not re-enable pre-existing tokens. *Type: bool* #: does not re-enable pre-existing tokens. *Type: bool*
enabled = resource.prop('enabled', type=bool) is_enabled = resource.prop('enabled', type=bool)
#: Unique project name, within the owning domain. *Type: string* #: Unique project name, within the owning domain. *Type: string*
name = resource.prop('name') name = resource.prop('name')

View File

@ -33,7 +33,7 @@ class Service(resource.Resource):
description = resource.prop('description') description = resource.prop('description')
#: Setting this value to ``False`` prevents the service and #: Setting this value to ``False`` prevents the service and
#: its endpoints from appearing in the service catalog. *Type: bool* #: its endpoints from appearing in the service catalog. *Type: bool*
enabled = resource.prop('enabled', type=bool) is_enabled = resource.prop('enabled', type=bool)
#: User-facing name of the service. *Type: string* #: User-facing name of the service. *Type: string*
name = resource.prop('name') name = resource.prop('name')
#: Describes the API implemented by the service. The following values are #: Describes the API implemented by the service. The following values are

View File

@ -11,6 +11,7 @@
# under the License. # under the License.
from openstack import format
from openstack.identity import identity_service from openstack.identity import identity_service
from openstack import resource from openstack import resource
@ -33,8 +34,9 @@ class Trust(resource.Resource):
project_id = resource.prop('project_id') project_id = resource.prop('project_id')
#: Specifies the expiration time of the trust. A trust may be revoked #: Specifies the expiration time of the trust. A trust may be revoked
#: ahead of expiration. If the value represents a time in the past, #: ahead of expiration. If the value represents a time in the past,
#: the trust is deactivated. *Type: string* #: the trust is deactivated.
expires_at = resource.prop('expires_at') #: *Type: datetime object parsed from ISO 8601 formatted string*
expires_at = resource.prop('expires_at', type=format.ISO8601)
#: ID of the trust object. *Type: string* #: ID of the trust object. *Type: string*
id = resource.prop('id') id = resource.prop('id')
#: If ``impersonation`` is set to true, then the ``user`` attribute #: If ``impersonation`` is set to true, then the ``user`` attribute
@ -42,8 +44,8 @@ class Trust(resource.Resource):
#: that of the trustor rather than the trustee, thus allowing the trustee #: that of the trustor rather than the trustee, thus allowing the trustee
#: to impersonate the trustor. #: to impersonate the trustor.
#: If ``impersonation`` is set to ``False``, then the token's ``user`` #: If ``impersonation`` is set to ``False``, then the token's ``user``
#: attribute will represent that of the trustee. *Type: boolean* #: attribute will represent that of the trustee. *Type: bool*
impersonation = resource.prop('impersonation') is_impersonation = resource.prop('impersonation', type=bool)
#: Represents the user ID who is capable of consuming the trust. #: Represents the user ID who is capable of consuming the trust.
#: *Type: string* #: *Type: string*
trustee_user_id = resource.prop('trustee_user_id') trustee_user_id = resource.prop('trustee_user_id')

View File

@ -53,7 +53,7 @@ class User(resource.Resource):
#: receiving authorization. Additionally, all pre-existing tokens held by #: receiving authorization. Additionally, all pre-existing tokens held by
#: the user are immediately invalidated. Re-enabling a user does not #: the user are immediately invalidated. Re-enabling a user does not
#: re-enable pre-existing tokens. *Type: bool* #: re-enable pre-existing tokens. *Type: bool*
enabled = resource.prop('enabled', type=bool) is_enabled = resource.prop('enabled', type=bool)
#: Unique user name, within the owning domain. *Type: string* #: Unique user name, within the owning domain. *Type: string*
name = resource.prop('name') name = resource.prop('name')
#: The default form of credential used during authentication. #: The default form of credential used during authentication.

View File

@ -10,6 +10,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import datetime
import mock import mock
import testtools import testtools
@ -22,7 +24,7 @@ EXAMPLE = {
'links': '3', 'links': '3',
'name': '4', 'name': '4',
'namespace': '5', 'namespace': '5',
'updated': '6', 'updated': '2015-03-09T12:14:57.233772',
} }
@ -47,7 +49,9 @@ class TestExtension(testtools.TestCase):
self.assertEqual(EXAMPLE['links'], sot.links) self.assertEqual(EXAMPLE['links'], sot.links)
self.assertEqual(EXAMPLE['name'], sot.name) self.assertEqual(EXAMPLE['name'], sot.name)
self.assertEqual(EXAMPLE['namespace'], sot.namespace) self.assertEqual(EXAMPLE['namespace'], sot.namespace)
self.assertEqual(EXAMPLE['updated'], sot.updated) dt = datetime.datetime(2015, 3, 9, 12, 14, 57, 233772).replace(
tzinfo=None)
self.assertEqual(dt, sot.updated_at.replace(tzinfo=None))
def test_list(self): def test_list(self):
resp = mock.Mock() resp = mock.Mock()

View File

@ -43,3 +43,4 @@ class TestRole(testtools.TestCase):
self.assertEqual(EXAMPLE['description'], sot.description) self.assertEqual(EXAMPLE['description'], sot.description)
self.assertEqual(EXAMPLE['id'], sot.id) self.assertEqual(EXAMPLE['id'], sot.id)
self.assertEqual(EXAMPLE['name'], sot.name) self.assertEqual(EXAMPLE['name'], sot.name)
self.assertTrue(sot.is_enabled)

View File

@ -40,6 +40,6 @@ class TestTenant(testtools.TestCase):
def test_make_it(self): def test_make_it(self):
sot = tenant.Tenant(EXAMPLE) sot = tenant.Tenant(EXAMPLE)
self.assertEqual(EXAMPLE['description'], sot.description) self.assertEqual(EXAMPLE['description'], sot.description)
self.assertEqual(EXAMPLE['enabled'], sot.enabled) self.assertTrue(sot.is_enabled)
self.assertEqual(EXAMPLE['id'], sot.id) self.assertEqual(EXAMPLE['id'], sot.id)
self.assertEqual(EXAMPLE['name'], sot.name) self.assertEqual(EXAMPLE['name'], sot.name)

View File

@ -40,6 +40,6 @@ class TestUser(testtools.TestCase):
def test_make_it(self): def test_make_it(self):
sot = user.User(EXAMPLE) sot = user.User(EXAMPLE)
self.assertEqual(EXAMPLE['email'], sot.email) self.assertEqual(EXAMPLE['email'], sot.email)
self.assertEqual(EXAMPLE['enabled'], sot.enabled) self.assertTrue(sot.is_enabled)
self.assertEqual(EXAMPLE['id'], sot.id) self.assertEqual(EXAMPLE['id'], sot.id)
self.assertEqual(EXAMPLE['name'], sot.name) self.assertEqual(EXAMPLE['name'], sot.name)

View File

@ -40,6 +40,6 @@ class TestDomain(testtools.TestCase):
def test_make_it(self): def test_make_it(self):
sot = domain.Domain(EXAMPLE) sot = domain.Domain(EXAMPLE)
self.assertEqual(EXAMPLE['description'], sot.description) self.assertEqual(EXAMPLE['description'], sot.description)
self.assertEqual(EXAMPLE['enabled'], sot.enabled) self.assertTrue(sot.is_enabled)
self.assertEqual(EXAMPLE['id'], sot.id) self.assertEqual(EXAMPLE['id'], sot.id)
self.assertEqual(EXAMPLE['name'], sot.name) self.assertEqual(EXAMPLE['name'], sot.name)

View File

@ -41,7 +41,7 @@ class TestEndpoint(testtools.TestCase):
def test_make_it(self): def test_make_it(self):
sot = endpoint.Endpoint(EXAMPLE) sot = endpoint.Endpoint(EXAMPLE)
self.assertEqual(EXAMPLE['enabled'], sot.enabled) self.assertTrue(sot.is_enabled)
self.assertEqual(EXAMPLE['id'], sot.id) self.assertEqual(EXAMPLE['id'], sot.id)
self.assertEqual(EXAMPLE['interface'], sot.interface) self.assertEqual(EXAMPLE['interface'], sot.interface)
self.assertEqual(EXAMPLE['region_id'], sot.region_id) self.assertEqual(EXAMPLE['region_id'], sot.region_id)

View File

@ -42,6 +42,6 @@ class TestProject(testtools.TestCase):
sot = project.Project(EXAMPLE) sot = project.Project(EXAMPLE)
self.assertEqual(EXAMPLE['description'], sot.description) self.assertEqual(EXAMPLE['description'], sot.description)
self.assertEqual(EXAMPLE['domain_id'], sot.domain_id) self.assertEqual(EXAMPLE['domain_id'], sot.domain_id)
self.assertEqual(EXAMPLE['enabled'], sot.enabled) self.assertTrue(sot.is_enabled)
self.assertEqual(EXAMPLE['id'], sot.id) self.assertEqual(EXAMPLE['id'], sot.id)
self.assertEqual(EXAMPLE['name'], sot.name) self.assertEqual(EXAMPLE['name'], sot.name)

View File

@ -41,7 +41,7 @@ class TestService(testtools.TestCase):
def test_make_it(self): def test_make_it(self):
sot = service.Service(EXAMPLE) sot = service.Service(EXAMPLE)
self.assertEqual(EXAMPLE['description'], sot.description) self.assertEqual(EXAMPLE['description'], sot.description)
self.assertEqual(EXAMPLE['enabled'], sot.enabled) self.assertTrue(sot.is_enabled)
self.assertEqual(EXAMPLE['id'], sot.id) self.assertEqual(EXAMPLE['id'], sot.id)
self.assertEqual(EXAMPLE['name'], sot.name) self.assertEqual(EXAMPLE['name'], sot.name)
self.assertEqual(EXAMPLE['type'], sot.type) self.assertEqual(EXAMPLE['type'], sot.type)

View File

@ -10,6 +10,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import datetime
import testtools import testtools
from openstack.identity.v3 import trust from openstack.identity.v3 import trust
@ -17,7 +19,7 @@ from openstack.identity.v3 import trust
IDENTIFIER = 'IDENTIFIER' IDENTIFIER = 'IDENTIFIER'
EXAMPLE = { EXAMPLE = {
'project_id': '1', 'project_id': '1',
'expires_at': '2020-01-01T18:30:59.999999Z', 'expires_at': '2016-03-09T12:14:57.233772',
'id': IDENTIFIER, 'id': IDENTIFIER,
'impersonation': True, 'impersonation': True,
'trustee_user_id': '2', 'trustee_user_id': '2',
@ -44,9 +46,11 @@ class TestTrust(testtools.TestCase):
sot = trust.Trust(EXAMPLE) sot = trust.Trust(EXAMPLE)
self.assertEqual(EXAMPLE['project_id'], self.assertEqual(EXAMPLE['project_id'],
sot.project_id) sot.project_id)
self.assertEqual(EXAMPLE['expires_at'], sot.expires_at) dt = datetime.datetime(2016, 3, 9, 12, 14, 57, 233772).replace(
tzinfo=None)
self.assertEqual(dt, sot.expires_at.replace(tzinfo=None))
self.assertEqual(EXAMPLE['id'], sot.id) self.assertEqual(EXAMPLE['id'], sot.id)
self.assertEqual(EXAMPLE['impersonation'], sot.impersonation) self.assertTrue(sot.is_impersonation)
self.assertEqual(EXAMPLE['trustee_user_id'], sot.trustee_user_id) self.assertEqual(EXAMPLE['trustee_user_id'], sot.trustee_user_id)
self.assertEqual(EXAMPLE['trustor_user_id'], sot.trustor_user_id) self.assertEqual(EXAMPLE['trustor_user_id'], sot.trustor_user_id)
self.assertEqual(EXAMPLE['roles'], sot.roles) self.assertEqual(EXAMPLE['roles'], sot.roles)

View File

@ -48,7 +48,7 @@ class TestUser(testtools.TestCase):
self.assertEqual(EXAMPLE['description'], sot.description) self.assertEqual(EXAMPLE['description'], sot.description)
self.assertEqual(EXAMPLE['domain_id'], sot.domain_id) self.assertEqual(EXAMPLE['domain_id'], sot.domain_id)
self.assertEqual(EXAMPLE['email'], sot.email) self.assertEqual(EXAMPLE['email'], sot.email)
self.assertEqual(EXAMPLE['enabled'], sot.enabled) self.assertTrue(sot.is_enabled)
self.assertEqual(EXAMPLE['id'], sot.id) self.assertEqual(EXAMPLE['id'], sot.id)
self.assertEqual(EXAMPLE['name'], sot.name) self.assertEqual(EXAMPLE['name'], sot.name)
self.assertEqual(EXAMPLE['password'], sot.password) self.assertEqual(EXAMPLE['password'], sot.password)