summaryrefslogtreecommitdiff
path: root/openstackclient/tests/unit/network/v2
diff options
context:
space:
mode:
authorStephen Finucane <sfinucan@redhat.com>2022-12-14 11:19:04 +0000
committerStephen Finucane <sfinucan@redhat.com>2023-05-16 16:21:44 +0100
commit19be070204ae52e342ba2c18f6cc519d617230ab (patch)
tree32bf4eb28350d10d671ba1213dd7348589f77487 /openstackclient/tests/unit/network/v2
parent347b444feb19ddb13a5b1a66d049eb0d818cbe77 (diff)
downloadpython-openstackclient-19be070204ae52e342ba2c18f6cc519d617230ab.tar.gz
tests: Remove unnecessary nesting of compute resources
Change-Id: I27326b8f2e0d84d3ef2c2fbdcb5c96a5ac1d79e4 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Diffstat (limited to 'openstackclient/tests/unit/network/v2')
-rw-r--r--openstackclient/tests/unit/network/v2/test_floating_ip_compute.py8
-rw-r--r--openstackclient/tests/unit/network/v2/test_floating_ip_pool_compute.py4
-rw-r--r--openstackclient/tests/unit/network/v2/test_network_compute.py10
-rw-r--r--openstackclient/tests/unit/network/v2/test_port.py2
-rw-r--r--openstackclient/tests/unit/network/v2/test_security_group_compute.py28
-rw-r--r--openstackclient/tests/unit/network/v2/test_security_group_rule_compute.py60
6 files changed, 41 insertions, 71 deletions
diff --git a/openstackclient/tests/unit/network/v2/test_floating_ip_compute.py b/openstackclient/tests/unit/network/v2/test_floating_ip_compute.py
index 489212be..238a2c6b 100644
--- a/openstackclient/tests/unit/network/v2/test_floating_ip_compute.py
+++ b/openstackclient/tests/unit/network/v2/test_floating_ip_compute.py
@@ -35,7 +35,7 @@ class TestFloatingIPCompute(compute_fakes.TestComputev2):
@mock.patch('openstackclient.api.compute_v2.APIv2.floating_ip_create')
class TestCreateFloatingIPCompute(TestFloatingIPCompute):
# The floating ip to be deleted.
- _floating_ip = compute_fakes.FakeFloatingIP.create_one_floating_ip()
+ _floating_ip = compute_fakes.create_one_floating_ip()
columns = (
'fixed_ip',
@@ -95,7 +95,7 @@ class TestCreateFloatingIPCompute(TestFloatingIPCompute):
@mock.patch('openstackclient.api.compute_v2.APIv2.floating_ip_delete')
class TestDeleteFloatingIPCompute(TestFloatingIPCompute):
# The floating ips to be deleted.
- _floating_ips = compute_fakes.FakeFloatingIP.create_floating_ips(count=2)
+ _floating_ips = compute_fakes.create_floating_ips(count=2)
def setUp(self):
super(TestDeleteFloatingIPCompute, self).setUp()
@@ -171,7 +171,7 @@ class TestDeleteFloatingIPCompute(TestFloatingIPCompute):
@mock.patch('openstackclient.api.compute_v2.APIv2.floating_ip_list')
class TestListFloatingIPCompute(TestFloatingIPCompute):
# The floating ips to be list up
- _floating_ips = compute_fakes.FakeFloatingIP.create_floating_ips(count=3)
+ _floating_ips = compute_fakes.create_floating_ips(count=3)
columns = (
'ID',
@@ -217,7 +217,7 @@ class TestListFloatingIPCompute(TestFloatingIPCompute):
@mock.patch('openstackclient.api.compute_v2.APIv2.floating_ip_find')
class TestShowFloatingIPCompute(TestFloatingIPCompute):
# The floating ip to display.
- _floating_ip = compute_fakes.FakeFloatingIP.create_one_floating_ip()
+ _floating_ip = compute_fakes.create_one_floating_ip()
columns = (
'fixed_ip',
diff --git a/openstackclient/tests/unit/network/v2/test_floating_ip_pool_compute.py b/openstackclient/tests/unit/network/v2/test_floating_ip_pool_compute.py
index 2e0f75bd..6c3d4ee7 100644
--- a/openstackclient/tests/unit/network/v2/test_floating_ip_pool_compute.py
+++ b/openstackclient/tests/unit/network/v2/test_floating_ip_pool_compute.py
@@ -31,9 +31,7 @@ class TestFloatingIPPoolCompute(compute_fakes.TestComputev2):
@mock.patch('openstackclient.api.compute_v2.APIv2.floating_ip_pool_list')
class TestListFloatingIPPoolCompute(TestFloatingIPPoolCompute):
# The floating ip pools to list up
- _floating_ip_pools = (
- compute_fakes.FakeFloatingIPPool.create_floating_ip_pools(count=3)
- )
+ _floating_ip_pools = compute_fakes.create_floating_ip_pools(count=3)
columns = ('Name',)
diff --git a/openstackclient/tests/unit/network/v2/test_network_compute.py b/openstackclient/tests/unit/network/v2/test_network_compute.py
index ffa82f5d..ada1d723 100644
--- a/openstackclient/tests/unit/network/v2/test_network_compute.py
+++ b/openstackclient/tests/unit/network/v2/test_network_compute.py
@@ -34,7 +34,7 @@ class TestNetworkCompute(compute_fakes.TestComputev2):
@mock.patch('openstackclient.api.compute_v2.APIv2.network_create')
class TestCreateNetworkCompute(TestNetworkCompute):
# The network to create.
- _network = compute_fakes.FakeNetwork.create_one_network()
+ _network = compute_fakes.create_one_network()
columns = (
'bridge',
@@ -179,10 +179,10 @@ class TestDeleteNetworkCompute(TestNetworkCompute):
self.app.client_manager.network_endpoint_enabled = False
# The networks to delete
- self._networks = compute_fakes.FakeNetwork.create_networks(count=3)
+ self._networks = compute_fakes.create_networks(count=3)
# Return value of utils.find_resource()
- self.compute.api.network_find = compute_fakes.FakeNetwork.get_networks(
+ self.compute.api.network_find = compute_fakes.get_networks(
networks=self._networks
)
@@ -254,7 +254,7 @@ class TestDeleteNetworkCompute(TestNetworkCompute):
@mock.patch('openstackclient.api.compute_v2.APIv2.network_list')
class TestListNetworkCompute(TestNetworkCompute):
# The networks going to be listed up.
- _networks = compute_fakes.FakeNetwork.create_networks(count=3)
+ _networks = compute_fakes.create_networks(count=3)
columns = (
'ID',
@@ -299,7 +299,7 @@ class TestListNetworkCompute(TestNetworkCompute):
@mock.patch('openstackclient.api.compute_v2.APIv2.network_find')
class TestShowNetworkCompute(TestNetworkCompute):
# The network to show.
- _network = compute_fakes.FakeNetwork.create_one_network()
+ _network = compute_fakes.create_one_network()
columns = (
'bridge',
diff --git a/openstackclient/tests/unit/network/v2/test_port.py b/openstackclient/tests/unit/network/v2/test_port.py
index 0f6bb9c3..78ac6635 100644
--- a/openstackclient/tests/unit/network/v2/test_port.py
+++ b/openstackclient/tests/unit/network/v2/test_port.py
@@ -1113,7 +1113,7 @@ class TestListPort(TestPort):
@mock.patch.object(utils, 'find_resource')
def test_port_list_with_server_option(self, mock_find):
- fake_server = compute_fakes.FakeServer.create_one_server()
+ fake_server = compute_fakes.create_one_server()
mock_find.return_value = fake_server
arglist = [
diff --git a/openstackclient/tests/unit/network/v2/test_security_group_compute.py b/openstackclient/tests/unit/network/v2/test_security_group_compute.py
index 22e8b71b..57defbd3 100644
--- a/openstackclient/tests/unit/network/v2/test_security_group_compute.py
+++ b/openstackclient/tests/unit/network/v2/test_security_group_compute.py
@@ -36,9 +36,7 @@ class TestCreateSecurityGroupCompute(TestSecurityGroupCompute):
domain = identity_fakes.FakeDomain.create_one_domain()
# The security group to be shown.
- _security_group = (
- compute_fakes.FakeSecurityGroup.create_one_security_group()
- )
+ _security_group = compute_fakes.create_one_security_group()
columns = (
'description',
@@ -114,7 +112,7 @@ class TestCreateSecurityGroupCompute(TestSecurityGroupCompute):
@mock.patch('openstackclient.api.compute_v2.APIv2.security_group_delete')
class TestDeleteSecurityGroupCompute(TestSecurityGroupCompute):
# The security groups to be deleted.
- _security_groups = compute_fakes.FakeSecurityGroup.create_security_groups()
+ _security_groups = compute_fakes.create_security_groups()
def setUp(self):
super(TestDeleteSecurityGroupCompute, self).setUp()
@@ -122,9 +120,7 @@ class TestDeleteSecurityGroupCompute(TestSecurityGroupCompute):
self.app.client_manager.network_endpoint_enabled = False
self.compute.api.security_group_find = (
- compute_fakes.FakeSecurityGroup.get_security_groups(
- self._security_groups
- )
+ compute_fakes.get_security_groups(self._security_groups)
)
# Get the command object to test
@@ -198,9 +194,7 @@ class TestDeleteSecurityGroupCompute(TestSecurityGroupCompute):
@mock.patch('openstackclient.api.compute_v2.APIv2.security_group_list')
class TestListSecurityGroupCompute(TestSecurityGroupCompute):
# The security group to be listed.
- _security_groups = compute_fakes.FakeSecurityGroup.create_security_groups(
- count=3
- )
+ _security_groups = compute_fakes.create_security_groups(count=3)
columns = (
'ID',
@@ -278,9 +272,7 @@ class TestListSecurityGroupCompute(TestSecurityGroupCompute):
@mock.patch('openstackclient.api.compute_v2.APIv2.security_group_set')
class TestSetSecurityGroupCompute(TestSecurityGroupCompute):
# The security group to be set.
- _security_group = (
- compute_fakes.FakeSecurityGroup.create_one_security_group()
- )
+ _security_group = compute_fakes.create_one_security_group()
def setUp(self):
super(TestSetSecurityGroupCompute, self).setUp()
@@ -347,15 +339,11 @@ class TestSetSecurityGroupCompute(TestSecurityGroupCompute):
@mock.patch('openstackclient.api.compute_v2.APIv2.security_group_find')
class TestShowSecurityGroupCompute(TestSecurityGroupCompute):
# The security group rule to be shown with the group.
- _security_group_rule = (
- compute_fakes.FakeSecurityGroupRule.create_one_security_group_rule()
- )
+ _security_group_rule = compute_fakes.create_one_security_group_rule()
# The security group to be shown.
- _security_group = (
- compute_fakes.FakeSecurityGroup.create_one_security_group(
- attrs={'rules': [_security_group_rule]}
- )
+ _security_group = compute_fakes.create_one_security_group(
+ attrs={'rules': [_security_group_rule]}
)
columns = (
diff --git a/openstackclient/tests/unit/network/v2/test_security_group_rule_compute.py b/openstackclient/tests/unit/network/v2/test_security_group_rule_compute.py
index ea4adce0..2a1609ba 100644
--- a/openstackclient/tests/unit/network/v2/test_security_group_rule_compute.py
+++ b/openstackclient/tests/unit/network/v2/test_security_group_rule_compute.py
@@ -40,15 +40,11 @@ class TestCreateSecurityGroupRuleCompute(TestSecurityGroupRuleCompute):
_security_group_rule = None
# The security group that will contain the rule created.
- _security_group = (
- compute_fakes.FakeSecurityGroup.create_one_security_group()
- )
+ _security_group = compute_fakes.create_one_security_group()
def _setup_security_group_rule(self, attrs=None):
self._security_group_rule = (
- compute_fakes.FakeSecurityGroupRule.create_one_security_group_rule(
- attrs
- )
+ compute_fakes.create_one_security_group_rule(attrs)
)
(
expected_columns,
@@ -311,11 +307,7 @@ class TestCreateSecurityGroupRuleCompute(TestSecurityGroupRuleCompute):
@mock.patch('openstackclient.api.compute_v2.APIv2.security_group_rule_delete')
class TestDeleteSecurityGroupRuleCompute(TestSecurityGroupRuleCompute):
# The security group rule to be deleted.
- _security_group_rules = (
- compute_fakes.FakeSecurityGroupRule.create_security_group_rules(
- count=2
- )
- )
+ _security_group_rules = compute_fakes.create_security_group_rules(count=2)
def setUp(self):
super(TestDeleteSecurityGroupRuleCompute, self).setUp()
@@ -383,33 +375,27 @@ class TestDeleteSecurityGroupRuleCompute(TestSecurityGroupRuleCompute):
class TestListSecurityGroupRuleCompute(TestSecurityGroupRuleCompute):
# The security group to hold the rules.
- _security_group = (
- compute_fakes.FakeSecurityGroup.create_one_security_group()
- )
+ _security_group = compute_fakes.create_one_security_group()
# The security group rule to be listed.
- _security_group_rule_tcp = (
- compute_fakes.FakeSecurityGroupRule.create_one_security_group_rule(
- {
- 'ip_protocol': 'tcp',
- 'ethertype': 'IPv4',
- 'from_port': 80,
- 'to_port': 80,
- 'group': {'name': _security_group['name']},
- }
- )
+ _security_group_rule_tcp = compute_fakes.create_one_security_group_rule(
+ {
+ 'ip_protocol': 'tcp',
+ 'ethertype': 'IPv4',
+ 'from_port': 80,
+ 'to_port': 80,
+ 'group': {'name': _security_group['name']},
+ }
)
- _security_group_rule_icmp = (
- compute_fakes.FakeSecurityGroupRule.create_one_security_group_rule(
- {
- 'ip_protocol': 'icmp',
- 'ethertype': 'IPv4',
- 'from_port': -1,
- 'to_port': -1,
- 'ip_range': {'cidr': '10.0.2.0/24'},
- 'group': {'name': _security_group['name']},
- }
- )
+ _security_group_rule_icmp = compute_fakes.create_one_security_group_rule(
+ {
+ 'ip_protocol': 'icmp',
+ 'ethertype': 'IPv4',
+ 'from_port': -1,
+ 'to_port': -1,
+ 'ip_range': {'cidr': '10.0.2.0/24'},
+ 'group': {'name': _security_group['name']},
+ }
)
_security_group['rules'] = [
_security_group_rule_tcp,
@@ -525,9 +511,7 @@ class TestListSecurityGroupRuleCompute(TestSecurityGroupRuleCompute):
class TestShowSecurityGroupRuleCompute(TestSecurityGroupRuleCompute):
# The security group rule to be shown.
- _security_group_rule = (
- compute_fakes.FakeSecurityGroupRule.create_one_security_group_rule()
- )
+ _security_group_rule = compute_fakes.create_one_security_group_rule()
columns, data = security_group_rule._format_security_group_rule_show(
_security_group_rule