diff options
Diffstat (limited to 'openstackclient/tests')
| -rw-r--r-- | openstackclient/tests/network/v2/fakes.py | 13 | ||||
| -rw-r--r-- | openstackclient/tests/network/v2/test_floating_ip.py | 22 | ||||
| -rw-r--r-- | openstackclient/tests/network/v2/test_subnet_pool.py | 69 |
3 files changed, 93 insertions, 11 deletions
diff --git a/openstackclient/tests/network/v2/fakes.py b/openstackclient/tests/network/v2/fakes.py index b48cde3e..fe31aab9 100644 --- a/openstackclient/tests/network/v2/fakes.py +++ b/openstackclient/tests/network/v2/fakes.py @@ -619,10 +619,9 @@ class FakeFloatingIP(object): # 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', + 'floating_ip_address': '1.0.9.0', + 'fixed_ip_address': '2.0.9.0', + 'port_id': 'port-id-' + uuid.uuid4().hex, } # Overwrite default attributes. @@ -699,6 +698,9 @@ class FakeSubnetPool(object): subnet_pool_attrs = { 'id': 'subnet-pool-id-' + uuid.uuid4().hex, 'name': 'subnet-pool-name-' + uuid.uuid4().hex, + 'prefixes': ['10.0.0.0/24', '10.1.0.0/24'], + 'default_prefixlen': 8, + 'address_scope_id': 'address-scope-id-' + uuid.uuid4().hex, } # Overwrite default attributes. @@ -706,7 +708,8 @@ class FakeSubnetPool(object): # Set default methods. subnet_pool_methods = { - 'keys': ['id', 'name'] + 'keys': ['id', 'name', 'prefixes', 'default_prefixlen', + 'address_scope_id'] } # Overwrite default methods. diff --git a/openstackclient/tests/network/v2/test_floating_ip.py b/openstackclient/tests/network/v2/test_floating_ip.py index 031dcdac..a29d6913 100644 --- a/openstackclient/tests/network/v2/test_floating_ip.py +++ b/openstackclient/tests/network/v2/test_floating_ip.py @@ -64,16 +64,20 @@ 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') + columns = ( + 'ID', + 'Floating IP Address', + 'Fixed IP Address', + 'Port', + ) data = [] for ip in floating_ips: data.append(( ip.id, - ip.ip, - ip.fixed_ip, - ip.instance_id, - ip.pool, + ip.floating_ip_address, + ip.fixed_ip_address, + ip.port_id, )) def setUp(self): @@ -147,7 +151,13 @@ class TestListFloatingIPCompute(TestFloatingIPCompute): # The floating ips to be list up floating_ips = compute_fakes.FakeFloatingIP.create_floating_ips(count=3) - columns = ('ID', 'Floating IP', 'Fixed IP', 'Server ID', 'Pool') + columns = ( + 'ID', + 'Floating IP Address', + 'Fixed IP Address', + 'Server', + 'Pool', + ) data = [] for ip in floating_ips: diff --git a/openstackclient/tests/network/v2/test_subnet_pool.py b/openstackclient/tests/network/v2/test_subnet_pool.py index 0cbfa1ee..28be5937 100644 --- a/openstackclient/tests/network/v2/test_subnet_pool.py +++ b/openstackclient/tests/network/v2/test_subnet_pool.py @@ -55,3 +55,72 @@ class TestDeleteSubnetPool(TestSubnetPool): self.network.delete_subnet_pool.assert_called_with(self._subnet_pool) self.assertIsNone(result) + + +class TestListSubnetPool(TestSubnetPool): + # The subnet pools going to be listed up. + _subnet_pools = network_fakes.FakeSubnetPool.create_subnet_pools(count=3) + + columns = ( + 'ID', + 'Name', + 'Prefixes', + ) + columns_long = columns + ( + 'Default Prefix Length', + 'Address Scope', + ) + + data = [] + for pool in _subnet_pools: + data.append(( + pool.id, + pool.name, + pool.prefixes, + )) + + data_long = [] + for pool in _subnet_pools: + data_long.append(( + pool.id, + pool.name, + pool.prefixes, + pool.default_prefixlen, + pool.address_scope_id, + )) + + def setUp(self): + super(TestListSubnetPool, self).setUp() + + # Get the command object to test + self.cmd = subnet_pool.ListSubnetPool(self.app, self.namespace) + + self.network.subnet_pools = mock.Mock(return_value=self._subnet_pools) + + def test_subnet_pool_list_no_option(self): + arglist = [] + verifylist = [ + ('long', False), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + columns, data = self.cmd.take_action(parsed_args) + + self.network.subnet_pools.assert_called_with() + self.assertEqual(self.columns, columns) + self.assertEqual(self.data, list(data)) + + def test_subnet_pool_list_long(self): + arglist = [ + '--long', + ] + verifylist = [ + ('long', True), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + columns, data = self.cmd.take_action(parsed_args) + + self.network.subnet_pools.assert_called_with() + self.assertEqual(self.columns_long, columns) + self.assertEqual(self.data_long, list(data)) |
