Refactor network fakes to sdk properties PART 1
Included resources: address_group address_scope auto_allocated_topology availability_zone Change-Id: I943f988588efbe68dd3ab17a18441b25ac8c8d4d
This commit is contained in:
parent
c9b84106c3
commit
23ad68264b
openstackclient
@ -29,7 +29,7 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
def _get_columns(item):
|
def _get_columns(item):
|
||||||
column_map = {}
|
column_map = {}
|
||||||
hidden_columns = ['location']
|
hidden_columns = ['location', 'tenant_id']
|
||||||
return utils.get_osc_show_columns_for_sdk_resource(
|
return utils.get_osc_show_columns_for_sdk_resource(
|
||||||
item,
|
item,
|
||||||
column_map,
|
column_map,
|
||||||
|
@ -30,7 +30,7 @@ def _get_columns(item):
|
|||||||
column_map = {
|
column_map = {
|
||||||
'is_shared': 'shared',
|
'is_shared': 'shared',
|
||||||
}
|
}
|
||||||
hidden_columns = ['location']
|
hidden_columns = ['location', 'tenant_id']
|
||||||
return utils.get_osc_show_columns_for_sdk_resource(
|
return utils.get_osc_show_columns_for_sdk_resource(
|
||||||
item,
|
item,
|
||||||
column_map,
|
column_map,
|
||||||
|
@ -26,7 +26,7 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
def _get_columns(item):
|
def _get_columns(item):
|
||||||
column_map = {}
|
column_map = {}
|
||||||
hidden_columns = ['location']
|
hidden_columns = ['name', 'location', 'tenant_id']
|
||||||
return utils.get_osc_show_columns_for_sdk_resource(
|
return utils.get_osc_show_columns_for_sdk_resource(
|
||||||
item,
|
item,
|
||||||
column_map,
|
column_map,
|
||||||
|
@ -115,8 +115,7 @@ class TestAvailabilityZoneList(TestAvailabilityZone):
|
|||||||
compute_fakes.FakeAvailabilityZone.create_availability_zones()
|
compute_fakes.FakeAvailabilityZone.create_availability_zones()
|
||||||
volume_azs = \
|
volume_azs = \
|
||||||
volume_fakes.FakeAvailabilityZone.create_availability_zones(count=1)
|
volume_fakes.FakeAvailabilityZone.create_availability_zones(count=1)
|
||||||
network_azs = \
|
network_azs = network_fakes.create_availability_zones()
|
||||||
network_fakes.FakeAvailabilityZone.create_availability_zones()
|
|
||||||
|
|
||||||
short_columnslist = ('Zone Name', 'Zone Status')
|
short_columnslist = ('Zone Name', 'Zone Status')
|
||||||
long_columnslist = (
|
long_columnslist = (
|
||||||
|
@ -18,6 +18,10 @@ from random import randint
|
|||||||
from unittest import mock
|
from unittest import mock
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
from openstack.network.v2 import address_group as _address_group
|
||||||
|
from openstack.network.v2 import address_scope as _address_scope
|
||||||
|
from openstack.network.v2 import auto_allocated_topology as allocated_topology
|
||||||
|
from openstack.network.v2 import availability_zone as _availability_zone
|
||||||
from openstack.network.v2 import local_ip as _local_ip
|
from openstack.network.v2 import local_ip as _local_ip
|
||||||
from openstack.network.v2 import local_ip_association as _local_ip_association
|
from openstack.network.v2 import local_ip_association as _local_ip_association
|
||||||
|
|
||||||
@ -86,221 +90,6 @@ class TestNetworkV2(utils.TestCommand):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class FakeAddressGroup(object):
|
|
||||||
"""Fake one or more address groups."""
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def create_one_address_group(attrs=None):
|
|
||||||
"""Create a fake address group.
|
|
||||||
|
|
||||||
:param Dictionary attrs:
|
|
||||||
A dictionary with all attributes
|
|
||||||
:return:
|
|
||||||
A FakeResource object with name, id, etc.
|
|
||||||
"""
|
|
||||||
attrs = attrs or {}
|
|
||||||
|
|
||||||
# Set default attributes.
|
|
||||||
address_group_attrs = {
|
|
||||||
'name': 'address-group-name-' + uuid.uuid4().hex,
|
|
||||||
'description': 'address-group-description-' + uuid.uuid4().hex,
|
|
||||||
'id': 'address-group-id-' + uuid.uuid4().hex,
|
|
||||||
'project_id': 'project-id-' + uuid.uuid4().hex,
|
|
||||||
'addresses': ['10.0.0.1/32'],
|
|
||||||
'location': 'MUNCHMUNCHMUNCH',
|
|
||||||
}
|
|
||||||
|
|
||||||
# Overwrite default attributes.
|
|
||||||
address_group_attrs.update(attrs)
|
|
||||||
|
|
||||||
address_group = fakes.FakeResource(
|
|
||||||
info=copy.deepcopy(address_group_attrs),
|
|
||||||
loaded=True)
|
|
||||||
|
|
||||||
return address_group
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def create_address_groups(attrs=None, count=2):
|
|
||||||
"""Create multiple fake address groups.
|
|
||||||
|
|
||||||
:param Dictionary attrs:
|
|
||||||
A dictionary with all attributes
|
|
||||||
:param int count:
|
|
||||||
The number of address groups to fake
|
|
||||||
:return:
|
|
||||||
A list of FakeResource objects faking the address groups
|
|
||||||
"""
|
|
||||||
address_groups = []
|
|
||||||
for i in range(0, count):
|
|
||||||
address_groups.append(
|
|
||||||
FakeAddressGroup.create_one_address_group(attrs))
|
|
||||||
|
|
||||||
return address_groups
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_address_groups(address_groups=None, count=2):
|
|
||||||
"""Get an iterable Mock object with a list of faked address groups.
|
|
||||||
|
|
||||||
If address groups list is provided, then initialize the Mock object
|
|
||||||
with the list. Otherwise create one.
|
|
||||||
|
|
||||||
:param List address_groups:
|
|
||||||
A list of FakeResource objects faking address groups
|
|
||||||
:param int count:
|
|
||||||
The number of address groups to fake
|
|
||||||
:return:
|
|
||||||
An iterable Mock object with side_effect set to a list of faked
|
|
||||||
address groups
|
|
||||||
"""
|
|
||||||
if address_groups is None:
|
|
||||||
address_groups = FakeAddressGroup.create_address_groups(count)
|
|
||||||
return mock.Mock(side_effect=address_groups)
|
|
||||||
|
|
||||||
|
|
||||||
class FakeAddressScope(object):
|
|
||||||
"""Fake one or more address scopes."""
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def create_one_address_scope(attrs=None):
|
|
||||||
"""Create a fake address scope.
|
|
||||||
|
|
||||||
:param Dictionary attrs:
|
|
||||||
A dictionary with all attributes
|
|
||||||
:return:
|
|
||||||
A FakeResource object with name, id, etc.
|
|
||||||
"""
|
|
||||||
attrs = attrs or {}
|
|
||||||
|
|
||||||
# Set default attributes.
|
|
||||||
address_scope_attrs = {
|
|
||||||
'name': 'address-scope-name-' + uuid.uuid4().hex,
|
|
||||||
'id': 'address-scope-id-' + uuid.uuid4().hex,
|
|
||||||
'project_id': 'project-id-' + uuid.uuid4().hex,
|
|
||||||
'shared': False,
|
|
||||||
'ip_version': 4,
|
|
||||||
'location': 'MUNCHMUNCHMUNCH',
|
|
||||||
}
|
|
||||||
|
|
||||||
# Overwrite default attributes.
|
|
||||||
address_scope_attrs.update(attrs)
|
|
||||||
|
|
||||||
address_scope = fakes.FakeResource(
|
|
||||||
info=copy.deepcopy(address_scope_attrs),
|
|
||||||
loaded=True)
|
|
||||||
|
|
||||||
# Set attributes with special mapping in OpenStack SDK.
|
|
||||||
address_scope.is_shared = address_scope_attrs['shared']
|
|
||||||
|
|
||||||
return address_scope
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def create_address_scopes(attrs=None, count=2):
|
|
||||||
"""Create multiple fake address scopes.
|
|
||||||
|
|
||||||
:param Dictionary attrs:
|
|
||||||
A dictionary with all attributes
|
|
||||||
:param int count:
|
|
||||||
The number of address scopes to fake
|
|
||||||
:return:
|
|
||||||
A list of FakeResource objects faking the address scopes
|
|
||||||
"""
|
|
||||||
address_scopes = []
|
|
||||||
for i in range(0, count):
|
|
||||||
address_scopes.append(
|
|
||||||
FakeAddressScope.create_one_address_scope(attrs))
|
|
||||||
|
|
||||||
return address_scopes
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_address_scopes(address_scopes=None, count=2):
|
|
||||||
"""Get an iterable Mock object with a list of faked address scopes.
|
|
||||||
|
|
||||||
If address scopes list is provided, then initialize the Mock object
|
|
||||||
with the list. Otherwise create one.
|
|
||||||
|
|
||||||
:param List address_scopes:
|
|
||||||
A list of FakeResource objects faking address scopes
|
|
||||||
:param int count:
|
|
||||||
The number of address scopes to fake
|
|
||||||
:return:
|
|
||||||
An iterable Mock object with side_effect set to a list of faked
|
|
||||||
address scopes
|
|
||||||
"""
|
|
||||||
if address_scopes is None:
|
|
||||||
address_scopes = FakeAddressScope.create_address_scopes(count)
|
|
||||||
return mock.Mock(side_effect=address_scopes)
|
|
||||||
|
|
||||||
|
|
||||||
class FakeAutoAllocatedTopology(object):
|
|
||||||
"""Fake Auto Allocated Topology"""
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def create_one_topology(attrs=None):
|
|
||||||
attrs = attrs or {}
|
|
||||||
|
|
||||||
auto_allocated_topology_attrs = {
|
|
||||||
'id': 'network-id-' + uuid.uuid4().hex,
|
|
||||||
'project_id': 'project-id-' + uuid.uuid4().hex,
|
|
||||||
}
|
|
||||||
|
|
||||||
auto_allocated_topology_attrs.update(attrs)
|
|
||||||
|
|
||||||
auto_allocated_topology = fakes.FakeResource(
|
|
||||||
info=copy.deepcopy(auto_allocated_topology_attrs),
|
|
||||||
loaded=True)
|
|
||||||
|
|
||||||
return auto_allocated_topology
|
|
||||||
|
|
||||||
|
|
||||||
class FakeAvailabilityZone(object):
|
|
||||||
"""Fake one or more network availability zones (AZs)."""
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def create_one_availability_zone(attrs=None):
|
|
||||||
"""Create a fake AZ.
|
|
||||||
|
|
||||||
:param Dictionary attrs:
|
|
||||||
A dictionary with all attributes
|
|
||||||
:return:
|
|
||||||
A FakeResource object with name, state, etc.
|
|
||||||
"""
|
|
||||||
attrs = attrs or {}
|
|
||||||
|
|
||||||
# Set default attributes.
|
|
||||||
availability_zone = {
|
|
||||||
'name': uuid.uuid4().hex,
|
|
||||||
'state': 'available',
|
|
||||||
'resource': 'network',
|
|
||||||
}
|
|
||||||
|
|
||||||
# Overwrite default attributes.
|
|
||||||
availability_zone.update(attrs)
|
|
||||||
|
|
||||||
availability_zone = fakes.FakeResource(
|
|
||||||
info=copy.deepcopy(availability_zone),
|
|
||||||
loaded=True)
|
|
||||||
return availability_zone
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def create_availability_zones(attrs=None, count=2):
|
|
||||||
"""Create multiple fake AZs.
|
|
||||||
|
|
||||||
:param Dictionary attrs:
|
|
||||||
A dictionary with all attributes
|
|
||||||
:param int count:
|
|
||||||
The number of AZs to fake
|
|
||||||
:return:
|
|
||||||
A list of FakeResource objects faking the AZs
|
|
||||||
"""
|
|
||||||
availability_zones = []
|
|
||||||
for i in range(0, count):
|
|
||||||
availability_zone = \
|
|
||||||
FakeAvailabilityZone.create_one_availability_zone(attrs)
|
|
||||||
availability_zones.append(availability_zone)
|
|
||||||
|
|
||||||
return availability_zones
|
|
||||||
|
|
||||||
|
|
||||||
class FakeIPAvailability(object):
|
class FakeIPAvailability(object):
|
||||||
"""Fake one or more network ip availabilities."""
|
"""Fake one or more network ip availabilities."""
|
||||||
|
|
||||||
@ -2038,6 +1827,198 @@ class FakeL3ConntrackHelper(object):
|
|||||||
return mock.Mock(side_effect=ct_helpers)
|
return mock.Mock(side_effect=ct_helpers)
|
||||||
|
|
||||||
|
|
||||||
|
def create_one_address_group(attrs=None):
|
||||||
|
"""Create a fake address group.
|
||||||
|
|
||||||
|
:param Dictionary attrs:
|
||||||
|
A dictionary with all attributes
|
||||||
|
:return:
|
||||||
|
An AddressGroup object with name, id, etc.
|
||||||
|
"""
|
||||||
|
attrs = attrs or {}
|
||||||
|
|
||||||
|
# Set default attributes.
|
||||||
|
address_group_attrs = {
|
||||||
|
'name': 'address-group-name-' + uuid.uuid4().hex,
|
||||||
|
'description': 'address-group-description-' + uuid.uuid4().hex,
|
||||||
|
'id': 'address-group-id-' + uuid.uuid4().hex,
|
||||||
|
'project_id': 'project-id-' + uuid.uuid4().hex,
|
||||||
|
'addresses': ['10.0.0.1/32'],
|
||||||
|
'location': 'MUNCHMUNCHMUNCH',
|
||||||
|
}
|
||||||
|
|
||||||
|
# Overwrite default attributes.
|
||||||
|
address_group_attrs.update(attrs)
|
||||||
|
|
||||||
|
address_group = _address_group.AddressGroup(**address_group_attrs)
|
||||||
|
|
||||||
|
return address_group
|
||||||
|
|
||||||
|
|
||||||
|
def create_address_groups(attrs=None, count=2):
|
||||||
|
"""Create multiple fake address groups.
|
||||||
|
|
||||||
|
:param Dictionary attrs:
|
||||||
|
A dictionary with all attributes
|
||||||
|
:param int count:
|
||||||
|
The number of address groups to fake
|
||||||
|
:return:
|
||||||
|
A list of AddressGroup objects faking the address groups
|
||||||
|
"""
|
||||||
|
address_groups = []
|
||||||
|
for i in range(0, count):
|
||||||
|
address_groups.append(create_one_address_group(attrs))
|
||||||
|
|
||||||
|
return address_groups
|
||||||
|
|
||||||
|
|
||||||
|
def get_address_groups(address_groups=None, count=2):
|
||||||
|
"""Get an iterable Mock object with a list of faked address groups.
|
||||||
|
|
||||||
|
If address groups list is provided, then initialize the Mock object
|
||||||
|
with the list. Otherwise create one.
|
||||||
|
|
||||||
|
:param List address_groups:
|
||||||
|
A list of FakeResource objects faking address groups
|
||||||
|
:param int count:
|
||||||
|
The number of address groups to fake
|
||||||
|
:return:
|
||||||
|
An iterable Mock object with side_effect set to a list of faked
|
||||||
|
AddressGroup objects
|
||||||
|
"""
|
||||||
|
if address_groups is None:
|
||||||
|
address_groups = create_address_groups(count)
|
||||||
|
return mock.Mock(side_effect=address_groups)
|
||||||
|
|
||||||
|
|
||||||
|
def create_one_address_scope(attrs=None):
|
||||||
|
"""Create a fake address scope.
|
||||||
|
|
||||||
|
:param Dictionary attrs:
|
||||||
|
A dictionary with all attributes
|
||||||
|
:return:
|
||||||
|
An AddressScope object with name, id, etc.
|
||||||
|
"""
|
||||||
|
attrs = attrs or {}
|
||||||
|
|
||||||
|
# Set default attributes.
|
||||||
|
address_scope_attrs = {
|
||||||
|
'name': 'address-scope-name-' + uuid.uuid4().hex,
|
||||||
|
'id': 'address-scope-id-' + uuid.uuid4().hex,
|
||||||
|
'project_id': 'project-id-' + uuid.uuid4().hex,
|
||||||
|
'shared': False,
|
||||||
|
'ip_version': 4,
|
||||||
|
'location': 'MUNCHMUNCHMUNCH',
|
||||||
|
}
|
||||||
|
|
||||||
|
# Overwrite default attributes.
|
||||||
|
address_scope_attrs.update(attrs)
|
||||||
|
|
||||||
|
address_scope = _address_scope.AddressScope(**address_scope_attrs)
|
||||||
|
|
||||||
|
# Set attributes with special mapping in OpenStack SDK.
|
||||||
|
address_scope.is_shared = address_scope_attrs['shared']
|
||||||
|
|
||||||
|
return address_scope
|
||||||
|
|
||||||
|
|
||||||
|
def create_address_scopes(attrs=None, count=2):
|
||||||
|
"""Create multiple fake address scopes.
|
||||||
|
|
||||||
|
:param Dictionary attrs:
|
||||||
|
A dictionary with all attributes
|
||||||
|
:param int count:
|
||||||
|
The number of address scopes to fake
|
||||||
|
:return:
|
||||||
|
A list of AddressScope objects faking the address scopes
|
||||||
|
"""
|
||||||
|
address_scopes = []
|
||||||
|
for i in range(0, count):
|
||||||
|
address_scopes.append(create_one_address_scope(attrs))
|
||||||
|
|
||||||
|
return address_scopes
|
||||||
|
|
||||||
|
|
||||||
|
def get_address_scopes(address_scopes=None, count=2):
|
||||||
|
"""Get an iterable Mock object with a list of faked address scopes.
|
||||||
|
|
||||||
|
If address scopes list is provided, then initialize the Mock object
|
||||||
|
with the list. Otherwise create one.
|
||||||
|
|
||||||
|
:param List address_scopes:
|
||||||
|
A list of FakeResource objects faking address scopes
|
||||||
|
:param int count:
|
||||||
|
The number of address scopes to fake
|
||||||
|
:return:
|
||||||
|
An iterable Mock object with side_effect set to a list of faked
|
||||||
|
AddressScope objects
|
||||||
|
"""
|
||||||
|
if address_scopes is None:
|
||||||
|
address_scopes = create_address_scopes(count)
|
||||||
|
return mock.Mock(side_effect=address_scopes)
|
||||||
|
|
||||||
|
|
||||||
|
def create_one_topology(attrs=None):
|
||||||
|
attrs = attrs or {}
|
||||||
|
|
||||||
|
auto_allocated_topology_attrs = {
|
||||||
|
'id': 'network-id-' + uuid.uuid4().hex,
|
||||||
|
'project_id': 'project-id-' + uuid.uuid4().hex,
|
||||||
|
}
|
||||||
|
|
||||||
|
auto_allocated_topology_attrs.update(attrs)
|
||||||
|
|
||||||
|
auto_allocated_topology = allocated_topology.AutoAllocatedTopology(
|
||||||
|
**auto_allocated_topology_attrs
|
||||||
|
)
|
||||||
|
|
||||||
|
return auto_allocated_topology
|
||||||
|
|
||||||
|
|
||||||
|
def create_one_availability_zone(attrs=None):
|
||||||
|
"""Create a fake AZ.
|
||||||
|
|
||||||
|
:param Dictionary attrs:
|
||||||
|
A dictionary with all attributes
|
||||||
|
:return:
|
||||||
|
An AvailabilityZone object with name, state, etc.
|
||||||
|
"""
|
||||||
|
attrs = attrs or {}
|
||||||
|
|
||||||
|
# Set default attributes.
|
||||||
|
availability_zone = {
|
||||||
|
'name': uuid.uuid4().hex,
|
||||||
|
'state': 'available',
|
||||||
|
'resource': 'network',
|
||||||
|
}
|
||||||
|
|
||||||
|
# Overwrite default attributes.
|
||||||
|
availability_zone.update(attrs)
|
||||||
|
|
||||||
|
availability_zone = _availability_zone.AvailabilityZone(
|
||||||
|
**availability_zone
|
||||||
|
)
|
||||||
|
return availability_zone
|
||||||
|
|
||||||
|
|
||||||
|
def create_availability_zones(attrs=None, count=2):
|
||||||
|
"""Create multiple fake AZs.
|
||||||
|
|
||||||
|
:param Dictionary attrs:
|
||||||
|
A dictionary with all attributes
|
||||||
|
:param int count:
|
||||||
|
The number of AZs to fake
|
||||||
|
:return:
|
||||||
|
A list of AvailabilityZone objects faking the AZs
|
||||||
|
"""
|
||||||
|
availability_zones = []
|
||||||
|
for i in range(0, count):
|
||||||
|
availability_zone = create_one_availability_zone(attrs)
|
||||||
|
availability_zones.append(availability_zone)
|
||||||
|
|
||||||
|
return availability_zones
|
||||||
|
|
||||||
|
|
||||||
def create_one_local_ip(attrs=None):
|
def create_one_local_ip(attrs=None):
|
||||||
"""Create a fake local ip.
|
"""Create a fake local ip.
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class TestCreateAddressGroup(TestAddressGroup):
|
|||||||
domain = identity_fakes_v3.FakeDomain.create_one_domain()
|
domain = identity_fakes_v3.FakeDomain.create_one_domain()
|
||||||
# The new address group created.
|
# The new address group created.
|
||||||
new_address_group = (
|
new_address_group = (
|
||||||
network_fakes.FakeAddressGroup.create_one_address_group(
|
network_fakes.create_one_address_group(
|
||||||
attrs={
|
attrs={
|
||||||
'project_id': project.id,
|
'project_id': project.id,
|
||||||
}
|
}
|
||||||
@ -133,16 +133,13 @@ class TestCreateAddressGroup(TestAddressGroup):
|
|||||||
class TestDeleteAddressGroup(TestAddressGroup):
|
class TestDeleteAddressGroup(TestAddressGroup):
|
||||||
|
|
||||||
# The address group to delete.
|
# The address group to delete.
|
||||||
_address_groups = (
|
_address_groups = network_fakes.create_address_groups(count=2)
|
||||||
network_fakes.FakeAddressGroup.create_address_groups(count=2))
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestDeleteAddressGroup, self).setUp()
|
super(TestDeleteAddressGroup, self).setUp()
|
||||||
self.network.delete_address_group = mock.Mock(return_value=None)
|
self.network.delete_address_group = mock.Mock(return_value=None)
|
||||||
self.network.find_address_group = (
|
self.network.find_address_group = network_fakes.get_address_groups(
|
||||||
network_fakes.FakeAddressGroup.get_address_groups(
|
address_groups=self._address_groups)
|
||||||
address_groups=self._address_groups)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Get the command object to test
|
# Get the command object to test
|
||||||
self.cmd = address_group.DeleteAddressGroup(self.app, self.namespace)
|
self.cmd = address_group.DeleteAddressGroup(self.app, self.namespace)
|
||||||
@ -216,8 +213,7 @@ class TestDeleteAddressGroup(TestAddressGroup):
|
|||||||
class TestListAddressGroup(TestAddressGroup):
|
class TestListAddressGroup(TestAddressGroup):
|
||||||
|
|
||||||
# The address groups to list up.
|
# The address groups to list up.
|
||||||
address_groups = (
|
address_groups = network_fakes.create_address_groups(count=3)
|
||||||
network_fakes.FakeAddressGroup.create_address_groups(count=3))
|
|
||||||
columns = (
|
columns = (
|
||||||
'ID',
|
'ID',
|
||||||
'Name',
|
'Name',
|
||||||
@ -308,7 +304,7 @@ class TestListAddressGroup(TestAddressGroup):
|
|||||||
class TestSetAddressGroup(TestAddressGroup):
|
class TestSetAddressGroup(TestAddressGroup):
|
||||||
|
|
||||||
# The address group to set.
|
# The address group to set.
|
||||||
_address_group = network_fakes.FakeAddressGroup.create_one_address_group()
|
_address_group = network_fakes.create_one_address_group()
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestSetAddressGroup, self).setUp()
|
super(TestSetAddressGroup, self).setUp()
|
||||||
@ -392,7 +388,7 @@ class TestSetAddressGroup(TestAddressGroup):
|
|||||||
class TestShowAddressGroup(TestAddressGroup):
|
class TestShowAddressGroup(TestAddressGroup):
|
||||||
|
|
||||||
# The address group to show.
|
# The address group to show.
|
||||||
_address_group = network_fakes.FakeAddressGroup.create_one_address_group()
|
_address_group = network_fakes.create_one_address_group()
|
||||||
columns = (
|
columns = (
|
||||||
'addresses',
|
'addresses',
|
||||||
'description',
|
'description',
|
||||||
@ -444,7 +440,7 @@ class TestShowAddressGroup(TestAddressGroup):
|
|||||||
class TestUnsetAddressGroup(TestAddressGroup):
|
class TestUnsetAddressGroup(TestAddressGroup):
|
||||||
|
|
||||||
# The address group to unset.
|
# The address group to unset.
|
||||||
_address_group = network_fakes.FakeAddressGroup.create_one_address_group()
|
_address_group = network_fakes.create_one_address_group()
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestUnsetAddressGroup, self).setUp()
|
super(TestUnsetAddressGroup, self).setUp()
|
||||||
|
@ -40,12 +40,10 @@ class TestCreateAddressScope(TestAddressScope):
|
|||||||
project = identity_fakes_v3.FakeProject.create_one_project()
|
project = identity_fakes_v3.FakeProject.create_one_project()
|
||||||
domain = identity_fakes_v3.FakeDomain.create_one_domain()
|
domain = identity_fakes_v3.FakeDomain.create_one_domain()
|
||||||
# The new address scope created.
|
# The new address scope created.
|
||||||
new_address_scope = (
|
new_address_scope = network_fakes.create_one_address_scope(
|
||||||
network_fakes.FakeAddressScope.create_one_address_scope(
|
attrs={
|
||||||
attrs={
|
'project_id': project.id,
|
||||||
'project_id': project.id,
|
})
|
||||||
}
|
|
||||||
))
|
|
||||||
columns = (
|
columns = (
|
||||||
'id',
|
'id',
|
||||||
'ip_version',
|
'ip_version',
|
||||||
@ -58,7 +56,7 @@ class TestCreateAddressScope(TestAddressScope):
|
|||||||
new_address_scope.ip_version,
|
new_address_scope.ip_version,
|
||||||
new_address_scope.name,
|
new_address_scope.name,
|
||||||
new_address_scope.project_id,
|
new_address_scope.project_id,
|
||||||
new_address_scope.shared,
|
new_address_scope.is_shared,
|
||||||
)
|
)
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -153,16 +151,13 @@ class TestCreateAddressScope(TestAddressScope):
|
|||||||
class TestDeleteAddressScope(TestAddressScope):
|
class TestDeleteAddressScope(TestAddressScope):
|
||||||
|
|
||||||
# The address scope to delete.
|
# The address scope to delete.
|
||||||
_address_scopes = (
|
_address_scopes = network_fakes.create_address_scopes(count=2)
|
||||||
network_fakes.FakeAddressScope.create_address_scopes(count=2))
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestDeleteAddressScope, self).setUp()
|
super(TestDeleteAddressScope, self).setUp()
|
||||||
self.network.delete_address_scope = mock.Mock(return_value=None)
|
self.network.delete_address_scope = mock.Mock(return_value=None)
|
||||||
self.network.find_address_scope = (
|
self.network.find_address_scope = network_fakes.get_address_scopes(
|
||||||
network_fakes.FakeAddressScope.get_address_scopes(
|
address_scopes=self._address_scopes)
|
||||||
address_scopes=self._address_scopes)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Get the command object to test
|
# Get the command object to test
|
||||||
self.cmd = address_scope.DeleteAddressScope(self.app, self.namespace)
|
self.cmd = address_scope.DeleteAddressScope(self.app, self.namespace)
|
||||||
@ -237,8 +232,7 @@ class TestDeleteAddressScope(TestAddressScope):
|
|||||||
class TestListAddressScope(TestAddressScope):
|
class TestListAddressScope(TestAddressScope):
|
||||||
|
|
||||||
# The address scopes to list up.
|
# The address scopes to list up.
|
||||||
address_scopes = (
|
address_scopes = network_fakes.create_address_scopes(count=3)
|
||||||
network_fakes.FakeAddressScope.create_address_scopes(count=3))
|
|
||||||
columns = (
|
columns = (
|
||||||
'ID',
|
'ID',
|
||||||
'Name',
|
'Name',
|
||||||
@ -252,7 +246,7 @@ class TestListAddressScope(TestAddressScope):
|
|||||||
scope.id,
|
scope.id,
|
||||||
scope.name,
|
scope.name,
|
||||||
scope.ip_version,
|
scope.ip_version,
|
||||||
scope.shared,
|
scope.is_shared,
|
||||||
scope.project_id,
|
scope.project_id,
|
||||||
))
|
))
|
||||||
|
|
||||||
@ -377,7 +371,7 @@ class TestListAddressScope(TestAddressScope):
|
|||||||
class TestSetAddressScope(TestAddressScope):
|
class TestSetAddressScope(TestAddressScope):
|
||||||
|
|
||||||
# The address scope to set.
|
# The address scope to set.
|
||||||
_address_scope = network_fakes.FakeAddressScope.create_one_address_scope()
|
_address_scope = network_fakes.create_one_address_scope()
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestSetAddressScope, self).setUp()
|
super(TestSetAddressScope, self).setUp()
|
||||||
@ -448,7 +442,7 @@ class TestShowAddressScope(TestAddressScope):
|
|||||||
|
|
||||||
# The address scope to show.
|
# The address scope to show.
|
||||||
_address_scope = (
|
_address_scope = (
|
||||||
network_fakes.FakeAddressScope.create_one_address_scope())
|
network_fakes.create_one_address_scope())
|
||||||
columns = (
|
columns = (
|
||||||
'id',
|
'id',
|
||||||
'ip_version',
|
'ip_version',
|
||||||
@ -461,7 +455,7 @@ class TestShowAddressScope(TestAddressScope):
|
|||||||
_address_scope.ip_version,
|
_address_scope.ip_version,
|
||||||
_address_scope.name,
|
_address_scope.name,
|
||||||
_address_scope.project_id,
|
_address_scope.project_id,
|
||||||
_address_scope.shared,
|
_address_scope.is_shared,
|
||||||
)
|
)
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -31,7 +31,7 @@ class TestCreateAutoAllocatedTopology(TestAutoAllocatedTopology):
|
|||||||
project = identity_fakes.FakeProject.create_one_project()
|
project = identity_fakes.FakeProject.create_one_project()
|
||||||
network_object = network_fakes.FakeNetwork.create_one_network()
|
network_object = network_fakes.FakeNetwork.create_one_network()
|
||||||
|
|
||||||
topology = network_fakes.FakeAutoAllocatedTopology.create_one_topology(
|
topology = network_fakes.create_one_topology(
|
||||||
attrs={'id': network_object.id,
|
attrs={'id': network_object.id,
|
||||||
'project_id': project.id}
|
'project_id': project.id}
|
||||||
)
|
)
|
||||||
@ -129,7 +129,7 @@ class TestValidateAutoAllocatedTopology(TestAutoAllocatedTopology):
|
|||||||
project = identity_fakes.FakeProject.create_one_project()
|
project = identity_fakes.FakeProject.create_one_project()
|
||||||
network_object = network_fakes.FakeNetwork.create_one_network()
|
network_object = network_fakes.FakeNetwork.create_one_network()
|
||||||
|
|
||||||
topology = network_fakes.FakeAutoAllocatedTopology.create_one_topology(
|
topology = network_fakes.create_one_topology(
|
||||||
attrs={'id': network_object.id,
|
attrs={'id': network_object.id,
|
||||||
'project_id': project.id}
|
'project_id': project.id}
|
||||||
)
|
)
|
||||||
@ -206,7 +206,7 @@ class TestDeleteAutoAllocatedTopology(TestAutoAllocatedTopology):
|
|||||||
project = identity_fakes.FakeProject.create_one_project()
|
project = identity_fakes.FakeProject.create_one_project()
|
||||||
network_object = network_fakes.FakeNetwork.create_one_network()
|
network_object = network_fakes.FakeNetwork.create_one_network()
|
||||||
|
|
||||||
topology = network_fakes.FakeAutoAllocatedTopology.create_one_topology(
|
topology = network_fakes.create_one_topology(
|
||||||
attrs={'id': network_object.id,
|
attrs={'id': network_object.id,
|
||||||
'project_id': project.id}
|
'project_id': project.id}
|
||||||
)
|
)
|
||||||
|
@ -40,9 +40,9 @@ class TestCreateNetworkRBAC(TestNetworkRBAC):
|
|||||||
network_object = network_fakes.FakeNetwork.create_one_network()
|
network_object = network_fakes.FakeNetwork.create_one_network()
|
||||||
qos_object = network_fakes.FakeNetworkQosPolicy.create_one_qos_policy()
|
qos_object = network_fakes.FakeNetworkQosPolicy.create_one_qos_policy()
|
||||||
sg_object = network_fakes.FakeNetworkSecGroup.create_one_security_group()
|
sg_object = network_fakes.FakeNetworkSecGroup.create_one_security_group()
|
||||||
as_object = network_fakes.FakeAddressScope.create_one_address_scope()
|
as_object = network_fakes.create_one_address_scope()
|
||||||
snp_object = network_fakes.FakeSubnetPool.create_one_subnet_pool()
|
snp_object = network_fakes.FakeSubnetPool.create_one_subnet_pool()
|
||||||
ag_object = network_fakes.FakeAddressGroup.create_one_address_group()
|
ag_object = network_fakes.create_one_address_group()
|
||||||
project = identity_fakes_v3.FakeProject.create_one_project()
|
project = identity_fakes_v3.FakeProject.create_one_project()
|
||||||
rbac_policy = network_fakes.FakeNetworkRBAC.create_one_network_rbac(
|
rbac_policy = network_fakes.FakeNetworkRBAC.create_one_network_rbac(
|
||||||
attrs={'project_id': project.id,
|
attrs={'project_id': project.id,
|
||||||
|
@ -47,7 +47,7 @@ class TestCreateSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork):
|
|||||||
network_fakes.FakeSecurityGroup.create_one_security_group()
|
network_fakes.FakeSecurityGroup.create_one_security_group()
|
||||||
|
|
||||||
# The address group to be used in security group rules
|
# The address group to be used in security group rules
|
||||||
_address_group = network_fakes.FakeAddressGroup.create_one_address_group()
|
_address_group = network_fakes.create_one_address_group()
|
||||||
|
|
||||||
expected_columns = (
|
expected_columns = (
|
||||||
'description',
|
'description',
|
||||||
|
@ -44,7 +44,7 @@ class TestCreateSubnetPool(TestSubnetPool):
|
|||||||
# The new subnet pool to create.
|
# The new subnet pool to create.
|
||||||
_subnet_pool = network_fakes.FakeSubnetPool.create_one_subnet_pool()
|
_subnet_pool = network_fakes.FakeSubnetPool.create_one_subnet_pool()
|
||||||
|
|
||||||
_address_scope = network_fakes.FakeAddressScope.create_one_address_scope()
|
_address_scope = network_fakes.create_one_address_scope()
|
||||||
|
|
||||||
columns = (
|
columns = (
|
||||||
'address_scope_id',
|
'address_scope_id',
|
||||||
@ -614,7 +614,7 @@ class TestListSubnetPool(TestSubnetPool):
|
|||||||
self.assertCountEqual(self.data, list(data))
|
self.assertCountEqual(self.data, list(data))
|
||||||
|
|
||||||
def test_subnet_pool_list_address_scope(self):
|
def test_subnet_pool_list_address_scope(self):
|
||||||
addr_scope = network_fakes.FakeAddressScope.create_one_address_scope()
|
addr_scope = network_fakes.create_one_address_scope()
|
||||||
self.network.find_address_scope = mock.Mock(return_value=addr_scope)
|
self.network.find_address_scope = mock.Mock(return_value=addr_scope)
|
||||||
arglist = [
|
arglist = [
|
||||||
'--address-scope', addr_scope.id,
|
'--address-scope', addr_scope.id,
|
||||||
@ -665,7 +665,7 @@ class TestSetSubnetPool(TestSubnetPool):
|
|||||||
'tags': ['green', 'red']}
|
'tags': ['green', 'red']}
|
||||||
)
|
)
|
||||||
|
|
||||||
_address_scope = network_fakes.FakeAddressScope.create_one_address_scope()
|
_address_scope = network_fakes.create_one_address_scope()
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestSetSubnetPool, self).setUp()
|
super(TestSetSubnetPool, self).setUp()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user