diff options
| author | yanpuqing <yanpq@awcloud.com> | 2018-06-13 05:21:53 -0400 |
|---|---|---|
| committer | Lajos Katona <lajos.katona@ericsson.com> | 2018-08-21 16:24:51 +0200 |
| commit | 3012ab4bb8db0a6ea7a0cace6f1d2e2e3685b903 (patch) | |
| tree | e0830314da790ea3eb19ea35caab3cc7e631babc /openstackclient/tests | |
| parent | 814ffb2a6f22aed640ba6adad62c1288f917b09a (diff) | |
| download | python-openstackclient-3012ab4bb8db0a6ea7a0cace6f1d2e2e3685b903.tar.gz | |
Do not require port argument when updating floating IP
When setting floating ip other properties, port argument is
force to use.
The patch modifies the command, when setting floating ip other
properties, like tags, no need port argument.
Change-Id: I908712c8913f32d3dd5fdfefe7347277d72f66de
Story: 1751431
Task: 13865
Closes-Bug: #1778666
(cherry picked from commit 402c9a21b347509520be206e28ee7d0ef4004b92)
Small changes due to changes in tag handling and how unit tests are
working.
Conflicts:
doc/source/cli/command-objects/floating-ip.rst
openstackclient/network/v2/floating_ip.py
openstackclient/tests/unit/network/v2/test_floating_ip_network.py
Diffstat (limited to 'openstackclient/tests')
| -rw-r--r-- | openstackclient/tests/unit/network/v2/test_floating_ip_network.py | 64 |
1 files changed, 64 insertions, 0 deletions
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 86f64ccd..61c463af 100644 --- a/openstackclient/tests/unit/network/v2/test_floating_ip_network.py +++ b/openstackclient/tests/unit/network/v2/test_floating_ip_network.py @@ -707,6 +707,39 @@ class TestSetFloatingIP(TestFloatingIPNetwork): "openstackclient.tests.unit.network.v2.test_floating_ip_network." + "fip._find_floating_ip" ) + def test_qos_policy_option(self, find_floating_ip_mock): + qos_policy = network_fakes.FakeNetworkQosPolicy.create_one_qos_policy() + self.network.find_qos_policy = mock.Mock(return_value=qos_policy) + find_floating_ip_mock.side_effect = [ + self.floating_ip, + ] + arglist = [ + "--qos-policy", qos_policy.id, + self.floating_ip.id, + ] + verifylist = [ + ('qos_policy', qos_policy.id), + ('floating_ip', self.floating_ip.id), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args) + + attrs = { + 'qos_policy_id': qos_policy.id, + } + find_floating_ip_mock.assert_called_once_with( + mock.ANY, + self.floating_ip.id, + ignore_missing=False, + ) + self.network.update_ip.assert_called_once_with( + self.floating_ip, **attrs) + + @mock.patch( + "openstackclient.tests.unit.network.v2.test_floating_ip_network." + + "fip._find_floating_ip" + ) def test_port_and_qos_policy_option(self, find_floating_ip_mock): qos_policy = network_fakes.FakeNetworkQosPolicy.create_one_qos_policy() self.network.find_qos_policy = mock.Mock(return_value=qos_policy) @@ -743,6 +776,37 @@ class TestSetFloatingIP(TestFloatingIPNetwork): "openstackclient.tests.unit.network.v2.test_floating_ip_network." + "fip._find_floating_ip" ) + def test_no_qos_policy_option(self, find_floating_ip_mock): + find_floating_ip_mock.side_effect = [ + self.floating_ip, + ] + arglist = [ + "--no-qos-policy", + self.floating_ip.id, + ] + verifylist = [ + ('no_qos_policy', True), + ('floating_ip', self.floating_ip.id), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args) + + attrs = { + 'qos_policy_id': None, + } + find_floating_ip_mock.assert_called_once_with( + mock.ANY, + self.floating_ip.id, + ignore_missing=False, + ) + self.network.update_ip.assert_called_once_with( + self.floating_ip, **attrs) + + @mock.patch( + "openstackclient.tests.unit.network.v2.test_floating_ip_network." + + "fip._find_floating_ip" + ) def test_port_and_no_qos_policy_option(self, find_floating_ip_mock): find_floating_ip_mock.side_effect = [ self.floating_ip, |
