diff options
Diffstat (limited to 'openstackclient/tests/functional/identity/v2')
9 files changed, 122 insertions, 89 deletions
diff --git a/openstackclient/tests/functional/identity/v2/common.py b/openstackclient/tests/functional/identity/v2/common.py index 43c0cbf2..9d3601eb 100644 --- a/openstackclient/tests/functional/identity/v2/common.py +++ b/openstackclient/tests/functional/identity/v2/common.py @@ -23,21 +23,37 @@ BASIC_LIST_HEADERS = ['ID', 'Name'] class IdentityTests(base.TestCase): - """Functional tests for Identity commands. """ + """Functional tests for Identity commands.""" USER_FIELDS = ['email', 'enabled', 'id', 'name', 'project_id', 'username'] PROJECT_FIELDS = ['enabled', 'id', 'name', 'description'] TOKEN_FIELDS = ['expires', 'id', 'project_id', 'user_id'] ROLE_FIELDS = ['id', 'name', 'domain_id'] SERVICE_FIELDS = ['id', 'enabled', 'name', 'type', 'description'] - ENDPOINT_FIELDS = ['id', 'region', 'service_id', 'service_name', - 'service_type', 'publicurl', - 'adminurl', 'internalurl'] - - EC2_CREDENTIALS_FIELDS = ['access', 'project_id', 'secret', - 'trust_id', 'user_id'] - EC2_CREDENTIALS_LIST_HEADERS = ['Access', 'Secret', - 'Project ID', 'User ID'] + ENDPOINT_FIELDS = [ + 'id', + 'region', + 'service_id', + 'service_name', + 'service_type', + 'publicurl', + 'adminurl', + 'internalurl', + ] + + EC2_CREDENTIALS_FIELDS = [ + 'access', + 'project_id', + 'secret', + 'trust_id', + 'user_id', + ] + EC2_CREDENTIALS_LIST_HEADERS = [ + 'Access', + 'Secret', + 'Project ID', + 'User ID', + ] CATALOG_LIST_HEADERS = ['Name', 'Type', 'Endpoints'] ENDPOINT_LIST_HEADERS = ['ID', 'Region', 'Service Name', 'Service Type'] @@ -53,7 +69,8 @@ class IdentityTests(base.TestCase): 'project create ' '--description %(description)s ' '--enable ' - '%(name)s' % { + '%(name)s' + % { 'description': cls.project_description, 'name': cls.project_name, } @@ -70,7 +87,8 @@ class IdentityTests(base.TestCase): try: cls.openstack( '--os-identity-api-version 2 ' - 'project delete %s' % cls.project_name) + 'project delete %s' % cls.project_name + ) finally: super(IdentityTests, cls).tearDownClass() @@ -78,7 +96,8 @@ class IdentityTests(base.TestCase): super(IdentityTests, self).setUp() # prepare v2 env ver_fixture = fixtures.EnvironmentVariable( - 'OS_IDENTITY_API_VERSION', '2.0') + 'OS_IDENTITY_API_VERSION', '2.0' + ) self.useFixture(ver_fixture) auth_url = os.environ.get('OS_AUTH_URL') if auth_url: @@ -93,13 +112,14 @@ class IdentityTests(base.TestCase): raw_output = self.openstack( 'project create ' '--description %(description)s ' - '--enable %(name)s' % {'description': project_description, - 'name': project_name}) + '--enable %(name)s' + % {'description': project_description, 'name': project_name} + ) project = self.parse_show_as_object(raw_output) if add_clean_up: self.addCleanup( - self.openstack, - 'project delete %s' % project['id']) + self.openstack, 'project delete %s' % project['id'] + ) items = self.parse_show(raw_output) self.assert_show_fields(items, self.PROJECT_FIELDS) return project_name @@ -114,14 +134,19 @@ class IdentityTests(base.TestCase): '--password %(password)s ' '--email %(email)s ' '--enable ' - '%(name)s' % {'project': self.project_name, - 'email': email, - 'password': password, - 'name': username}) + '%(name)s' + % { + 'project': self.project_name, + 'email': email, + 'password': password, + 'name': username, + } + ) if add_clean_up: self.addCleanup( self.openstack, - 'user delete %s' % self.parse_show_as_object(raw_output)['id']) + 'user delete %s' % self.parse_show_as_object(raw_output)['id'], + ) items = self.parse_show(raw_output) self.assert_show_fields(items, self.USER_FIELDS) return username @@ -131,9 +156,7 @@ class IdentityTests(base.TestCase): raw_output = self.openstack('role create %s' % role_name) role = self.parse_show_as_object(raw_output) if add_clean_up: - self.addCleanup( - self.openstack, - 'role delete %s' % role['id']) + self.addCleanup(self.openstack, 'role delete %s' % role['id']) items = self.parse_show(raw_output) self.assert_show_fields(items, self.ROLE_FIELDS) self.assertEqual(role_name, role['name']) @@ -145,8 +168,8 @@ class IdentityTests(base.TestCase): access_key = ec2_credentials['access'] if add_clean_up: self.addCleanup( - self.openstack, - 'ec2 credentials delete %s' % access_key) + self.openstack, 'ec2 credentials delete %s' % access_key + ) items = self.parse_show(raw_output) self.assert_show_fields(items, self.EC2_CREDENTIALS_FIELDS) return access_key @@ -155,8 +178,7 @@ class IdentityTests(base.TestCase): raw_output = self.openstack('token issue') token = self.parse_show_as_object(raw_output) if add_clean_up: - self.addCleanup(self.openstack, - 'token revoke %s' % token['id']) + self.addCleanup(self.openstack, 'token revoke %s' % token['id']) items = self.parse_show(raw_output) self.assert_show_fields(items, self.TOKEN_FIELDS) return token['id'] @@ -169,13 +191,18 @@ class IdentityTests(base.TestCase): 'service create ' '--name %(name)s ' '--description %(description)s ' - '%(type)s' % {'name': service_name, - 'description': description, - 'type': type_name}) + '%(type)s' + % { + 'name': service_name, + 'description': description, + 'type': type_name, + } + ) if add_clean_up: service = self.parse_show_as_object(raw_output) - self.addCleanup(self.openstack, - 'service delete %s' % service['id']) + self.addCleanup( + self.openstack, 'service delete %s' % service['id'] + ) items = self.parse_show(raw_output) self.assert_show_fields(items, self.SERVICE_FIELDS) return service_name @@ -192,16 +219,20 @@ class IdentityTests(base.TestCase): '--adminurl %(adminurl)s ' '--internalurl %(internalurl)s ' '--region %(region)s ' - '%(service)s' % {'publicurl': public_url, - 'adminurl': admin_url, - 'internalurl': internal_url, - 'region': region_id, - 'service': service_name}) + '%(service)s' + % { + 'publicurl': public_url, + 'adminurl': admin_url, + 'internalurl': internal_url, + 'region': region_id, + 'service': service_name, + } + ) endpoint = self.parse_show_as_object(raw_output) if add_clean_up: self.addCleanup( - self.openstack, - 'endpoint delete %s' % endpoint['id']) + self.openstack, 'endpoint delete %s' % endpoint['id'] + ) items = self.parse_show(raw_output) self.assert_show_fields(items, self.ENDPOINT_FIELDS) return endpoint['id'] diff --git a/openstackclient/tests/functional/identity/v2/test_catalog.py b/openstackclient/tests/functional/identity/v2/test_catalog.py index f403fbfc..1cef314f 100644 --- a/openstackclient/tests/functional/identity/v2/test_catalog.py +++ b/openstackclient/tests/functional/identity/v2/test_catalog.py @@ -14,7 +14,6 @@ from openstackclient.tests.functional.identity.v2 import common class CatalogTests(common.IdentityTests): - def test_catalog_list(self): raw_output = self.openstack('catalog list') items = self.parse_listing(raw_output) diff --git a/openstackclient/tests/functional/identity/v2/test_ec2_credentials.py b/openstackclient/tests/functional/identity/v2/test_ec2_credentials.py index 43dff91f..6d25bdae 100644 --- a/openstackclient/tests/functional/identity/v2/test_ec2_credentials.py +++ b/openstackclient/tests/functional/identity/v2/test_ec2_credentials.py @@ -14,7 +14,6 @@ from openstackclient.tests.functional.identity.v2 import common class EC2CredentialsTests(common.IdentityTests): - def test_ec2_credentials_create(self): self._create_dummy_ec2_credentials() diff --git a/openstackclient/tests/functional/identity/v2/test_endpoint.py b/openstackclient/tests/functional/identity/v2/test_endpoint.py index 9df5ca8a..bafbfdae 100644 --- a/openstackclient/tests/functional/identity/v2/test_endpoint.py +++ b/openstackclient/tests/functional/identity/v2/test_endpoint.py @@ -14,21 +14,20 @@ from openstackclient.tests.functional.identity.v2 import common class EndpointTests(common.IdentityTests): - def test_endpoint_create(self): self._create_dummy_endpoint() def test_endpoint_delete(self): endpoint_id = self._create_dummy_endpoint(add_clean_up=False) - raw_output = self.openstack( - 'endpoint delete %s' % endpoint_id) + raw_output = self.openstack('endpoint delete %s' % endpoint_id) self.assertEqual(0, len(raw_output)) def test_endpoint_multi_delete(self): endpoint_id_1 = self._create_dummy_endpoint(add_clean_up=False) endpoint_id_2 = self._create_dummy_endpoint(add_clean_up=False) raw_output = self.openstack( - 'endpoint delete ' + endpoint_id_1 + ' ' + endpoint_id_2) + 'endpoint delete ' + endpoint_id_1 + ' ' + endpoint_id_2 + ) self.assertEqual(0, len(raw_output)) def test_endpoint_list(self): diff --git a/openstackclient/tests/functional/identity/v2/test_project.py b/openstackclient/tests/functional/identity/v2/test_project.py index 38777c36..1ad0edaa 100644 --- a/openstackclient/tests/functional/identity/v2/test_project.py +++ b/openstackclient/tests/functional/identity/v2/test_project.py @@ -16,7 +16,6 @@ from openstackclient.tests.functional.identity.v2 import common class ProjectTests(common.IdentityTests): - def test_project_create(self): project_name = data_utils.rand_name('TestProject') description = data_utils.rand_name('description') @@ -26,12 +25,9 @@ class ProjectTests(common.IdentityTests): '--enable ' '--property k1=v1 ' '--property k2=v2 ' - '%(name)s' % {'description': description, - 'name': project_name}) - self.addCleanup( - self.openstack, - 'project delete %s' % project_name + '%(name)s' % {'description': description, 'name': project_name} ) + self.addCleanup(self.openstack, 'project delete %s' % project_name) items = self.parse_show(raw_output) show_fields = list(self.PROJECT_FIELDS) show_fields.extend(['k1', 'k2']) @@ -42,8 +38,7 @@ class ProjectTests(common.IdentityTests): def test_project_delete(self): project_name = self._create_dummy_project(add_clean_up=False) - raw_output = self.openstack( - 'project delete %s' % project_name) + raw_output = self.openstack('project delete %s' % project_name) self.assertEqual(0, len(raw_output)) def test_project_list(self): @@ -59,13 +54,11 @@ class ProjectTests(common.IdentityTests): '--name %(new_name)s ' '--disable ' '--property k0=v0 ' - '%(name)s' % {'new_name': new_project_name, - 'name': project_name}) + '%(name)s' % {'new_name': new_project_name, 'name': project_name} + ) self.assertEqual(0, len(raw_output)) # check project details - raw_output = self.openstack( - 'project show %s' % new_project_name - ) + raw_output = self.openstack('project show %s' % new_project_name) items = self.parse_show(raw_output) fields = list(self.PROJECT_FIELDS) fields.extend(['properties']) @@ -77,9 +70,7 @@ class ProjectTests(common.IdentityTests): def test_project_show(self): project_name = self._create_dummy_project() - raw_output = self.openstack( - 'project show %s' % project_name - ) + raw_output = self.openstack('project show %s' % project_name) items = self.parse_show(raw_output) fields = list(self.PROJECT_FIELDS) fields.extend(['properties']) diff --git a/openstackclient/tests/functional/identity/v2/test_role.py b/openstackclient/tests/functional/identity/v2/test_role.py index 124603d8..fb22f018 100644 --- a/openstackclient/tests/functional/identity/v2/test_role.py +++ b/openstackclient/tests/functional/identity/v2/test_role.py @@ -14,7 +14,6 @@ from openstackclient.tests.functional.identity.v2 import common class RoleTests(common.IdentityTests): - def test_role_create(self): self._create_dummy_role() @@ -42,17 +41,25 @@ class RoleTests(common.IdentityTests): 'role add ' '--project %(project)s ' '--user %(user)s ' - '%(role)s' % {'project': self.project_name, - 'user': username, - 'role': role_name}) + '%(role)s' + % { + 'project': self.project_name, + 'user': username, + 'role': role_name, + } + ) self.addCleanup( self.openstack, 'role remove ' '--project %(project)s ' '--user %(user)s ' - '%(role)s' % {'project': self.project_name, - 'user': username, - 'role': role_name}) + '%(role)s' + % { + 'project': self.project_name, + 'user': username, + 'role': role_name, + }, + ) items = self.parse_show(raw_output) self.assert_show_fields(items, self.ROLE_FIELDS) @@ -63,16 +70,24 @@ class RoleTests(common.IdentityTests): 'role add ' '--project %(project)s ' '--user %(user)s ' - '%(role)s' % {'project': self.project_name, - 'user': username, - 'role': role_name}) + '%(role)s' + % { + 'project': self.project_name, + 'user': username, + 'role': role_name, + } + ) del_raw_output = self.openstack( 'role remove ' '--project %(project)s ' '--user %(user)s ' - '%(role)s' % {'project': self.project_name, - 'user': username, - 'role': role_name}) + '%(role)s' + % { + 'project': self.project_name, + 'user': username, + 'role': role_name, + } + ) items = self.parse_show(add_raw_output) self.assert_show_fields(items, self.ROLE_FIELDS) self.assertEqual(0, len(del_raw_output)) diff --git a/openstackclient/tests/functional/identity/v2/test_service.py b/openstackclient/tests/functional/identity/v2/test_service.py index d0e03804..7afa967d 100644 --- a/openstackclient/tests/functional/identity/v2/test_service.py +++ b/openstackclient/tests/functional/identity/v2/test_service.py @@ -14,7 +14,6 @@ from openstackclient.tests.functional.identity.v2 import common class ServiceTests(common.IdentityTests): - def test_service_create(self): self._create_dummy_service() @@ -27,7 +26,8 @@ class ServiceTests(common.IdentityTests): service_name_1 = self._create_dummy_service(add_clean_up=False) service_name_2 = self._create_dummy_service(add_clean_up=False) raw_output = self.openstack( - 'service delete ' + service_name_1 + ' ' + service_name_2) + 'service delete ' + service_name_1 + ' ' + service_name_2 + ) self.assertEqual(0, len(raw_output)) def test_service_list(self): @@ -38,7 +38,6 @@ class ServiceTests(common.IdentityTests): def test_service_show(self): service_name = self._create_dummy_service() - raw_output = self.openstack( - 'service show %s' % service_name) + raw_output = self.openstack('service show %s' % service_name) items = self.parse_show(raw_output) self.assert_show_fields(items, self.SERVICE_FIELDS) diff --git a/openstackclient/tests/functional/identity/v2/test_token.py b/openstackclient/tests/functional/identity/v2/test_token.py index f8569744..d2ef78e3 100644 --- a/openstackclient/tests/functional/identity/v2/test_token.py +++ b/openstackclient/tests/functional/identity/v2/test_token.py @@ -14,7 +14,6 @@ from openstackclient.tests.functional.identity.v2 import common class TokenTests(common.IdentityTests): - def test_token_issue(self): self._create_dummy_token() diff --git a/openstackclient/tests/functional/identity/v2/test_user.py b/openstackclient/tests/functional/identity/v2/test_user.py index ac609b94..d30e3c45 100644 --- a/openstackclient/tests/functional/identity/v2/test_user.py +++ b/openstackclient/tests/functional/identity/v2/test_user.py @@ -17,7 +17,6 @@ from openstackclient.tests.functional.identity.v2 import common class UserTests(common.IdentityTests): - def test_user_create(self): self._create_dummy_user() @@ -37,12 +36,13 @@ class UserTests(common.IdentityTests): user = self.parse_show_as_object(raw_output) new_username = data_utils.rand_name('NewTestUser') new_email = data_utils.rand_name() + '@example.com' - raw_output = self.openstack('user set ' - '--email %(email)s ' - '--name %(new_name)s ' - '%(id)s' % {'email': new_email, - 'new_name': new_username, - 'id': user['id']}) + raw_output = self.openstack( + 'user set ' + '--email %(email)s ' + '--name %(new_name)s ' + '%(id)s' + % {'email': new_email, 'new_name': new_username, 'id': user['id']} + ) self.assertEqual(0, len(raw_output)) raw_output = self.openstack('user show %s' % new_username) new_user = self.parse_show_as_object(raw_output) @@ -56,5 +56,6 @@ class UserTests(common.IdentityTests): self.assert_show_fields(items, self.USER_FIELDS) def test_bad_user_command(self): - self.assertRaises(exceptions.CommandFailed, - self.openstack, 'user unlist') + self.assertRaises( + exceptions.CommandFailed, self.openstack, 'user unlist' + ) |