Skip to content

Commit 9db8902

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "tests: Remove use of unnecessary fake argparse Namespace"
2 parents 9ca9eba + bb6b1e3 commit 9db8902

35 files changed

Lines changed: 183 additions & 270 deletions

openstackclient/tests/unit/compute/v2/test_server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ def setUp(self):
513513
self.network_client.update_ip = mock.Mock(return_value=None)
514514

515515
# Get the command object to test
516-
self.cmd = server.AddFloatingIP(self.app, self.namespace)
516+
self.cmd = server.AddFloatingIP(self.app, None)
517517

518518
def test_server_add_floating_ip(self):
519519
_server = compute_fakes.create_one_server()
@@ -7182,7 +7182,7 @@ def setUp(self):
71827182
self.network_client.update_ip = mock.Mock(return_value=None)
71837183

71847184
# Get the command object to test
7185-
self.cmd = server.RemoveFloatingIP(self.app, self.namespace)
7185+
self.cmd = server.RemoveFloatingIP(self.app, None)
71867186

71877187
def test_server_remove_floating_ip_default(self):
71887188
_server = compute_fakes.create_one_server()

openstackclient/tests/unit/network/test_common.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
# under the License.
1212
#
1313

14-
import argparse
1514
from unittest import mock
1615

1716
import openstack
@@ -126,8 +125,6 @@ class TestNetworkAndCompute(utils.TestCommand):
126125
def setUp(self):
127126
super().setUp()
128127

129-
self.namespace = argparse.Namespace()
130-
131128
# Create client mocks. Note that we intentionally do not use specced
132129
# mocks since we want to test fake methods.
133130

@@ -143,7 +140,7 @@ def setUp(self):
143140
return_value='take_action_compute'
144141
)
145142

146-
self.cmd = FakeNetworkAndComputeCommand(self.app, self.namespace)
143+
self.cmd = FakeNetworkAndComputeCommand(self.app, None)
147144

148145
def test_take_action_network(self):
149146
arglist = ['common', 'network']
@@ -168,19 +165,19 @@ def test_take_action_compute(self):
168165
class TestNetworkAndComputeCommand(TestNetworkAndCompute):
169166
def setUp(self):
170167
super(TestNetworkAndComputeCommand, self).setUp()
171-
self.cmd = FakeNetworkAndComputeCommand(self.app, self.namespace)
168+
self.cmd = FakeNetworkAndComputeCommand(self.app, None)
172169

173170

174171
class TestNetworkAndComputeLister(TestNetworkAndCompute):
175172
def setUp(self):
176173
super(TestNetworkAndComputeLister, self).setUp()
177-
self.cmd = FakeNetworkAndComputeLister(self.app, self.namespace)
174+
self.cmd = FakeNetworkAndComputeLister(self.app, None)
178175

179176

180177
class TestNetworkAndComputeShowOne(TestNetworkAndCompute):
181178
def setUp(self):
182179
super(TestNetworkAndComputeShowOne, self).setUp()
183-
self.cmd = FakeNetworkAndComputeShowOne(self.app, self.namespace)
180+
self.cmd = FakeNetworkAndComputeShowOne(self.app, None)
184181

185182
def test_take_action_with_http_exception(self):
186183
with mock.patch.object(self.cmd, 'take_action_network') as m_action:
@@ -207,8 +204,6 @@ class TestNeutronCommandWithExtraArgs(utils.TestCommand):
207204
def setUp(self):
208205
super(TestNeutronCommandWithExtraArgs, self).setUp()
209206

210-
self.namespace = argparse.Namespace()
211-
212207
# Create client mocks. Note that we intentionally do not use specced
213208
# mocks since we want to test fake methods.
214209

@@ -217,9 +212,7 @@ def setUp(self):
217212
self.network_client.test_create_action = mock.Mock()
218213

219214
# Subclasses can override the command object to test.
220-
self.cmd = FakeCreateNeutronCommandWithExtraArgs(
221-
self.app, self.namespace
222-
)
215+
self.cmd = FakeCreateNeutronCommandWithExtraArgs(self.app, None)
223216

224217
def test_create_extra_attributes_default_type(self):
225218
arglist = [

openstackclient/tests/unit/network/v2/fakes.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
# License for the specific language governing permissions and limitations
1111
# under the License.
1212

13-
import argparse
1413
import copy
1514
from random import choice
1615
from random import randint
@@ -106,10 +105,7 @@ class TestNetworkV2(
106105
FakeClientMixin,
107106
utils.TestCommand,
108107
):
109-
def setUp(self):
110-
super().setUp()
111-
112-
self.namespace = argparse.Namespace()
108+
...
113109

114110

115111
def create_one_extension(attrs=None):

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def setUp(self):
6363
)
6464

6565
# Get the command object to test
66-
self.cmd = address_group.CreateAddressGroup(self.app, self.namespace)
66+
self.cmd = address_group.CreateAddressGroup(self.app, None)
6767

6868
self.projects_mock.get.return_value = self.project
6969
self.domains_mock.get.return_value = self.domain
@@ -153,7 +153,7 @@ def setUp(self):
153153
)
154154

155155
# Get the command object to test
156-
self.cmd = address_group.DeleteAddressGroup(self.app, self.namespace)
156+
self.cmd = address_group.DeleteAddressGroup(self.app, None)
157157

158158
def test_address_group_delete(self):
159159
arglist = [
@@ -256,7 +256,7 @@ def setUp(self):
256256
)
257257

258258
# Get the command object to test
259-
self.cmd = address_group.ListAddressGroup(self.app, self.namespace)
259+
self.cmd = address_group.ListAddressGroup(self.app, None)
260260

261261
def test_address_group_list(self):
262262
arglist = []
@@ -341,7 +341,7 @@ def setUp(self):
341341
return_value=self._address_group
342342
)
343343
# Get the command object to test
344-
self.cmd = address_group.SetAddressGroup(self.app, self.namespace)
344+
self.cmd = address_group.SetAddressGroup(self.app, None)
345345

346346
def test_set_nothing(self):
347347
arglist = [
@@ -447,7 +447,7 @@ def setUp(self):
447447
)
448448

449449
# Get the command object to test
450-
self.cmd = address_group.ShowAddressGroup(self.app, self.namespace)
450+
self.cmd = address_group.ShowAddressGroup(self.app, None)
451451

452452
def test_show_no_options(self):
453453
arglist = []
@@ -493,7 +493,7 @@ def setUp(self):
493493
return_value=self._address_group
494494
)
495495
# Get the command object to test
496-
self.cmd = address_group.UnsetAddressGroup(self.app, self.namespace)
496+
self.cmd = address_group.UnsetAddressGroup(self.app, None)
497497

498498
def test_unset_nothing(self):
499499
arglist = [

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def setUp(self):
5757
)
5858

5959
# Get the command object to test
60-
self.cmd = address_scope.CreateAddressScope(self.app, self.namespace)
60+
self.cmd = address_scope.CreateAddressScope(self.app, None)
6161

6262
self.projects_mock.get.return_value = self.project
6363
self.domains_mock.get.return_value = self.domain
@@ -168,7 +168,7 @@ def setUp(self):
168168
)
169169

170170
# Get the command object to test
171-
self.cmd = address_scope.DeleteAddressScope(self.app, self.namespace)
171+
self.cmd = address_scope.DeleteAddressScope(self.app, None)
172172

173173
def test_address_scope_delete(self):
174174
arglist = [
@@ -272,7 +272,7 @@ def setUp(self):
272272
)
273273

274274
# Get the command object to test
275-
self.cmd = address_scope.ListAddressScope(self.app, self.namespace)
275+
self.cmd = address_scope.ListAddressScope(self.app, None)
276276

277277
def test_address_scope_list(self):
278278
arglist = []
@@ -404,7 +404,7 @@ def setUp(self):
404404
)
405405

406406
# Get the command object to test
407-
self.cmd = address_scope.SetAddressScope(self.app, self.namespace)
407+
self.cmd = address_scope.SetAddressScope(self.app, None)
408408

409409
def test_set_nothing(self):
410410
arglist = [
@@ -493,7 +493,7 @@ def setUp(self):
493493
)
494494

495495
# Get the command object to test
496-
self.cmd = address_scope.ShowAddressScope(self.app, self.namespace)
496+
self.cmd = address_scope.ShowAddressScope(self.app, None)
497497

498498
def test_show_no_options(self):
499499
arglist = []

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def setUp(self):
105105

106106
# Get the command object to test
107107
self.cmd = default_security_group_rule.CreateDefaultSecurityGroupRule(
108-
self.app, self.namespace
108+
self.app, None
109109
)
110110

111111
def test_create_all_remote_options(self):
@@ -848,7 +848,7 @@ def setUp(self):
848848

849849
# Get the command object to test
850850
self.cmd = default_security_group_rule.DeleteDefaultSecurityGroupRule(
851-
self.app, self.namespace
851+
self.app, None
852852
)
853853

854854
def test_default_security_group_rule_delete(self):
@@ -985,7 +985,7 @@ def setUp(self):
985985

986986
# Get the command object to test
987987
self.cmd = default_security_group_rule.ListDefaultSecurityGroupRule(
988-
self.app, self.namespace
988+
self.app, None
989989
)
990990

991991
def test_list_default(self):
@@ -1107,7 +1107,7 @@ def setUp(self):
11071107

11081108
# Get the command object to test
11091109
self.cmd = default_security_group_rule.ShowDefaultSecurityGroupRule(
1110-
self.app, self.namespace
1110+
self.app, None
11111111
)
11121112

11131113
def test_show_no_options(self):

openstackclient/tests/unit/network/v2/test_floating_ip_network.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def setUp(self):
9595
self.network_client.find_port = mock.Mock(return_value=self.port)
9696

9797
# Get the command object to test
98-
self.cmd = fip.CreateFloatingIP(self.app, self.namespace)
98+
self.cmd = fip.CreateFloatingIP(self.app, None)
9999

100100
def test_create_no_options(self):
101101
arglist = []
@@ -306,7 +306,7 @@ def setUp(self):
306306
self.network_client.delete_ip = mock.Mock(return_value=None)
307307

308308
# Get the command object to test
309-
self.cmd = fip.DeleteFloatingIP(self.app, self.namespace)
309+
self.cmd = fip.DeleteFloatingIP(self.app, None)
310310

311311
def test_floating_ip_delete(self):
312312
self.network_client.find_ip.side_effect = [
@@ -479,7 +479,7 @@ def setUp(self):
479479
)
480480

481481
# Get the command object to test
482-
self.cmd = fip.ListFloatingIP(self.app, self.namespace)
482+
self.cmd = fip.ListFloatingIP(self.app, None)
483483

484484
def test_floating_ip_list(self):
485485
arglist = []
@@ -747,7 +747,7 @@ def setUp(self):
747747
self.network_client.find_ip = mock.Mock(return_value=self.floating_ip)
748748

749749
# Get the command object to test
750-
self.cmd = fip.ShowFloatingIP(self.app, self.namespace)
750+
self.cmd = fip.ShowFloatingIP(self.app, None)
751751

752752
def test_floating_ip_show(self):
753753
arglist = [
@@ -791,7 +791,7 @@ def setUp(self):
791791
self.network_client.set_tags = mock.Mock(return_value=None)
792792

793793
# Get the command object to test
794-
self.cmd = fip.SetFloatingIP(self.app, self.namespace)
794+
self.cmd = fip.SetFloatingIP(self.app, None)
795795

796796
def test_port_option(self):
797797
arglist = [
@@ -1041,7 +1041,7 @@ def setUp(self):
10411041
self.network_client.set_tags = mock.Mock(return_value=None)
10421042

10431043
# Get the command object to test
1044-
self.cmd = fip.UnsetFloatingIP(self.app, self.namespace)
1044+
self.cmd = fip.UnsetFloatingIP(self.app, None)
10451045

10461046
def test_floating_ip_unset_port(self):
10471047
arglist = [

openstackclient/tests/unit/network/v2/test_floating_ip_pool_network.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ def setUp(self):
2727
super(TestListFloatingIPPoolNetwork, self).setUp()
2828

2929
# Get the command object to test
30-
self.cmd = floating_ip_pool.ListFloatingIPPool(
31-
self.app, self.namespace
32-
)
30+
self.cmd = floating_ip_pool.ListFloatingIPPool(self.app, None)
3331

3432
def test_floating_ip_list(self):
3533
arglist = []

openstackclient/tests/unit/network/v2/test_floating_ip_port_forwarding.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def setUp(self):
6262

6363
# Get the command object to test
6464
self.cmd = floating_ip_port_forwarding.CreateFloatingIPPortForwarding(
65-
self.app, self.namespace
65+
self.app, None
6666
)
6767

6868
self.columns = (
@@ -358,7 +358,7 @@ def setUp(self):
358358
self.network_client.find_ip = mock.Mock(return_value=self.floating_ip)
359359
# Get the command object to test
360360
self.cmd = floating_ip_port_forwarding.DeleteFloatingIPPortForwarding(
361-
self.app, self.namespace
361+
self.app, None
362362
)
363363

364364
def test_port_forwarding_delete(self):
@@ -496,7 +496,7 @@ def setUp(self):
496496
self.network_client.find_ip = mock.Mock(return_value=self.floating_ip)
497497
# Get the command object to test
498498
self.cmd = floating_ip_port_forwarding.ListFloatingIPPortForwarding(
499-
self.app, self.namespace
499+
self.app, None
500500
)
501501

502502
def test_port_forwarding_list(self):
@@ -567,7 +567,7 @@ def setUp(self):
567567
self.network_client.find_ip = mock.Mock(return_value=self.floating_ip)
568568
# Get the command object to test
569569
self.cmd = floating_ip_port_forwarding.SetFloatingIPPortForwarding(
570-
self.app, self.namespace
570+
self.app, None
571571
)
572572

573573
def test_set_nothing(self):
@@ -696,7 +696,7 @@ def setUp(self):
696696
self.network_client.find_ip = mock.Mock(return_value=self.floating_ip)
697697
# Get the command object to test
698698
self.cmd = floating_ip_port_forwarding.ShowFloatingIPPortForwarding(
699-
self.app, self.namespace
699+
self.app, None
700700
)
701701

702702
def test_show_no_options(self):

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class TestListIPAvailability(TestIPAvailability):
5454
def setUp(self):
5555
super(TestListIPAvailability, self).setUp()
5656

57-
self.cmd = ip_availability.ListIPAvailability(self.app, self.namespace)
57+
self.cmd = ip_availability.ListIPAvailability(self.app, None)
5858
self.network_client.network_ip_availabilities = mock.Mock(
5959
return_value=self._ip_availability
6060
)
@@ -142,7 +142,7 @@ def setUp(self):
142142
)
143143

144144
# Get the command object to test
145-
self.cmd = ip_availability.ShowIPAvailability(self.app, self.namespace)
145+
self.cmd = ip_availability.ShowIPAvailability(self.app, None)
146146

147147
def test_show_no_option(self):
148148
arglist = []

0 commit comments

Comments
 (0)