[test][unit]creating resources support set project_id
To write a new unit test, need to set "project_id", and then use the discarded "tenant_id" is not appropriate. this patch updated creating resources method, both "project_id" and "tenant_id" are acceptable. of course, "project_id" priority. Closes-bug: #1966354 Change-Id: Ic24f03da169dd3d1549b05b35ec77d3e9a25f17b
This commit is contained in:
parent
1b68aebaba
commit
cc50b45ca3
|
@ -108,6 +108,8 @@ class MeteringPluginDbTestCaseMixin(object):
|
|||
@contextlib.contextmanager
|
||||
def metering_label(self, name='label', description='desc',
|
||||
fmt=None, **kwargs):
|
||||
if 'project_id' in kwargs:
|
||||
kwargs['tenant_id'] = kwargs['project_id']
|
||||
if not fmt:
|
||||
fmt = self.fmt
|
||||
metering_label = self._make_metering_label(fmt, name,
|
||||
|
@ -117,6 +119,8 @@ class MeteringPluginDbTestCaseMixin(object):
|
|||
@contextlib.contextmanager
|
||||
def metering_label_rule(self, metering_label_id=None, direction='ingress',
|
||||
excluded=False, fmt=None, **kwargs):
|
||||
if 'project_id' in kwargs:
|
||||
kwargs['tenant_id'] = kwargs['project_id']
|
||||
if not fmt:
|
||||
fmt = self.fmt
|
||||
metering_label_rule = self._make_metering_label_rule(fmt,
|
||||
|
|
|
@ -746,6 +746,8 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase):
|
|||
admin_state_up=True,
|
||||
fmt=None,
|
||||
**kwargs):
|
||||
if 'project_id' in kwargs:
|
||||
kwargs['tenant_id'] = kwargs['project_id']
|
||||
network = self._make_network(fmt or self.fmt, name,
|
||||
admin_state_up, **kwargs)
|
||||
yield network
|
||||
|
@ -766,9 +768,11 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase):
|
|||
ipv6_ra_mode=None,
|
||||
ipv6_address_mode=None,
|
||||
tenant_id=None,
|
||||
project_id=None,
|
||||
service_types=None,
|
||||
set_context=False):
|
||||
|
||||
if project_id:
|
||||
tenant_id = project_id
|
||||
cidr = netaddr.IPNetwork(cidr) if cidr else None
|
||||
if (gateway_ip is not None and
|
||||
gateway_ip != constants.ATTR_NOT_SPECIFIED):
|
||||
|
@ -797,6 +801,8 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase):
|
|||
|
||||
@contextlib.contextmanager
|
||||
def subnetpool(self, prefixes, admin=False, **kwargs):
|
||||
if 'project_id' in kwargs:
|
||||
kwargs['tenant_id'] = kwargs['project_id']
|
||||
subnetpool = self._make_subnetpool(self.fmt,
|
||||
prefixes,
|
||||
admin,
|
||||
|
@ -804,8 +810,10 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase):
|
|||
yield subnetpool
|
||||
|
||||
@contextlib.contextmanager
|
||||
def port(self, subnet=None, fmt=None, set_context=False, tenant_id=None,
|
||||
def port(self, subnet=None, fmt=None, set_context=False, project_id=None,
|
||||
**kwargs):
|
||||
tenant_id = project_id if project_id else kwargs.pop(
|
||||
'tenant_id', None)
|
||||
with optional_ctx(
|
||||
subnet, self.subnet,
|
||||
set_context=set_context, tenant_id=tenant_id) as subnet_to_use:
|
||||
|
|
|
@ -78,6 +78,8 @@ class AddressScopeTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
|||
@contextlib.contextmanager
|
||||
def address_scope(self, ip_version=constants.IP_VERSION_4,
|
||||
admin=False, **kwargs):
|
||||
if 'project_id' in kwargs:
|
||||
kwargs['tenant_id'] = kwargs['project_id']
|
||||
addr_scope = self._make_address_scope(self.fmt, ip_version,
|
||||
admin, **kwargs)
|
||||
yield addr_scope
|
||||
|
|
|
@ -458,9 +458,11 @@ class L3NatTestCaseMixin(object):
|
|||
|
||||
@contextlib.contextmanager
|
||||
def router(self, name='router1', admin_state_up=True,
|
||||
fmt=None, tenant_id=None,
|
||||
fmt=None, project_id=None,
|
||||
external_gateway_info=None, set_context=False,
|
||||
**kwargs):
|
||||
tenant_id = project_id if project_id else kwargs.pop(
|
||||
'tenant_id', None)
|
||||
router = self._make_router(fmt or self.fmt, tenant_id, name,
|
||||
admin_state_up, external_gateway_info,
|
||||
set_context, **kwargs)
|
||||
|
@ -520,7 +522,9 @@ class L3NatTestCaseMixin(object):
|
|||
@contextlib.contextmanager
|
||||
def floatingip_with_assoc(self, port_id=None, fmt=None, fixed_ip=None,
|
||||
public_cidr='11.0.0.0/24', set_context=False,
|
||||
tenant_id=None, flavor_id=None, **kwargs):
|
||||
project_id=None, flavor_id=None, **kwargs):
|
||||
tenant_id = project_id if project_id else kwargs.pop(
|
||||
'tenant_id', None)
|
||||
with self.subnet(cidr=public_cidr,
|
||||
set_context=set_context,
|
||||
tenant_id=tenant_id) as public_sub:
|
||||
|
@ -566,6 +570,8 @@ class L3NatTestCaseMixin(object):
|
|||
def floatingip_no_assoc_with_public_sub(self, private_sub, fmt=None,
|
||||
set_context=False, public_sub=None,
|
||||
flavor_id=None, **kwargs):
|
||||
if 'project_id' in kwargs:
|
||||
kwargs['tenant_id'] = kwargs['project_id']
|
||||
self._set_net_external(public_sub['subnet']['network_id'])
|
||||
args_list = {}
|
||||
if flavor_id:
|
||||
|
@ -598,6 +604,8 @@ class L3NatTestCaseMixin(object):
|
|||
@contextlib.contextmanager
|
||||
def floatingip_no_assoc(self, private_sub, fmt=None,
|
||||
set_context=False, flavor_id=None, **kwargs):
|
||||
if 'project_id' in kwargs:
|
||||
kwargs['tenant_id'] = kwargs['project_id']
|
||||
with self.subnet(cidr='12.0.0.0/24') as public_sub:
|
||||
with self.floatingip_no_assoc_with_public_sub(
|
||||
private_sub, fmt, set_context, public_sub,
|
||||
|
|
|
@ -33,7 +33,9 @@ class SubnetOnboardTestsBase(object):
|
|||
@contextlib.contextmanager
|
||||
def address_scope(self, ip_version, prefixes=None, shared=False,
|
||||
admin=True, name='test-scope', is_default_pool=False,
|
||||
tenant_id=None, **kwargs):
|
||||
project_id=None, **kwargs):
|
||||
tenant_id = project_id if project_id else kwargs.get(
|
||||
'tenant_id', None)
|
||||
if not tenant_id:
|
||||
tenant_id = _uuid()
|
||||
|
||||
|
@ -46,8 +48,10 @@ class SubnetOnboardTestsBase(object):
|
|||
|
||||
@contextlib.contextmanager
|
||||
def subnetpool(self, ip_version, prefixes=None, shared=False, admin=True,
|
||||
name='test-pool', is_default_pool=False, tenant_id=None,
|
||||
name='test-pool', is_default_pool=False, project_id=None,
|
||||
address_scope_id=None, **kwargs):
|
||||
tenant_id = project_id if project_id else kwargs.get(
|
||||
'tenant_id', None)
|
||||
if not tenant_id:
|
||||
tenant_id = _uuid()
|
||||
pool_data = {'tenant_id': tenant_id, 'shared': shared, 'name': name,
|
||||
|
|
|
@ -32,7 +32,9 @@ class SubnetpoolPrefixOpsTestBase(object):
|
|||
@contextlib.contextmanager
|
||||
def address_scope(self, ip_version, prefixes=None, shared=False,
|
||||
admin=True, name='test-scope', is_default_pool=False,
|
||||
tenant_id=None, **kwargs):
|
||||
project_id=None, **kwargs):
|
||||
tenant_id = project_id if project_id else kwargs.get(
|
||||
'tenant_id', None)
|
||||
if not tenant_id:
|
||||
tenant_id = _uuid()
|
||||
|
||||
|
@ -45,8 +47,10 @@ class SubnetpoolPrefixOpsTestBase(object):
|
|||
|
||||
@contextlib.contextmanager
|
||||
def subnetpool(self, ip_version, prefixes=None, shared=False, admin=True,
|
||||
name='test-pool', is_default_pool=False, tenant_id=None,
|
||||
name='test-pool', is_default_pool=False, project_id=None,
|
||||
address_scope_id=None, **kwargs):
|
||||
tenant_id = project_id if project_id else kwargs.get(
|
||||
'tenant_id', None)
|
||||
if not tenant_id:
|
||||
tenant_id = _uuid()
|
||||
pool_data = {'tenant_id': tenant_id, 'shared': shared, 'name': name,
|
||||
|
|
Loading…
Reference in New Issue