diff options
| author | Tang Chen <chen.tang@easystack.cn> | 2016-02-09 14:23:28 +0800 |
|---|---|---|
| committer | Steve Martinelli <stevemar@ca.ibm.com> | 2016-02-14 04:21:08 +0000 |
| commit | d8abec33ada8b2b028d52eb8bfad2640812b9af8 (patch) | |
| tree | 2fa0f1ac02ce9bb4b7a17cdbb5a521e05f7899bd /openstackclient/tests | |
| parent | 6109dfcf63a666330e7323d957a37a251dd2b520 (diff) | |
| download | python-openstackclient-d8abec33ada8b2b028d52eb8bfad2640812b9af8.tar.gz | |
Floating IP: Neutron support for "ip floating list" command
Change-Id: I253f66f6bc64470e1a18ffea506048eb53f67d5c
partial-Bug: 1519502
Related-to: blueprint neutron-client
Diffstat (limited to 'openstackclient/tests')
| -rw-r--r-- | openstackclient/tests/network/v2/fakes.py | 5 | ||||
| -rw-r--r-- | openstackclient/tests/network/v2/test_floating_ip.py | 76 |
2 files changed, 80 insertions, 1 deletions
diff --git a/openstackclient/tests/network/v2/fakes.py b/openstackclient/tests/network/v2/fakes.py index 7dee41e0..77720ee0 100644 --- a/openstackclient/tests/network/v2/fakes.py +++ b/openstackclient/tests/network/v2/fakes.py @@ -566,12 +566,15 @@ class FakeFloatingIP(object): :param Dictionary methods: A dictionary with all methods :return: - A FakeResource object, with id, ip + A FakeResource object, with id, ip, and so on """ # Set default attributes. floating_ip_attrs = { 'id': 'floating-ip-id-' + uuid.uuid4().hex, 'ip': '1.0.9.0', + 'fixed_ip': '2.0.9.0', + 'instance_id': 'server-id-' + uuid.uuid4().hex, + 'pool': 'public', } # Overwrite default attributes. diff --git a/openstackclient/tests/network/v2/test_floating_ip.py b/openstackclient/tests/network/v2/test_floating_ip.py index 49131f36..cfe3d11d 100644 --- a/openstackclient/tests/network/v2/test_floating_ip.py +++ b/openstackclient/tests/network/v2/test_floating_ip.py @@ -59,6 +59,43 @@ class TestDeleteFloatingIPNetwork(TestFloatingIPNetwork): self.assertIsNone(result) +class TestListFloatingIPNetwork(TestFloatingIPNetwork): + + # The floating ips to list up + floating_ips = network_fakes.FakeFloatingIP.create_floating_ips(count=3) + + columns = ('ID', 'Floating IP', 'Fixed IP', 'Server ID', 'Pool') + + data = [] + for ip in floating_ips: + data.append(( + ip.id, + ip.ip, + ip.fixed_ip, + ip.instance_id, + ip.pool, + )) + + def setUp(self): + super(TestListFloatingIPNetwork, self).setUp() + + self.network.ips = mock.Mock(return_value=self.floating_ips) + + # Get the command object to test + self.cmd = floating_ip.ListFloatingIP(self.app, self.namespace) + + def test_floating_ip_list(self): + arglist = [] + verifylist = [] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + columns, data = self.cmd.take_action(parsed_args) + + self.network.ips.assert_called_with(**{}) + self.assertEqual(self.columns, columns) + self.assertEqual(self.data, list(data)) + + # Tests for Nova network # class TestFloatingIPCompute(compute_fakes.TestComputev2): @@ -103,3 +140,42 @@ class TestDeleteFloatingIPCompute(TestFloatingIPCompute): self.floating_ip.id ) self.assertIsNone(result) + + +class TestListFloatingIPCompute(TestFloatingIPCompute): + + # The floating ips to be list up + floating_ips = network_fakes.FakeFloatingIP.create_floating_ips(count=3) + + columns = ('ID', 'Floating IP', 'Fixed IP', 'Server ID', 'Pool') + + data = [] + for ip in floating_ips: + data.append(( + ip.id, + ip.ip, + ip.fixed_ip, + ip.instance_id, + ip.pool, + )) + + def setUp(self): + super(TestListFloatingIPCompute, self).setUp() + + self.app.client_manager.network_endpoint_enabled = False + + self.compute.floating_ips.list.return_value = self.floating_ips + + # Get the command object to test + self.cmd = floating_ip.ListFloatingIP(self.app, None) + + def test_floating_ip_list(self): + arglist = [] + verifylist = [] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + columns, data = self.cmd.take_action(parsed_args) + + self.compute.floating_ips.list.assert_called_with() + self.assertEqual(self.columns, columns) + self.assertEqual(self.data, list(data)) |
