Merge "Use instance variables for subnet tests"
This commit is contained in:
commit
e22fc1fb6b
@ -38,23 +38,25 @@ class TestSubnet(network_fakes.TestNetworkV2):
|
||||
|
||||
class TestCreateSubnet(TestSubnet):
|
||||
|
||||
project = identity_fakes_v3.FakeProject.create_one_project()
|
||||
domain = identity_fakes_v3.FakeDomain.create_one_domain()
|
||||
def _init_subnet_variables(self):
|
||||
self.project = identity_fakes_v3.FakeProject.create_one_project()
|
||||
self.domain = identity_fakes_v3.FakeDomain.create_one_domain()
|
||||
# An IPv4 subnet to be created with mostly default values
|
||||
_subnet = network_fakes.FakeSubnet.create_one_subnet(
|
||||
self._subnet = network_fakes.FakeSubnet.create_one_subnet(
|
||||
attrs={
|
||||
'tenant_id': project.id,
|
||||
'tenant_id': self.project.id,
|
||||
}
|
||||
)
|
||||
|
||||
# Subnet pool to be used to create a subnet from a pool
|
||||
_subnet_pool = network_fakes.FakeSubnetPool.create_one_subnet_pool()
|
||||
self._subnet_pool = \
|
||||
network_fakes.FakeSubnetPool.create_one_subnet_pool()
|
||||
|
||||
# An IPv4 subnet to be created using a specific subnet pool
|
||||
_subnet_from_pool = network_fakes.FakeSubnet.create_one_subnet(
|
||||
self._subnet_from_pool = network_fakes.FakeSubnet.create_one_subnet(
|
||||
attrs={
|
||||
'tenant_id': project.id,
|
||||
'subnetpool_id': _subnet_pool.id,
|
||||
'tenant_id': self.project.id,
|
||||
'subnetpool_id': self._subnet_pool.id,
|
||||
'dns_nameservers': ['8.8.8.8',
|
||||
'8.8.4.4'],
|
||||
'host_routes': [{'destination': '10.20.20.0/24',
|
||||
@ -67,9 +69,9 @@ class TestCreateSubnet(TestSubnet):
|
||||
)
|
||||
|
||||
# An IPv6 subnet to be created with most options specified
|
||||
_subnet_ipv6 = network_fakes.FakeSubnet.create_one_subnet(
|
||||
self._subnet_ipv6 = network_fakes.FakeSubnet.create_one_subnet(
|
||||
attrs={
|
||||
'tenant_id': project.id,
|
||||
'tenant_id': self.project.id,
|
||||
'cidr': 'fe80:0:0:a00a::/64',
|
||||
'enable_dhcp': True,
|
||||
'dns_nameservers': ['fe80:27ff:a00a:f00f::ffff',
|
||||
@ -93,21 +95,21 @@ class TestCreateSubnet(TestSubnet):
|
||||
)
|
||||
|
||||
# The network to be returned from find_network
|
||||
_network = network_fakes.FakeNetwork.create_one_network(
|
||||
self._network = network_fakes.FakeNetwork.create_one_network(
|
||||
attrs={
|
||||
'id': _subnet.network_id,
|
||||
'id': self._subnet.network_id,
|
||||
}
|
||||
)
|
||||
|
||||
# The network segment to be returned from find_segment
|
||||
_network_segment = \
|
||||
self._network_segment = \
|
||||
network_fakes.FakeNetworkSegment.create_one_network_segment(
|
||||
attrs={
|
||||
'network_id': _subnet.network_id,
|
||||
'network_id': self._subnet.network_id,
|
||||
}
|
||||
)
|
||||
|
||||
columns = (
|
||||
self.columns = (
|
||||
'allocation_pools',
|
||||
'cidr',
|
||||
'description',
|
||||
@ -128,70 +130,73 @@ class TestCreateSubnet(TestSubnet):
|
||||
'tags',
|
||||
)
|
||||
|
||||
data = (
|
||||
subnet_v2._format_allocation_pools(_subnet.allocation_pools),
|
||||
_subnet.cidr,
|
||||
_subnet.description,
|
||||
utils.format_list(_subnet.dns_nameservers),
|
||||
_subnet.enable_dhcp,
|
||||
_subnet.gateway_ip,
|
||||
subnet_v2._format_host_routes(_subnet.host_routes),
|
||||
_subnet.id,
|
||||
_subnet.ip_version,
|
||||
_subnet.ipv6_address_mode,
|
||||
_subnet.ipv6_ra_mode,
|
||||
_subnet.name,
|
||||
_subnet.network_id,
|
||||
_subnet.project_id,
|
||||
_subnet.segment_id,
|
||||
utils.format_list(_subnet.service_types),
|
||||
_subnet.subnetpool_id,
|
||||
utils.format_list(_subnet.tags),
|
||||
self.data = (
|
||||
subnet_v2._format_allocation_pools(self._subnet.allocation_pools),
|
||||
self._subnet.cidr,
|
||||
self._subnet.description,
|
||||
utils.format_list(self._subnet.dns_nameservers),
|
||||
self._subnet.enable_dhcp,
|
||||
self._subnet.gateway_ip,
|
||||
subnet_v2._format_host_routes(self._subnet.host_routes),
|
||||
self._subnet.id,
|
||||
self._subnet.ip_version,
|
||||
self._subnet.ipv6_address_mode,
|
||||
self._subnet.ipv6_ra_mode,
|
||||
self._subnet.name,
|
||||
self._subnet.network_id,
|
||||
self._subnet.project_id,
|
||||
self._subnet.segment_id,
|
||||
utils.format_list(self._subnet.service_types),
|
||||
self._subnet.subnetpool_id,
|
||||
utils.format_list(self._subnet.tags),
|
||||
)
|
||||
|
||||
data_subnet_pool = (
|
||||
subnet_v2._format_allocation_pools(_subnet_from_pool.allocation_pools),
|
||||
_subnet_from_pool.cidr,
|
||||
_subnet_from_pool.description,
|
||||
utils.format_list(_subnet_from_pool.dns_nameservers),
|
||||
_subnet_from_pool.enable_dhcp,
|
||||
_subnet_from_pool.gateway_ip,
|
||||
subnet_v2._format_host_routes(_subnet_from_pool.host_routes),
|
||||
_subnet_from_pool.id,
|
||||
_subnet_from_pool.ip_version,
|
||||
_subnet_from_pool.ipv6_address_mode,
|
||||
_subnet_from_pool.ipv6_ra_mode,
|
||||
_subnet_from_pool.name,
|
||||
_subnet_from_pool.network_id,
|
||||
_subnet_from_pool.project_id,
|
||||
_subnet_from_pool.segment_id,
|
||||
utils.format_list(_subnet_from_pool.service_types),
|
||||
_subnet_from_pool.subnetpool_id,
|
||||
utils.format_list(_subnet.tags),
|
||||
self.data_subnet_pool = (
|
||||
subnet_v2._format_allocation_pools(
|
||||
self._subnet_from_pool.allocation_pools),
|
||||
self._subnet_from_pool.cidr,
|
||||
self._subnet_from_pool.description,
|
||||
utils.format_list(self._subnet_from_pool.dns_nameservers),
|
||||
self._subnet_from_pool.enable_dhcp,
|
||||
self._subnet_from_pool.gateway_ip,
|
||||
subnet_v2._format_host_routes(self._subnet_from_pool.host_routes),
|
||||
self._subnet_from_pool.id,
|
||||
self._subnet_from_pool.ip_version,
|
||||
self._subnet_from_pool.ipv6_address_mode,
|
||||
self._subnet_from_pool.ipv6_ra_mode,
|
||||
self._subnet_from_pool.name,
|
||||
self._subnet_from_pool.network_id,
|
||||
self._subnet_from_pool.project_id,
|
||||
self._subnet_from_pool.segment_id,
|
||||
utils.format_list(self._subnet_from_pool.service_types),
|
||||
self._subnet_from_pool.subnetpool_id,
|
||||
utils.format_list(self._subnet.tags),
|
||||
)
|
||||
|
||||
data_ipv6 = (
|
||||
subnet_v2._format_allocation_pools(_subnet_ipv6.allocation_pools),
|
||||
_subnet_ipv6.cidr,
|
||||
_subnet_ipv6.description,
|
||||
utils.format_list(_subnet_ipv6.dns_nameservers),
|
||||
_subnet_ipv6.enable_dhcp,
|
||||
_subnet_ipv6.gateway_ip,
|
||||
subnet_v2._format_host_routes(_subnet_ipv6.host_routes),
|
||||
_subnet_ipv6.id,
|
||||
_subnet_ipv6.ip_version,
|
||||
_subnet_ipv6.ipv6_address_mode,
|
||||
_subnet_ipv6.ipv6_ra_mode,
|
||||
_subnet_ipv6.name,
|
||||
_subnet_ipv6.network_id,
|
||||
_subnet_ipv6.project_id,
|
||||
_subnet_ipv6.segment_id,
|
||||
utils.format_list(_subnet_ipv6.service_types),
|
||||
_subnet_ipv6.subnetpool_id,
|
||||
utils.format_list(_subnet.tags),
|
||||
self.data_ipv6 = (
|
||||
subnet_v2._format_allocation_pools(
|
||||
self._subnet_ipv6.allocation_pools),
|
||||
self._subnet_ipv6.cidr,
|
||||
self._subnet_ipv6.description,
|
||||
utils.format_list(self._subnet_ipv6.dns_nameservers),
|
||||
self._subnet_ipv6.enable_dhcp,
|
||||
self._subnet_ipv6.gateway_ip,
|
||||
subnet_v2._format_host_routes(self._subnet_ipv6.host_routes),
|
||||
self._subnet_ipv6.id,
|
||||
self._subnet_ipv6.ip_version,
|
||||
self._subnet_ipv6.ipv6_address_mode,
|
||||
self._subnet_ipv6.ipv6_ra_mode,
|
||||
self._subnet_ipv6.name,
|
||||
self._subnet_ipv6.network_id,
|
||||
self._subnet_ipv6.project_id,
|
||||
self._subnet_ipv6.segment_id,
|
||||
utils.format_list(self._subnet_ipv6.service_types),
|
||||
self._subnet_ipv6.subnetpool_id,
|
||||
utils.format_list(self._subnet.tags),
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
self._init_subnet_variables()
|
||||
super(TestCreateSubnet, self).setUp()
|
||||
|
||||
# Get the command object to test
|
||||
|
Loading…
x
Reference in New Issue
Block a user