summaryrefslogtreecommitdiff
path: root/openstackclient/tests/unit/network
diff options
context:
space:
mode:
authorNurmatov Mamatisa <nurmatov.mamatisa@huawei.com>2022-03-15 10:53:49 +0300
committerNurmatov Mamatisa <nurmatov.mamatisa@huawei.com>2022-03-15 11:48:33 +0300
commit6fe0ae497c9f5cd142a459ee2f798a882aaac689 (patch)
treede71b8e7327b070a0f07a94e9c8b6bbdfadeec7a /openstackclient/tests/unit/network
parent23ad68264bb88de0e69b964531fb51b1f19e3d35 (diff)
downloadpython-openstackclient-6fe0ae497c9f5cd142a459ee2f798a882aaac689.tar.gz
Refactor network fakes to sdk properties PART 2
Included resources: ip_availibility network Change-Id: I141bcb43272594da75e776a84a74158fc866ac94
Diffstat (limited to 'openstackclient/tests/unit/network')
-rw-r--r--openstackclient/tests/unit/network/v2/fakes.py287
-rw-r--r--openstackclient/tests/unit/network/v2/test_floating_ip_network.py8
-rw-r--r--openstackclient/tests/unit/network/v2/test_ip_availability.py10
-rw-r--r--openstackclient/tests/unit/network/v2/test_local_ip.py4
-rw-r--r--openstackclient/tests/unit/network/v2/test_network.py92
-rw-r--r--openstackclient/tests/unit/network/v2/test_network_agent.py10
-rw-r--r--openstackclient/tests/unit/network/v2/test_network_auto_allocated_topology.py6
-rw-r--r--openstackclient/tests/unit/network/v2/test_network_rbac.py2
-rw-r--r--openstackclient/tests/unit/network/v2/test_network_segment.py4
-rw-r--r--openstackclient/tests/unit/network/v2/test_port.py4
-rw-r--r--openstackclient/tests/unit/network/v2/test_router.py6
-rw-r--r--openstackclient/tests/unit/network/v2/test_subnet.py6
12 files changed, 220 insertions, 219 deletions
diff --git a/openstackclient/tests/unit/network/v2/fakes.py b/openstackclient/tests/unit/network/v2/fakes.py
index 43c23762..755de4f4 100644
--- a/openstackclient/tests/unit/network/v2/fakes.py
+++ b/openstackclient/tests/unit/network/v2/fakes.py
@@ -24,6 +24,8 @@ 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_association as _local_ip_association
+from openstack.network.v2 import network as _network
+from openstack.network.v2 import network_ip_availability as _ip_availability
from openstackclient.tests.unit import fakes
from openstackclient.tests.unit.identity.v3 import fakes as identity_fakes_v3
@@ -90,56 +92,6 @@ class TestNetworkV2(utils.TestCommand):
)
-class FakeIPAvailability(object):
- """Fake one or more network ip availabilities."""
-
- @staticmethod
- def create_one_ip_availability(attrs=None):
- """Create a fake list with ip availability stats of a network.
-
- :param Dictionary attrs:
- A dictionary with all attributes
- :return:
- A FakeResource object with network_name, network_id, etc.
- """
- attrs = attrs or {}
-
- # Set default attributes.
- network_ip_attrs = {
- 'network_id': 'network-id-' + uuid.uuid4().hex,
- 'network_name': 'network-name-' + uuid.uuid4().hex,
- 'project_id': '',
- 'subnet_ip_availability': [],
- 'total_ips': 254,
- 'used_ips': 6,
- 'location': 'MUNCHMUNCHMUNCH',
- }
- network_ip_attrs.update(attrs)
-
- network_ip_availability = fakes.FakeResource(
- info=copy.deepcopy(network_ip_attrs),
- loaded=True)
-
- return network_ip_availability
-
- @staticmethod
- def create_ip_availability(count=2):
- """Create fake list of ip availability stats of multiple networks.
-
- :param int count:
- The number of networks to fake
- :return:
- A list of FakeResource objects faking network ip availability stats
- """
- network_ip_availabilities = []
- for i in range(0, count):
- network_ip_availability = \
- FakeIPAvailability.create_one_ip_availability()
- network_ip_availabilities.append(network_ip_availability)
-
- return network_ip_availabilities
-
-
class FakeExtension(object):
"""Fake one or more extension."""
@@ -173,111 +125,6 @@ class FakeExtension(object):
return extension
-class FakeNetwork(object):
- """Fake one or more networks."""
-
- @staticmethod
- def create_one_network(attrs=None):
- """Create a fake network.
-
- :param Dictionary attrs:
- A dictionary with all attributes
- :return:
- A FakeResource object, with id, name, etc.
- """
- attrs = attrs or {}
-
- # Set default attributes.
- network_attrs = {
- 'id': 'network-id-' + uuid.uuid4().hex,
- 'name': 'network-name-' + uuid.uuid4().hex,
- 'status': 'ACTIVE',
- 'description': 'network-description-' + uuid.uuid4().hex,
- 'dns_domain': 'example.org.',
- 'mtu': '1350',
- 'project_id': 'project-id-' + uuid.uuid4().hex,
- 'admin_state_up': True,
- 'shared': False,
- 'subnets': ['a', 'b'],
- 'provider:network_type': 'vlan',
- 'provider:physical_network': 'physnet1',
- 'provider:segmentation_id': "400",
- 'router:external': True,
- 'availability_zones': [],
- 'availability_zone_hints': [],
- 'is_default': False,
- 'port_security_enabled': True,
- 'qos_policy_id': 'qos-policy-id-' + uuid.uuid4().hex,
- 'ipv4_address_scope': 'ipv4' + uuid.uuid4().hex,
- 'ipv6_address_scope': 'ipv6' + uuid.uuid4().hex,
- 'tags': [],
- 'location': 'MUNCHMUNCHMUNCH',
- }
-
- # Overwrite default attributes.
- network_attrs.update(attrs)
-
- network = fakes.FakeResource(info=copy.deepcopy(network_attrs),
- loaded=True)
-
- # Set attributes with special mapping in OpenStack SDK.
- network.is_router_external = network_attrs['router:external']
- network.is_admin_state_up = network_attrs['admin_state_up']
- network.is_port_security_enabled = \
- network_attrs['port_security_enabled']
- network.subnet_ids = network_attrs['subnets']
- network.is_shared = network_attrs['shared']
- network.is_tags = network_attrs['tags']
- network.provider_network_type = \
- network_attrs['provider:network_type']
- network.provider_physical_network = \
- network_attrs['provider:physical_network']
- network.provider_segmentation_id = \
- network_attrs['provider:segmentation_id']
- network.ipv4_address_scope_id = \
- network_attrs['ipv4_address_scope']
- network.ipv6_address_scope_id = \
- network_attrs['ipv6_address_scope']
-
- return network
-
- @staticmethod
- def create_networks(attrs=None, count=2):
- """Create multiple fake networks.
-
- :param Dictionary attrs:
- A dictionary with all attributes
- :param int count:
- The number of networks to fake
- :return:
- A list of FakeResource objects faking the networks
- """
- networks = []
- for i in range(0, count):
- networks.append(FakeNetwork.create_one_network(attrs))
-
- return networks
-
- @staticmethod
- def get_networks(networks=None, count=2):
- """Get an iterable Mock object with a list of faked networks.
-
- If networks list is provided, then initialize the Mock object with the
- list. Otherwise create one.
-
- :param List networks:
- A list of FakeResource objects faking networks
- :param int count:
- The number of networks to fake
- :return:
- An iterable Mock object with side_effect set to a list of faked
- networks
- """
- if networks is None:
- networks = FakeNetwork.create_networks(count)
- return mock.Mock(side_effect=networks)
-
-
class FakeNetworkFlavor(object):
"""Fake Network Flavor."""
@@ -2019,6 +1866,136 @@ def create_availability_zones(attrs=None, count=2):
return availability_zones
+def create_one_ip_availability(attrs=None):
+ """Create a fake list with ip availability stats of a network.
+
+ :param Dictionary attrs:
+ A dictionary with all attributes
+ :return:
+ A NetworkIPAvailability object with network_name, network_id, etc.
+ """
+ attrs = attrs or {}
+
+ # Set default attributes.
+ network_ip_attrs = {
+ 'network_id': 'network-id-' + uuid.uuid4().hex,
+ 'network_name': 'network-name-' + uuid.uuid4().hex,
+ 'project_id': '',
+ 'subnet_ip_availability': [],
+ 'total_ips': 254,
+ 'used_ips': 6,
+ 'location': 'MUNCHMUNCHMUNCH',
+ }
+ network_ip_attrs.update(attrs)
+
+ network_ip_availability = _ip_availability.NetworkIPAvailability(
+ **network_ip_attrs)
+
+ return network_ip_availability
+
+
+def create_ip_availability(count=2):
+ """Create fake list of ip availability stats of multiple networks.
+
+ :param int count:
+ The number of networks to fake
+ :return:
+ A list of NetworkIPAvailability objects faking
+ network ip availability stats
+ """
+ network_ip_availabilities = []
+ for i in range(0, count):
+ network_ip_availability = create_one_ip_availability()
+ network_ip_availabilities.append(network_ip_availability)
+
+ return network_ip_availabilities
+
+
+def create_one_network(attrs=None):
+ """Create a fake network.
+
+ :param Dictionary attrs:
+ A dictionary with all attributes
+ :return:
+ An Network object, with id, name, etc.
+ """
+ attrs = attrs or {}
+
+ # Set default attributes.
+ network_attrs = {
+ 'created_at': '2021-11-29T10:10:23.000000',
+ 'id': 'network-id-' + uuid.uuid4().hex,
+ 'name': 'network-name-' + uuid.uuid4().hex,
+ 'status': 'ACTIVE',
+ 'description': 'network-description-' + uuid.uuid4().hex,
+ 'dns_domain': 'example.org.',
+ 'mtu': '1350',
+ 'project_id': 'project-id-' + uuid.uuid4().hex,
+ 'admin_state_up': True,
+ 'shared': False,
+ 'subnets': ['a', 'b'],
+ 'segments': 'network-segment-' + uuid.uuid4().hex,
+ 'provider:network_type': 'vlan',
+ 'provider:physical_network': 'physnet1',
+ 'provider:segmentation_id': "400",
+ 'router:external': True,
+ 'availability_zones': [],
+ 'availability_zone_hints': [],
+ 'is_default': False,
+ 'is_vlan_transparent': True,
+ 'port_security_enabled': True,
+ 'qos_policy_id': 'qos-policy-id-' + uuid.uuid4().hex,
+ 'ipv4_address_scope': 'ipv4' + uuid.uuid4().hex,
+ 'ipv6_address_scope': 'ipv6' + uuid.uuid4().hex,
+ 'tags': [],
+ 'location': 'MUNCHMUNCHMUNCH',
+ 'updated_at': '2021-11-29T10:10:25.000000',
+ }
+
+ # Overwrite default attributes.
+ network_attrs.update(attrs)
+
+ network = _network.Network(**network_attrs)
+
+ return network
+
+
+def create_networks(attrs=None, count=2):
+ """Create multiple fake networks.
+
+ :param Dictionary attrs:
+ A dictionary with all attributes
+ :param int count:
+ The number of networks to fake
+ :return:
+ A list of Network objects faking the networks
+ """
+ networks = []
+ for i in range(0, count):
+ networks.append(create_one_network(attrs))
+
+ return networks
+
+
+def get_networks(networks=None, count=2):
+ """Get an iterable Mock object with a list of faked networks.
+
+ If networks list is provided, then initialize the Mock object with the
+ list. Otherwise create one.
+
+ :param List networks:
+ A list of Network objects faking networks
+ :param int count:
+ The number of networks to fake
+ :return:
+ An iterable Mock object with side_effect set to a list of faked
+ networks
+ """
+ if networks is None:
+ networks = create_networks(count)
+ return mock.Mock(side_effect=networks)
+
+
def create_one_local_ip(attrs=None):
"""Create a fake local ip.
diff --git a/openstackclient/tests/unit/network/v2/test_floating_ip_network.py b/openstackclient/tests/unit/network/v2/test_floating_ip_network.py
index 5b5c83a5..a850045d 100644
--- a/openstackclient/tests/unit/network/v2/test_floating_ip_network.py
+++ b/openstackclient/tests/unit/network/v2/test_floating_ip_network.py
@@ -40,7 +40,7 @@ class TestFloatingIPNetwork(network_fakes.TestNetworkV2):
class TestCreateFloatingIPNetwork(TestFloatingIPNetwork):
# Fake data for option tests.
- floating_network = network_fakes.FakeNetwork.create_one_network()
+ floating_network = network_fakes.create_one_network()
subnet = network_fakes.FakeSubnet.create_one_subnet()
port = network_fakes.FakePort.create_one_port()
@@ -378,7 +378,7 @@ class TestListFloatingIPNetwork(TestFloatingIPNetwork):
# The floating ips to list up
floating_ips = network_fakes.FakeFloatingIP.create_floating_ips(count=3)
- fake_network = network_fakes.FakeNetwork.create_one_network({
+ fake_network = network_fakes.create_one_network({
'id': 'fake_network_id',
})
fake_port = network_fakes.FakePort.create_one_port({
@@ -700,7 +700,7 @@ class TestShowFloatingIPNetwork(TestFloatingIPNetwork):
class TestSetFloatingIP(TestFloatingIPNetwork):
# Fake data for option tests.
- floating_network = network_fakes.FakeNetwork.create_one_network()
+ floating_network = network_fakes.create_one_network()
subnet = network_fakes.FakeSubnet.create_one_subnet()
port = network_fakes.FakePort.create_one_port()
@@ -932,7 +932,7 @@ class TestSetFloatingIP(TestFloatingIPNetwork):
class TestUnsetFloatingIP(TestFloatingIPNetwork):
- floating_network = network_fakes.FakeNetwork.create_one_network()
+ floating_network = network_fakes.create_one_network()
subnet = network_fakes.FakeSubnet.create_one_subnet()
port = network_fakes.FakePort.create_one_port()
diff --git a/openstackclient/tests/unit/network/v2/test_ip_availability.py b/openstackclient/tests/unit/network/v2/test_ip_availability.py
index 880cf581..fbe3b1ab 100644
--- a/openstackclient/tests/unit/network/v2/test_ip_availability.py
+++ b/openstackclient/tests/unit/network/v2/test_ip_availability.py
@@ -38,8 +38,7 @@ class TestIPAvailability(network_fakes.TestNetworkV2):
class TestListIPAvailability(TestIPAvailability):
- _ip_availability = \
- network_fakes.FakeIPAvailability.create_ip_availability(count=3)
+ _ip_availability = network_fakes.create_ip_availability(count=3)
columns = (
'Network ID',
'Network Name',
@@ -117,10 +116,9 @@ class TestListIPAvailability(TestIPAvailability):
class TestShowIPAvailability(TestIPAvailability):
- _network = network_fakes.FakeNetwork.create_one_network()
- _ip_availability = \
- network_fakes.FakeIPAvailability.create_one_ip_availability(
- attrs={'network_id': _network.id})
+ _network = network_fakes.create_one_network()
+ _ip_availability = network_fakes.create_one_ip_availability(
+ attrs={'network_id': _network.id})
columns = (
'network_id',
diff --git a/openstackclient/tests/unit/network/v2/test_local_ip.py b/openstackclient/tests/unit/network/v2/test_local_ip.py
index 17e8dcd1..38e352f3 100644
--- a/openstackclient/tests/unit/network/v2/test_local_ip.py
+++ b/openstackclient/tests/unit/network/v2/test_local_ip.py
@@ -40,7 +40,7 @@ class TestLocalIP(network_fakes.TestNetworkV2):
class TestCreateLocalIP(TestLocalIP):
project = identity_fakes_v3.FakeProject.create_one_project()
domain = identity_fakes_v3.FakeDomain.create_one_domain()
- local_ip_network = network_fakes.FakeNetwork.create_one_network()
+ local_ip_network = network_fakes.create_one_network()
port = network_fakes.FakePort.create_one_port()
# The new local ip created.
new_local_ip = network_fakes.create_one_local_ip(
@@ -216,7 +216,7 @@ class TestListLocalIP(TestLocalIP):
# The local ip to list up.
local_ips = (
network_fakes.create_local_ips(count=3))
- fake_network = network_fakes.FakeNetwork.create_one_network(
+ fake_network = network_fakes.create_one_network(
{'id': 'fake_network_id'}
)
diff --git a/openstackclient/tests/unit/network/v2/test_network.py b/openstackclient/tests/unit/network/v2/test_network.py
index 2b04edf5..8edfbef1 100644
--- a/openstackclient/tests/unit/network/v2/test_network.py
+++ b/openstackclient/tests/unit/network/v2/test_network.py
@@ -46,7 +46,7 @@ class TestCreateNetworkIdentityV3(TestNetwork):
project = identity_fakes_v3.FakeProject.create_one_project()
domain = identity_fakes_v3.FakeDomain.create_one_domain()
# The new network created.
- _network = network_fakes.FakeNetwork.create_one_network(
+ _network = network_fakes.create_one_network(
attrs={
'project_id': project.id,
'availability_zone_hints': ["nova"],
@@ -59,12 +59,14 @@ class TestCreateNetworkIdentityV3(TestNetwork):
'admin_state_up',
'availability_zone_hints',
'availability_zones',
+ 'created_at',
'description',
'dns_domain',
'id',
'ipv4_address_scope',
'ipv6_address_scope',
'is_default',
+ 'is_vlan_transparent',
'mtu',
'name',
'port_security_enabled',
@@ -76,14 +78,18 @@ class TestCreateNetworkIdentityV3(TestNetwork):
'router:external',
'shared',
'status',
+ 'segments',
'subnets',
'tags',
+ 'revision_number',
+ 'updated_at',
)
data = (
- network.AdminStateColumn(_network.admin_state_up),
+ network.AdminStateColumn(_network.is_admin_state_up),
format_columns.ListColumn(_network.availability_zone_hints),
format_columns.ListColumn(_network.availability_zones),
+ _network.created_at,
_network.description,
_network.dns_domain,
_network.id,
@@ -99,10 +105,14 @@ class TestCreateNetworkIdentityV3(TestNetwork):
_network.provider_segmentation_id,
_network.qos_policy_id,
network.RouterExternalColumn(_network.is_router_external),
- _network.shared,
+ _network.is_shared,
+ _network.is_vlan_transparent,
_network.status,
- format_columns.ListColumn(_network.subnets),
+ _network.segments,
+ format_columns.ListColumn(_network.subnet_ids),
format_columns.ListColumn(_network.tags),
+ _network.revision_number,
+ _network.updated_at,
)
def setUp(self):
@@ -145,7 +155,7 @@ class TestCreateNetworkIdentityV3(TestNetwork):
'name': self._network.name,
})
self.assertFalse(self.network.set_tags.called)
- self.assertEqual(self.columns, columns)
+ self.assertEqual(set(self.columns), set(columns))
self.assertCountEqual(self.data, data)
def test_create_all_options(self):
@@ -153,7 +163,7 @@ class TestCreateNetworkIdentityV3(TestNetwork):
"--disable",
"--share",
"--description", self._network.description,
- "--mtu", self._network.mtu,
+ "--mtu", str(self._network.mtu),
"--project", self.project.name,
"--project-domain", self.domain.name,
"--availability-zone-hint", "nova",
@@ -171,7 +181,7 @@ class TestCreateNetworkIdentityV3(TestNetwork):
('disable', True),
('share', True),
('description', self._network.description),
- ('mtu', self._network.mtu),
+ ('mtu', str(self._network.mtu)),
('project', self.project.name),
('project_domain', self.domain.name),
('availability_zone_hints', ["nova"]),
@@ -196,7 +206,7 @@ class TestCreateNetworkIdentityV3(TestNetwork):
'name': self._network.name,
'shared': True,
'description': self._network.description,
- 'mtu': self._network.mtu,
+ 'mtu': str(self._network.mtu),
'project_id': self.project.id,
'is_default': True,
'router:external': True,
@@ -208,7 +218,7 @@ class TestCreateNetworkIdentityV3(TestNetwork):
'port_security_enabled': True,
'dns_domain': 'example.org.',
})
- self.assertEqual(self.columns, columns)
+ self.assertEqual(set(self.columns), set(columns))
self.assertCountEqual(self.data, data)
def test_create_other_options(self):
@@ -235,7 +245,7 @@ class TestCreateNetworkIdentityV3(TestNetwork):
'shared': False,
'port_security_enabled': False,
})
- self.assertEqual(self.columns, columns)
+ self.assertEqual(set(self.columns), set(columns))
self.assertCountEqual(self.data, data)
def _test_create_with_tag(self, add_tags=True):
@@ -267,7 +277,7 @@ class TestCreateNetworkIdentityV3(TestNetwork):
tests_utils.CompareBySet(['red', 'blue']))
else:
self.assertFalse(self.network.set_tags.called)
- self.assertEqual(self.columns, columns)
+ self.assertEqual(set(self.columns), set(columns))
self.assertCountEqual(self.data, data)
def test_create_with_tags(self):
@@ -281,20 +291,21 @@ class TestCreateNetworkIdentityV2(TestNetwork):
project = identity_fakes_v2.FakeProject.create_one_project()
# The new network created.
- _network = network_fakes.FakeNetwork.create_one_network(
+ _network = network_fakes.create_one_network(
attrs={'project_id': project.id}
)
-
columns = (
'admin_state_up',
'availability_zone_hints',
'availability_zones',
+ 'created_at',
'description',
'dns_domain',
'id',
'ipv4_address_scope',
'ipv6_address_scope',
'is_default',
+ 'is_vlan_transparent',
'mtu',
'name',
'port_security_enabled',
@@ -306,14 +317,18 @@ class TestCreateNetworkIdentityV2(TestNetwork):
'router:external',
'shared',
'status',
+ 'segments',
'subnets',
'tags',
+ 'revision_number',
+ 'updated_at',
)
data = (
- network.AdminStateColumn(_network.admin_state_up),
+ network.AdminStateColumn(_network.is_admin_state_up),
format_columns.ListColumn(_network.availability_zone_hints),
format_columns.ListColumn(_network.availability_zones),
+ _network.created_at,
_network.description,
_network.dns_domain,
_network.id,
@@ -329,10 +344,14 @@ class TestCreateNetworkIdentityV2(TestNetwork):
_network.provider_segmentation_id,
_network.qos_policy_id,
network.RouterExternalColumn(_network.is_router_external),
- _network.shared,
+ _network.is_shared,
+ _network.is_vlan_transparent,
_network.status,
- format_columns.ListColumn(_network.subnets),
+ _network.segments,
+ format_columns.ListColumn(_network.subnet_ids),
format_columns.ListColumn(_network.tags),
+ _network.revision_number,
+ _network.updated_at,
)
def setUp(self):
@@ -380,7 +399,7 @@ class TestCreateNetworkIdentityV2(TestNetwork):
'project_id': self.project.id,
})
self.assertFalse(self.network.set_tags.called)
- self.assertEqual(self.columns, columns)
+ self.assertEqual(set(self.columns), set(columns))
self.assertCountEqual(self.data, data)
def test_create_with_domain_identityv2(self):
@@ -413,11 +432,11 @@ class TestDeleteNetwork(TestNetwork):
super(TestDeleteNetwork, self).setUp()
# The networks to delete
- self._networks = network_fakes.FakeNetwork.create_networks(count=3)
+ self._networks = network_fakes.create_networks(count=3)
self.network.delete_network = mock.Mock(return_value=None)
- self.network.find_network = network_fakes.FakeNetwork.get_networks(
+ self.network.find_network = network_fakes.get_networks(
networks=self._networks)
# Get the command object to test
@@ -495,7 +514,7 @@ class TestDeleteNetwork(TestNetwork):
class TestListNetwork(TestNetwork):
# The networks going to be listed up.
- _network = network_fakes.FakeNetwork.create_networks(count=3)
+ _network = network_fakes.create_networks(count=3)
columns = (
'ID',
@@ -521,7 +540,7 @@ class TestListNetwork(TestNetwork):
data.append((
net.id,
net.name,
- format_columns.ListColumn(net.subnets),
+ format_columns.ListColumn(net.subnet_ids),
))
data_long = []
@@ -531,9 +550,9 @@ class TestListNetwork(TestNetwork):
net.name,
net.status,
net.project_id,
- network.AdminStateColumn(net.admin_state_up),
- net.shared,
- format_columns.ListColumn(net.subnets),
+ network.AdminStateColumn(net.is_admin_state_up),
+ net.is_shared,
+ format_columns.ListColumn(net.subnet_ids),
net.provider_network_type,
network.RouterExternalColumn(net.is_router_external),
format_columns.ListColumn(net.availability_zones),
@@ -880,7 +899,7 @@ class TestListNetwork(TestNetwork):
class TestSetNetwork(TestNetwork):
# The network to set.
- _network = network_fakes.FakeNetwork.create_one_network(
+ _network = network_fakes.create_one_network(
{'tags': ['green', 'red']})
qos_policy = (network_fakes.FakeNetworkQosPolicy.
create_one_qos_policy(attrs={'id': _network.qos_policy_id}))
@@ -1025,18 +1044,19 @@ class TestSetNetwork(TestNetwork):
class TestShowNetwork(TestNetwork):
# The network to show.
- _network = network_fakes.FakeNetwork.create_one_network()
-
+ _network = network_fakes.create_one_network()
columns = (
'admin_state_up',
'availability_zone_hints',
'availability_zones',
+ 'created_at',
'description',
'dns_domain',
'id',
'ipv4_address_scope',
'ipv6_address_scope',
'is_default',
+ 'is_vlan_transparent',
'mtu',
'name',
'port_security_enabled',
@@ -1048,14 +1068,18 @@ class TestShowNetwork(TestNetwork):
'router:external',
'shared',
'status',
+ 'segments',
'subnets',
'tags',
+ 'revision_number',
+ 'updated_at',
)
data = (
- network.AdminStateColumn(_network.admin_state_up),
+ network.AdminStateColumn(_network.is_admin_state_up),
format_columns.ListColumn(_network.availability_zone_hints),
format_columns.ListColumn(_network.availability_zones),
+ _network.created_at,
_network.description,
_network.dns_domain,
_network.id,
@@ -1071,10 +1095,14 @@ class TestShowNetwork(TestNetwork):
_network.provider_segmentation_id,
_network.qos_policy_id,
network.RouterExternalColumn(_network.is_router_external),
- _network.shared,
+ _network.is_shared,
+ _network.is_vlan_transparent,
_network.status,
- format_columns.ListColumn(_network.subnets),
+ _network.segments,
+ format_columns.ListColumn(_network.subnet_ids),
format_columns.ListColumn(_network.tags),
+ _network.revision_number,
+ _network.updated_at,
)
def setUp(self):
@@ -1106,14 +1134,14 @@ class TestShowNetwork(TestNetwork):
self.network.find_network.assert_called_once_with(
self._network.name, ignore_missing=False)
- self.assertEqual(self.columns, columns)
+ self.assertEqual(set(self.columns), set(columns))
self.assertCountEqual(self.data, data)
class TestUnsetNetwork(TestNetwork):
# The network to set.
- _network = network_fakes.FakeNetwork.create_one_network(
+ _network = network_fakes.create_one_network(
{'tags': ['green', 'red']})
qos_policy = (network_fakes.FakeNetworkQosPolicy.
create_one_qos_policy(attrs={'id': _network.qos_policy_id}))
diff --git a/openstackclient/tests/unit/network/v2/test_network_agent.py b/openstackclient/tests/unit/network/v2/test_network_agent.py
index 734a36ee..6d3d882b 100644
--- a/openstackclient/tests/unit/network/v2/test_network_agent.py
+++ b/openstackclient/tests/unit/network/v2/test_network_agent.py
@@ -33,7 +33,7 @@ class TestNetworkAgent(network_fakes.TestNetworkV2):
class TestAddNetworkToAgent(TestNetworkAgent):
- net = network_fakes.FakeNetwork.create_one_network()
+ net = network_fakes.create_one_network()
agent = network_fakes.FakeNetworkAgent.create_one_network_agent()
def setUp(self):
@@ -221,7 +221,7 @@ class TestListNetworkAgent(TestNetworkAgent):
network_fakes.FakeNetworkAgent.create_one_network_agent()
self.network.get_agent = mock.Mock(return_value=_testagent)
- self._testnetwork = network_fakes.FakeNetwork.create_one_network()
+ self._testnetwork = network_fakes.create_one_network()
self.network.find_network = mock.Mock(return_value=self._testnetwork)
self.network.network_hosting_dhcp_agents = mock.Mock(
return_value=self.network_agents)
@@ -290,13 +290,11 @@ class TestListNetworkAgent(TestNetworkAgent):
('network', self._testnetwork.id),
]
- attrs = {self._testnetwork, }
-
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.network.network_hosting_dhcp_agents.assert_called_once_with(
- *attrs)
+ self._testnetwork)
self.assertEqual(self.columns, columns)
self.assertCountEqual(self.data, list(data))
@@ -348,7 +346,7 @@ class TestListNetworkAgent(TestNetworkAgent):
class TestRemoveNetworkFromAgent(TestNetworkAgent):
- net = network_fakes.FakeNetwork.create_one_network()
+ net = network_fakes.create_one_network()
agent = network_fakes.FakeNetworkAgent.create_one_network_agent()
def setUp(self):
diff --git a/openstackclient/tests/unit/network/v2/test_network_auto_allocated_topology.py b/openstackclient/tests/unit/network/v2/test_network_auto_allocated_topology.py
index a6ab3d7e..a5dbcde1 100644
--- a/openstackclient/tests/unit/network/v2/test_network_auto_allocated_topology.py
+++ b/openstackclient/tests/unit/network/v2/test_network_auto_allocated_topology.py
@@ -29,7 +29,7 @@ class TestAutoAllocatedTopology(network_fakes.TestNetworkV2):
class TestCreateAutoAllocatedTopology(TestAutoAllocatedTopology):
project = identity_fakes.FakeProject.create_one_project()
- network_object = network_fakes.FakeNetwork.create_one_network()
+ network_object = network_fakes.create_one_network()
topology = network_fakes.create_one_topology(
attrs={'id': network_object.id,
@@ -127,7 +127,7 @@ class TestCreateAutoAllocatedTopology(TestAutoAllocatedTopology):
class TestValidateAutoAllocatedTopology(TestAutoAllocatedTopology):
project = identity_fakes.FakeProject.create_one_project()
- network_object = network_fakes.FakeNetwork.create_one_network()
+ network_object = network_fakes.create_one_network()
topology = network_fakes.create_one_topology(
attrs={'id': network_object.id,
@@ -204,7 +204,7 @@ class TestValidateAutoAllocatedTopology(TestAutoAllocatedTopology):
class TestDeleteAutoAllocatedTopology(TestAutoAllocatedTopology):
project = identity_fakes.FakeProject.create_one_project()
- network_object = network_fakes.FakeNetwork.create_one_network()
+ network_object = network_fakes.create_one_network()
topology = network_fakes.create_one_topology(
attrs={'id': network_object.id,
diff --git a/openstackclient/tests/unit/network/v2/test_network_rbac.py b/openstackclient/tests/unit/network/v2/test_network_rbac.py
index 520a0724..c7e3374d 100644
--- a/openstackclient/tests/unit/network/v2/test_network_rbac.py
+++ b/openstackclient/tests/unit/network/v2/test_network_rbac.py
@@ -37,7 +37,7 @@ class TestNetworkRBAC(network_fakes.TestNetworkV2):
@ddt.ddt
class TestCreateNetworkRBAC(TestNetworkRBAC):
- network_object = network_fakes.FakeNetwork.create_one_network()
+ network_object = network_fakes.create_one_network()
qos_object = network_fakes.FakeNetworkQosPolicy.create_one_qos_policy()
sg_object = network_fakes.FakeNetworkSecGroup.create_one_security_group()
as_object = network_fakes.create_one_address_scope()
diff --git a/openstackclient/tests/unit/network/v2/test_network_segment.py b/openstackclient/tests/unit/network/v2/test_network_segment.py
index 6cd948e3..b337c5e6 100644
--- a/openstackclient/tests/unit/network/v2/test_network_segment.py
+++ b/openstackclient/tests/unit/network/v2/test_network_segment.py
@@ -35,7 +35,7 @@ class TestCreateNetworkSegment(TestNetworkSegment):
# The network segment to create along with associated network.
_network_segment = \
network_fakes.FakeNetworkSegment.create_one_network_segment()
- _network = network_fakes.FakeNetwork.create_one_network({
+ _network = network_fakes.create_one_network({
'id': _network_segment.network_id,
})
@@ -240,7 +240,7 @@ class TestDeleteNetworkSegment(TestNetworkSegment):
class TestListNetworkSegment(TestNetworkSegment):
- _network = network_fakes.FakeNetwork.create_one_network()
+ _network = network_fakes.create_one_network()
_network_segments = \
network_fakes.FakeNetworkSegment.create_network_segments(count=3)
diff --git a/openstackclient/tests/unit/network/v2/test_port.py b/openstackclient/tests/unit/network/v2/test_port.py
index 6f830aa6..bde01800 100644
--- a/openstackclient/tests/unit/network/v2/test_port.py
+++ b/openstackclient/tests/unit/network/v2/test_port.py
@@ -121,7 +121,7 @@ class TestCreatePort(TestPort):
self.network.create_port = mock.Mock(return_value=self._port)
self.network.set_tags = mock.Mock(return_value=None)
- fake_net = network_fakes.FakeNetwork.create_one_network({
+ fake_net = network_fakes.create_one_network({
'id': self._port.network_id,
})
self.network.find_network = mock.Mock(return_value=fake_net)
@@ -901,7 +901,7 @@ class TestListPort(TestPort):
fake_router = network_fakes.FakeRouter.create_one_router({
'id': 'fake-router-id',
})
- fake_network = network_fakes.FakeNetwork.create_one_network({
+ fake_network = network_fakes.create_one_network({
'id': 'fake-network-id',
})
self.network.find_router = mock.Mock(return_value=fake_router)
diff --git a/openstackclient/tests/unit/network/v2/test_router.py b/openstackclient/tests/unit/network/v2/test_router.py
index 4d035077..14840e1d 100644
--- a/openstackclient/tests/unit/network/v2/test_router.py
+++ b/openstackclient/tests/unit/network/v2/test_router.py
@@ -187,7 +187,7 @@ class TestCreateRouter(TestRouter):
self.assertCountEqual(self.data, data)
def test_create_with_gateway(self):
- _network = network_fakes.FakeNetwork.create_one_network()
+ _network = network_fakes.create_one_network()
_subnet = network_fakes.FakeSubnet.create_one_subnet()
self.network.find_network = mock.Mock(return_value=_network)
self.network.find_subnet = mock.Mock(return_value=_subnet)
@@ -957,7 +957,7 @@ class TestSetRouter(TestRouter):
# The router to set.
_default_route = {'destination': '10.20.20.0/24', 'nexthop': '10.20.30.1'}
- _network = network_fakes.FakeNetwork.create_one_network()
+ _network = network_fakes.create_one_network()
_subnet = network_fakes.FakeSubnet.create_one_subnet()
_router = network_fakes.FakeRouter.create_one_router(
attrs={'routes': [_default_route],
@@ -1485,7 +1485,7 @@ class TestUnsetRouter(TestRouter):
def setUp(self):
super(TestUnsetRouter, self).setUp()
- self.fake_network = network_fakes.FakeNetwork.create_one_network()
+ self.fake_network = network_fakes.create_one_network()
self.fake_qos_policy = (
network_fakes.FakeNetworkQosPolicy.create_one_qos_policy())
self._testrouter = network_fakes.FakeRouter.create_one_router(
diff --git a/openstackclient/tests/unit/network/v2/test_subnet.py b/openstackclient/tests/unit/network/v2/test_subnet.py
index dcac2ef8..0a990f59 100644
--- a/openstackclient/tests/unit/network/v2/test_subnet.py
+++ b/openstackclient/tests/unit/network/v2/test_subnet.py
@@ -95,7 +95,7 @@ class TestCreateSubnet(TestSubnet):
)
# The network to be returned from find_network
- self._network = network_fakes.FakeNetwork.create_one_network(
+ self._network = network_fakes.create_one_network(
attrs={
'id': self._subnet.network_id,
}
@@ -828,7 +828,7 @@ class TestListSubnet(TestSubnet):
self.assertCountEqual(self.data, list(data))
def test_subnet_list_network(self):
- network = network_fakes.FakeNetwork.create_one_network()
+ network = network_fakes.create_one_network()
self.network.find_network = mock.Mock(return_value=network)
arglist = [
'--network', network.id,
@@ -1185,7 +1185,7 @@ class TestSetSubnet(TestSubnet):
self._test_set_tags(with_tags=False)
def test_set_segment(self):
- _net = network_fakes.FakeNetwork.create_one_network()
+ _net = network_fakes.create_one_network()
_segment = network_fakes.FakeNetworkSegment.create_one_network_segment(
attrs={'network_id': _net.id})
_subnet = network_fakes.FakeSubnet.create_one_subnet(