|
11 | 11 | # under the License. |
12 | 12 | # |
13 | 13 |
|
14 | | -from unittest import mock |
15 | 14 | from unittest.mock import call |
16 | 15 |
|
17 | 16 | from osc_lib import exceptions |
@@ -58,8 +57,8 @@ class TestCreateAddressGroup(TestAddressGroup): |
58 | 57 |
|
59 | 58 | def setUp(self): |
60 | 59 | super().setUp() |
61 | | - self.network_client.create_address_group = mock.Mock( |
62 | | - return_value=self.new_address_group |
| 60 | + self.network_client.create_address_group.return_value = ( |
| 61 | + self.new_address_group |
63 | 62 | ) |
64 | 63 |
|
65 | 64 | # Get the command object to test |
@@ -145,7 +144,7 @@ class TestDeleteAddressGroup(TestAddressGroup): |
145 | 144 |
|
146 | 145 | def setUp(self): |
147 | 146 | super().setUp() |
148 | | - self.network_client.delete_address_group = mock.Mock(return_value=None) |
| 147 | + self.network_client.delete_address_group.return_value = None |
149 | 148 | self.network_client.find_address_group = ( |
150 | 149 | network_fakes.get_address_groups( |
151 | 150 | address_groups=self._address_groups |
@@ -206,9 +205,7 @@ def test_multi_address_groups_delete_with_exception(self): |
206 | 205 | parsed_args = self.check_parser(self.cmd, arglist, verifylist) |
207 | 206 |
|
208 | 207 | find_mock_result = [self._address_groups[0], exceptions.CommandError] |
209 | | - self.network_client.find_address_group = mock.Mock( |
210 | | - side_effect=find_mock_result |
211 | | - ) |
| 208 | + self.network_client.find_address_group.side_effect = find_mock_result |
212 | 209 |
|
213 | 210 | try: |
214 | 211 | self.cmd.take_action(parsed_args) |
@@ -251,9 +248,7 @@ class TestListAddressGroup(TestAddressGroup): |
251 | 248 |
|
252 | 249 | def setUp(self): |
253 | 250 | super().setUp() |
254 | | - self.network_client.address_groups = mock.Mock( |
255 | | - return_value=self.address_groups |
256 | | - ) |
| 251 | + self.network_client.address_groups.return_value = self.address_groups |
257 | 252 |
|
258 | 253 | # Get the command object to test |
259 | 254 | self.cmd = address_group.ListAddressGroup(self.app, None) |
@@ -333,13 +328,15 @@ class TestSetAddressGroup(TestAddressGroup): |
333 | 328 |
|
334 | 329 | def setUp(self): |
335 | 330 | super().setUp() |
336 | | - self.network_client.update_address_group = mock.Mock(return_value=None) |
337 | | - self.network_client.find_address_group = mock.Mock( |
338 | | - return_value=self._address_group |
| 331 | + self.network_client.update_address_group.return_value = None |
| 332 | + self.network_client.find_address_group.return_value = ( |
| 333 | + self._address_group |
339 | 334 | ) |
340 | | - self.network_client.add_addresses_to_address_group = mock.Mock( |
341 | | - return_value=self._address_group |
| 335 | + |
| 336 | + self.network_client.add_addresses_to_address_group.return_value = ( |
| 337 | + self._address_group |
342 | 338 | ) |
| 339 | + |
343 | 340 | # Get the command object to test |
344 | 341 | self.cmd = address_group.SetAddressGroup(self.app, None) |
345 | 342 |
|
@@ -442,8 +439,8 @@ class TestShowAddressGroup(TestAddressGroup): |
442 | 439 |
|
443 | 440 | def setUp(self): |
444 | 441 | super().setUp() |
445 | | - self.network_client.find_address_group = mock.Mock( |
446 | | - return_value=self._address_group |
| 442 | + self.network_client.find_address_group.return_value = ( |
| 443 | + self._address_group |
447 | 444 | ) |
448 | 445 |
|
449 | 446 | # Get the command object to test |
@@ -486,12 +483,12 @@ class TestUnsetAddressGroup(TestAddressGroup): |
486 | 483 |
|
487 | 484 | def setUp(self): |
488 | 485 | super().setUp() |
489 | | - self.network_client.find_address_group = mock.Mock( |
490 | | - return_value=self._address_group |
491 | | - ) |
492 | | - self.network_client.remove_addresses_from_address_group = mock.Mock( |
493 | | - return_value=self._address_group |
| 486 | + self.network_client.find_address_group.return_value = ( |
| 487 | + self._address_group |
494 | 488 | ) |
| 489 | + |
| 490 | + self.network_client.remove_addresses_from_address_group.return_value = self._address_group |
| 491 | + |
495 | 492 | # Get the command object to test |
496 | 493 | self.cmd = address_group.UnsetAddressGroup(self.app, None) |
497 | 494 |
|
|
0 commit comments