Skip to content

Commit 20490dc

Browse files
committed
tests: Centralise check for networking service
No point duplicating this across functional tests. Change-Id: I9502be8b4e718885c6f854c7f5b19f6cacf51055 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
1 parent 0439f17 commit 20490dc

29 files changed

Lines changed: 43 additions & 171 deletions

openstackclient/tests/functional/network/v2/common.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,15 @@ class NetworkTests(base.TestCase):
2020

2121
@classmethod
2222
def setUpClass(cls):
23-
super(NetworkTests, cls).setUpClass()
23+
super().setUpClass()
2424
cls.haz_network = cls.is_service_enabled('network')
2525

26+
def setUp(self):
27+
super().setUp()
28+
29+
if not self.haz_network:
30+
self.skipTest("No Network service present")
31+
2632

2733
class NetworkTagTests(NetworkTests):
2834
"""Functional tests with tag operation"""

openstackclient/tests/functional/network/v2/test_address_group.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ class AddressGroupTests(common.NetworkTests):
1919
"""Functional tests for address group"""
2020

2121
def setUp(self):
22-
super(AddressGroupTests, self).setUp()
23-
# Nothing in this class works with Nova Network
24-
if not self.haz_network:
25-
self.skipTest("No Network service present")
22+
super().setUp()
23+
2624
if not self.is_extension_enabled('address-group'):
2725
self.skipTest("No address-group extension present")
2826

openstackclient/tests/functional/network/v2/test_address_scope.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ class AddressScopeTests(common.NetworkTests):
2323
# has its own needs and there are collisions when running
2424
# tests in parallel.
2525

26-
def setUp(self):
27-
super(AddressScopeTests, self).setUp()
28-
# Nothing in this class works with Nova Network
29-
if not self.haz_network:
30-
self.skipTest("No Network service present")
31-
3226
def test_address_scope_delete(self):
3327
"""Test create, delete multiple"""
3428
name1 = uuid.uuid4().hex

openstackclient/tests/functional/network/v2/test_default_security_group_rule.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ class SecurityGroupRuleTests(common.NetworkTests):
1919
"""Functional tests for security group rule"""
2020

2121
def setUp(self):
22-
super(SecurityGroupRuleTests, self).setUp()
23-
# Nothing in this class works with Nova Network
24-
if not self.haz_network:
25-
self.skipTest("No Network service present")
22+
super().setUp()
23+
2624
if not self.is_extension_enabled("security-groups-default-rules"):
2725
self.skipTest("No security-groups-default-rules extension present")
2826

openstackclient/tests/functional/network/v2/test_floating_ip.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class FloatingIpTests(common.NetworkTests):
2121

2222
@classmethod
2323
def setUpClass(cls):
24-
common.NetworkTests.setUpClass()
24+
super().setUpClass()
2525
if cls.haz_network:
2626
# Create common networks that all tests share
2727
cls.EXTERNAL_NETWORK_NAME = uuid.uuid4().hex
@@ -53,13 +53,10 @@ def tearDownClass(cls):
5353
)
5454
cls.assertOutput('', del_output)
5555
finally:
56-
super(FloatingIpTests, cls).tearDownClass()
56+
super().tearDownClass()
5757

5858
def setUp(self):
59-
super(FloatingIpTests, self).setUp()
60-
# Nothing in this class works with Nova Network
61-
if not self.haz_network:
62-
self.skipTest("No Network service present")
59+
super().setUp()
6360

6461
# Verify setup
6562
self.assertIsNotNone(self.external_network_id)

openstackclient/tests/functional/network/v2/test_ip_availability.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ class IPAvailabilityTests(common.NetworkTests):
2020

2121
@classmethod
2222
def setUpClass(cls):
23-
common.NetworkTests.setUpClass()
23+
super().setUpClass()
24+
2425
if cls.haz_network:
2526
cls.NAME = uuid.uuid4().hex
2627
cls.NETWORK_NAME = uuid.uuid4().hex
@@ -49,13 +50,7 @@ def tearDownClass(cls):
4950
cls.assertOutput('', raw_subnet)
5051
cls.assertOutput('', raw_network)
5152
finally:
52-
super(IPAvailabilityTests, cls).tearDownClass()
53-
54-
def setUp(self):
55-
super(IPAvailabilityTests, self).setUp()
56-
# Nothing in this class works with Nova Network
57-
if not self.haz_network:
58-
self.skipTest("No Network service present")
53+
super().tearDownClass()
5954

6055
def test_ip_availability_list(self):
6156
"""Test ip availability list"""

openstackclient/tests/functional/network/v2/test_l3_conntrack_helper.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@
1818

1919
class L3ConntrackHelperTests(common.NetworkTests):
2020
def setUp(self):
21-
super(L3ConntrackHelperTests, self).setUp()
22-
# Nothing in this class works with Nova Network
23-
if not self.haz_network:
24-
self.skipTest("No Network service present")
21+
super().setUp()
22+
2523
if not self.is_extension_enabled('l3-conntrack-helper'):
2624
self.skipTest("No l3-conntrack-helper extension present")
25+
2726
if not self.is_extension_enabled('expose-l3-conntrack-helper'):
2827
self.skipTest("No expose-l3-conntrack-helper extension present")
2928

openstackclient/tests/functional/network/v2/test_local_ip.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ class LocalIPTests(common.NetworkTests):
2121
"""Functional tests for local IP"""
2222

2323
def setUp(self):
24-
super(LocalIPTests, self).setUp()
25-
# Nothing in this class works with Nova Network
26-
if not self.haz_network:
27-
self.skipTest("No Network service present")
24+
super().setUp()
25+
2826
if not self.is_extension_enabled('local-ip'):
2927
self.skipTest("No local-ip extension present")
3028

openstackclient/tests/functional/network/v2/test_network.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ class NetworkTests(common.NetworkTagTests):
2020

2121
base_command = 'network'
2222

23-
def setUp(self):
24-
super(NetworkTests, self).setUp()
25-
# Nothing in this class works with Nova Network
26-
if not self.haz_network:
27-
self.skipTest("No Network service present")
28-
2923
def test_network_create_compute(self):
3024
"""Test Nova-net create options, delete"""
3125
if self.haz_network:

openstackclient/tests/functional/network/v2/test_network_agent.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@
1818
class NetworkAgentTests(common.NetworkTests):
1919
"""Functional tests for network agent"""
2020

21-
def setUp(self):
22-
super(NetworkAgentTests, self).setUp()
23-
# Nothing in this class works with Nova Network
24-
if not self.haz_network:
25-
self.skipTest("No Network service present")
26-
2721
def test_network_agent_list_show_set(self):
2822
"""Test network agent list, set, show commands
2923
@@ -88,12 +82,6 @@ def test_network_agent_list_show_set(self):
8882
class NetworkAgentListTests(common.NetworkTests):
8983
"""Functional test for network agent"""
9084

91-
def setUp(self):
92-
super(NetworkAgentListTests, self).setUp()
93-
# Nothing in this class works with Nova Network
94-
if not self.haz_network:
95-
self.skipTest("No Network service present")
96-
9785
def test_network_dhcp_agent_list(self):
9886
"""Test network agent list"""
9987

0 commit comments

Comments
 (0)