Merge "Use base.create_domain to create domain in testcases"

This commit is contained in:
Jenkins 2017-04-25 10:19:55 +00:00 committed by Gerrit Code Review
commit 7bc5aa516a
5 changed files with 10 additions and 19 deletions

@ -31,10 +31,7 @@ class DomainsTestJSON(base.BaseIdentityV3AdminTest):
# One of those domains will be disabled
cls.setup_domains = list()
for i in range(3):
domain = cls.domains_client.create_domain(
name=data_utils.rand_name('domain'),
description=data_utils.rand_name('domain-desc'),
enabled=i < 2)['domain']
domain = cls.create_domain(enabled=i < 2)
cls.setup_domains.append(domain)
@classmethod

@ -25,11 +25,7 @@ class DomainsNegativeTestJSON(base.BaseIdentityV3AdminTest):
@decorators.attr(type=['negative', 'gate'])
@decorators.idempotent_id('1f3fbff5-4e44-400d-9ca1-d953f05f609b')
def test_delete_active_domain(self):
d_name = data_utils.rand_name('domain')
d_desc = data_utils.rand_name('domain-desc')
domain = self.domains_client.create_domain(
name=d_name,
description=d_desc)['domain']
domain = self.create_domain()
domain_id = domain['id']
self.addCleanup(self.delete_domain, domain_id)

@ -31,9 +31,7 @@ class BaseInheritsV3Test(base.BaseIdentityV3AdminTest):
u_desc = '%s description' % u_name
u_email = '%s@testmail.tm' % u_name
u_password = data_utils.rand_name('pass-')
cls.domain = cls.domains_client.create_domain(
name=data_utils.rand_name('domain-'),
description=data_utils.rand_name('domain-desc-'))['domain']
cls.domain = cls.create_domain()
cls.project = cls.projects_client.create_project(
data_utils.rand_name('project-'),
description=data_utils.rand_name('project-desc-'),

@ -38,9 +38,7 @@ class RolesV3TestJSON(base.BaseIdentityV3AdminTest):
u_desc = '%s description' % u_name
u_email = '%s@testmail.tm' % u_name
cls.u_password = data_utils.rand_password()
cls.domain = cls.domains_client.create_domain(
name=data_utils.rand_name('domain'),
description=data_utils.rand_name('domain-desc'))['domain']
cls.domain = cls.create_domain()
cls.project = cls.projects_client.create_project(
data_utils.rand_name('project'),
description=data_utils.rand_name('project-desc'),

@ -236,11 +236,13 @@ class BaseIdentityV3AdminTest(BaseIdentityV3Test):
cls.users_client.update_user(user['id'], name=user_name, enabled=False)
@classmethod
def create_domain(cls):
def create_domain(cls, **kwargs):
"""Create a domain."""
domain = cls.domains_client.create_domain(
name=data_utils.rand_name('test_domain'),
description=data_utils.rand_name('desc'))['domain']
if 'name' not in kwargs:
kwargs['name'] = data_utils.rand_name('test_domain')
if 'description' not in kwargs:
kwargs['description'] = data_utils.rand_name('desc')
domain = cls.domains_client.create_domain(**kwargs)['domain']
return domain
def delete_domain(self, domain_id):