diff options
Diffstat (limited to 'openstackclient/tests')
| -rw-r--r-- | openstackclient/tests/functional/volume/v2/test_volume_type.py | 5 | ||||
| -rw-r--r-- | openstackclient/tests/unit/network/v2/fakes.py | 29 | ||||
| -rw-r--r-- | openstackclient/tests/unit/network/v2/test_network.py | 55 | ||||
| -rw-r--r-- | openstackclient/tests/unit/network/v2/test_port.py | 2 | ||||
| -rw-r--r-- | openstackclient/tests/unit/network/v2/test_router.py | 8 | ||||
| -rw-r--r-- | openstackclient/tests/unit/test_shell.py | 2 | ||||
| -rw-r--r-- | openstackclient/tests/unit/volume/v1/test_volume.py | 136 | ||||
| -rw-r--r-- | openstackclient/tests/unit/volume/v2/test_snapshot.py | 28 | ||||
| -rw-r--r-- | openstackclient/tests/unit/volume/v2/test_type.py | 27 | ||||
| -rw-r--r-- | openstackclient/tests/unit/volume/v2/test_volume.py | 148 |
10 files changed, 409 insertions, 31 deletions
diff --git a/openstackclient/tests/functional/volume/v2/test_volume_type.py b/openstackclient/tests/functional/volume/v2/test_volume_type.py index d8bd3a96..b4df5b2d 100644 --- a/openstackclient/tests/functional/volume/v2/test_volume_type.py +++ b/openstackclient/tests/functional/volume/v2/test_volume_type.py @@ -42,6 +42,11 @@ class VolumeTypeTests(common.BaseVolumeTests): raw_output = self.openstack('volume type list' + opts) self.assertIn(self.NAME, raw_output) + def test_volume_type_list_default(self): + opts = self.get_opts(self.HEADERS) + raw_output = self.openstack('volume type list --default' + opts) + self.assertEqual("lvmdriver-1\n", raw_output) + def test_volume_type_show(self): opts = self.get_opts(self.FIELDS) raw_output = self.openstack('volume type show ' + self.NAME + opts) diff --git a/openstackclient/tests/unit/network/v2/fakes.py b/openstackclient/tests/unit/network/v2/fakes.py index 97d07076..84f145fb 100644 --- a/openstackclient/tests/unit/network/v2/fakes.py +++ b/openstackclient/tests/unit/network/v2/fakes.py @@ -297,15 +297,17 @@ class FakeNetwork(object): 'admin_state_up': True, 'shared': False, 'subnets': ['a', 'b'], - 'provider_network_type': 'vlan', - 'provider_physical_network': 'physnet1', - 'provider_segmentation_id': "400", + 'provider:network_type': 'vlan', + 'provider:physical_network': 'physnet1', + 'provider:segmentation_id': "400", 'router:external': True, 'availability_zones': [], 'availability_zone_hints': [], 'is_default': False, 'port_security_enabled': True, 'qos_policy_id': 'qos-policy-id-' + uuid.uuid4().hex, + 'ipv4_address_scope': 'ipv4' + uuid.uuid4().hex, + 'ipv6_address_scope': 'ipv6' + uuid.uuid4().hex, } # Overwrite default attributes. @@ -317,8 +319,21 @@ class FakeNetwork(object): # Set attributes with special mapping in OpenStack SDK. network.project_id = network_attrs['tenant_id'] network.is_router_external = network_attrs['router:external'] + network.is_admin_state_up = network_attrs['admin_state_up'] network.is_port_security_enabled = \ network_attrs['port_security_enabled'] + network.subnet_ids = network_attrs['subnets'] + network.is_shared = network_attrs['shared'] + network.provider_network_type = \ + network_attrs['provider:network_type'] + network.provider_physical_network = \ + network_attrs['provider:physical_network'] + network.provider_segmentation_id = \ + network_attrs['provider:segmentation_id'] + network.ipv4_address_scope_id = \ + network_attrs['ipv4_address_scope'] + network.ipv6_address_scope_id = \ + network_attrs['ipv6_address_scope'] return network @@ -461,12 +476,15 @@ class FakePort(object): loaded=True) # Set attributes with special mappings in OpenStack SDK. - port.project_id = port_attrs['tenant_id'] port.binding_host_id = port_attrs['binding:host_id'] port.binding_profile = port_attrs['binding:profile'] port.binding_vif_details = port_attrs['binding:vif_details'] port.binding_vif_type = port_attrs['binding:vif_type'] port.binding_vnic_type = port_attrs['binding:vnic_type'] + port.is_admin_state_up = port_attrs['admin_state_up'] + port.is_port_security_enabled = port_attrs['port_security_enabled'] + port.project_id = port_attrs['tenant_id'] + port.security_group_ids = port_attrs['security_groups'] return port @@ -834,6 +852,9 @@ class FakeRouter(object): # Set attributes with special mapping in OpenStack SDK. router.project_id = router_attrs['tenant_id'] + router.is_admin_state_up = router_attrs['admin_state_up'] + router.is_distributed = router_attrs['distributed'] + router.is_ha = router_attrs['ha'] return router diff --git a/openstackclient/tests/unit/network/v2/test_network.py b/openstackclient/tests/unit/network/v2/test_network.py index 96b1b102..c5283443 100644 --- a/openstackclient/tests/unit/network/v2/test_network.py +++ b/openstackclient/tests/unit/network/v2/test_network.py @@ -62,13 +62,15 @@ class TestCreateNetworkIdentityV3(TestNetwork): 'availability_zones', 'description', 'id', + 'ipv4_address_scope', + 'ipv6_address_scope', 'is_default', 'name', 'port_security_enabled', 'project_id', - 'provider_network_type', - 'provider_physical_network', - 'provider_segmentation_id', + 'provider:network_type', + 'provider:physical_network', + 'provider:segmentation_id', 'qos_policy_id', 'router:external', 'shared', @@ -82,6 +84,8 @@ class TestCreateNetworkIdentityV3(TestNetwork): utils.format_list(_network.availability_zones), _network.description, _network.id, + _network.ipv4_address_scope_id, + _network.ipv6_address_scope_id, _network.is_default, _network.name, _network.is_port_security_enabled, @@ -236,13 +240,15 @@ class TestCreateNetworkIdentityV2(TestNetwork): 'availability_zones', 'description', 'id', + 'ipv4_address_scope', + 'ipv6_address_scope', 'is_default', 'name', 'port_security_enabled', 'project_id', - 'provider_network_type', - 'provider_physical_network', - 'provider_segmentation_id', + 'provider:network_type', + 'provider:physical_network', + 'provider:segmentation_id', 'qos_policy_id', 'router:external', 'shared', @@ -256,6 +262,8 @@ class TestCreateNetworkIdentityV2(TestNetwork): utils.format_list(_network.availability_zones), _network.description, _network.id, + _network.ipv4_address_scope_id, + _network.ipv6_address_scope_id, _network.is_default, _network.name, _network.is_port_security_enabled, @@ -512,7 +520,7 @@ class TestListNetwork(TestNetwork): columns, data = self.cmd.take_action(parsed_args) self.network.networks.assert_called_once_with( - **{'router:external': True} + **{'router:external': True, 'is_router_external': True} ) self.assertEqual(self.columns, columns) self.assertEqual(self.data, list(data)) @@ -529,7 +537,7 @@ class TestListNetwork(TestNetwork): columns, data = self.cmd.take_action(parsed_args) self.network.networks.assert_called_once_with( - **{'router:external': False} + **{'router:external': False, 'is_router_external': False} ) self.assertEqual(self.columns, columns) self.assertEqual(self.data, list(data)) @@ -585,7 +593,7 @@ class TestListNetwork(TestNetwork): columns, data = self.cmd.take_action(parsed_args) self.network.networks.assert_called_once_with( - **{'admin_state_up': True} + **{'admin_state_up': True, 'is_admin_state_up': True} ) self.assertEqual(self.columns, columns) self.assertEqual(self.data, list(data)) @@ -603,7 +611,7 @@ class TestListNetwork(TestNetwork): columns, data = self.cmd.take_action(parsed_args) self.network.networks.assert_called_once_with( - **{'admin_state_up': False} + **{'admin_state_up': False, 'is_admin_state_up': False} ) self.assertEqual(self.columns, columns) self.assertEqual(self.data, list(data)) @@ -621,7 +629,7 @@ class TestListNetwork(TestNetwork): columns, data = self.cmd.take_action(parsed_args) self.network.networks.assert_called_once_with( - **{'tenant_id': project.id} + **{'tenant_id': project.id, 'project_id': project.id} ) self.assertEqual(self.columns, columns) @@ -640,7 +648,7 @@ class TestListNetwork(TestNetwork): parsed_args = self.check_parser(self.cmd, arglist, verifylist) columns, data = self.cmd.take_action(parsed_args) - filters = {'tenant_id': project.id} + filters = {'tenant_id': project.id, 'project_id': project.id} self.network.networks.assert_called_once_with(**filters) self.assertEqual(self.columns, columns) @@ -658,7 +666,7 @@ class TestListNetwork(TestNetwork): columns, data = self.cmd.take_action(parsed_args) self.network.networks.assert_called_once_with( - **{'shared': True} + **{'shared': True, 'is_shared': True} ) self.assertEqual(self.columns, columns) self.assertEqual(self.data, list(data)) @@ -675,7 +683,7 @@ class TestListNetwork(TestNetwork): columns, data = self.cmd.take_action(parsed_args) self.network.networks.assert_called_once_with( - **{'shared': False} + **{'shared': False, 'is_shared': False} ) self.assertEqual(self.columns, columns) self.assertEqual(self.data, list(data)) @@ -711,7 +719,8 @@ class TestListNetwork(TestNetwork): columns, data = self.cmd.take_action(parsed_args) self.network.networks.assert_called_once_with( - **{'provider:network_type': network_type} + **{'provider:network_type': network_type, + 'provider_network_type': network_type} ) self.assertEqual(self.columns, columns) self.assertEqual(self.data, list(data)) @@ -728,7 +737,8 @@ class TestListNetwork(TestNetwork): columns, data = self.cmd.take_action(parsed_args) self.network.networks.assert_called_once_with( - **{'provider:physical_network': physical_network} + **{'provider:physical_network': physical_network, + 'provider_physical_network': physical_network} ) self.assertEqual(self.columns, columns) self.assertEqual(self.data, list(data)) @@ -745,7 +755,8 @@ class TestListNetwork(TestNetwork): columns, data = self.cmd.take_action(parsed_args) self.network.networks.assert_called_once_with( - **{'provider:segmentation_id': segmentation_id} + **{'provider:segmentation_id': segmentation_id, + 'provider_segmentation_id': segmentation_id} ) self.assertEqual(self.columns, columns) self.assertEqual(self.data, list(data)) @@ -878,13 +889,15 @@ class TestShowNetwork(TestNetwork): 'availability_zones', 'description', 'id', + 'ipv4_address_scope', + 'ipv6_address_scope', 'is_default', 'name', 'port_security_enabled', 'project_id', - 'provider_network_type', - 'provider_physical_network', - 'provider_segmentation_id', + 'provider:network_type', + 'provider:physical_network', + 'provider:segmentation_id', 'qos_policy_id', 'router:external', 'shared', @@ -898,6 +911,8 @@ class TestShowNetwork(TestNetwork): utils.format_list(_network.availability_zones), _network.description, _network.id, + _network.ipv4_address_scope_id, + _network.ipv6_address_scope_id, _network.is_default, _network.name, _network.is_port_security_enabled, diff --git a/openstackclient/tests/unit/network/v2/test_port.py b/openstackclient/tests/unit/network/v2/test_port.py index aeb9884a..255e8116 100644 --- a/openstackclient/tests/unit/network/v2/test_port.py +++ b/openstackclient/tests/unit/network/v2/test_port.py @@ -324,7 +324,7 @@ class TestCreatePort(TestPort): self.assertEqual(ref_columns, columns) self.assertEqual(ref_data, data) - def test_create_with_no_secuirty_groups(self): + def test_create_with_no_security_groups(self): arglist = [ '--network', self._port.network_id, '--no-security-group', diff --git a/openstackclient/tests/unit/network/v2/test_router.py b/openstackclient/tests/unit/network/v2/test_router.py index b0409447..8c1d5804 100644 --- a/openstackclient/tests/unit/network/v2/test_router.py +++ b/openstackclient/tests/unit/network/v2/test_router.py @@ -459,7 +459,7 @@ class TestListRouter(TestRouter): columns, data = self.cmd.take_action(parsed_args) self.network.routers.assert_called_once_with( - **{'admin_state_up': True} + **{'admin_state_up': True, 'is_admin_state_up': True} ) self.assertEqual(self.columns, columns) self.assertEqual(self.data, list(data)) @@ -476,7 +476,7 @@ class TestListRouter(TestRouter): columns, data = self.cmd.take_action(parsed_args) self.network.routers.assert_called_once_with( - **{'admin_state_up': False} + **{'admin_state_up': False, 'is_admin_state_up': False} ) self.assertEqual(self.columns, columns) @@ -494,7 +494,7 @@ class TestListRouter(TestRouter): parsed_args = self.check_parser(self.cmd, arglist, verifylist) columns, data = self.cmd.take_action(parsed_args) - filters = {'tenant_id': project.id} + filters = {'tenant_id': project.id, 'project_id': project.id} self.network.routers.assert_called_once_with(**filters) self.assertEqual(self.columns, columns) @@ -514,7 +514,7 @@ class TestListRouter(TestRouter): parsed_args = self.check_parser(self.cmd, arglist, verifylist) columns, data = self.cmd.take_action(parsed_args) - filters = {'tenant_id': project.id} + filters = {'tenant_id': project.id, 'project_id': project.id} self.network.routers.assert_called_once_with(**filters) self.assertEqual(self.columns, columns) diff --git a/openstackclient/tests/unit/test_shell.py b/openstackclient/tests/unit/test_shell.py index 3d91da9b..b9fac684 100644 --- a/openstackclient/tests/unit/test_shell.py +++ b/openstackclient/tests/unit/test_shell.py @@ -422,7 +422,7 @@ class TestShellArgV(TestShell): Use the argv supplied by the test runner so we get actual Python runtime behaviour; we only need to check the type of argv[0] - which will alwyas be present. + which will always be present. """ with mock.patch( diff --git a/openstackclient/tests/unit/volume/v1/test_volume.py b/openstackclient/tests/unit/volume/v1/test_volume.py index 7a44dea8..6c6d9a1d 100644 --- a/openstackclient/tests/unit/volume/v1/test_volume.py +++ b/openstackclient/tests/unit/volume/v1/test_volume.py @@ -431,6 +431,142 @@ class TestVolumeCreate(TestVolume): self.assertEqual(self.columns, columns) self.assertEqual(self.datalist, data) + def test_volume_create_with_bootable_and_readonly(self): + arglist = [ + '--bootable', + '--read-only', + '--size', str(self.new_volume.size), + self.new_volume.display_name, + ] + verifylist = [ + ('bootable', True), + ('non_bootable', False), + ('read_only', True), + ('read_write', False), + ('size', self.new_volume.size), + ('name', self.new_volume.display_name), + ] + + parsed_args = self.check_parser( + self.cmd, arglist, verifylist) + + columns, data = self.cmd.take_action(parsed_args) + + self.volumes_mock.create.assert_called_with( + self.new_volume.size, + None, + None, + self.new_volume.display_name, + None, + None, + None, + None, + None, + None, + None, + ) + + self.assertEqual(self.columns, columns) + self.assertEqual(self.datalist, data) + self.volumes_mock.set_bootable.assert_called_with( + self.new_volume.id, True) + self.volumes_mock.update_readonly_flag.assert_called_with( + self.new_volume.id, True) + + def test_volume_create_with_nonbootable_and_readwrite(self): + arglist = [ + '--non-bootable', + '--read-write', + '--size', str(self.new_volume.size), + self.new_volume.display_name, + ] + verifylist = [ + ('bootable', False), + ('non_bootable', True), + ('read_only', False), + ('read_write', True), + ('size', self.new_volume.size), + ('name', self.new_volume.display_name), + ] + + parsed_args = self.check_parser( + self.cmd, arglist, verifylist) + + columns, data = self.cmd.take_action(parsed_args) + + self.volumes_mock.create.assert_called_with( + self.new_volume.size, + None, + None, + self.new_volume.display_name, + None, + None, + None, + None, + None, + None, + None, + ) + + self.assertEqual(self.columns, columns) + self.assertEqual(self.datalist, data) + self.volumes_mock.set_bootable.assert_called_with( + self.new_volume.id, False) + self.volumes_mock.update_readonly_flag.assert_called_with( + self.new_volume.id, False) + + @mock.patch.object(volume.LOG, 'error') + def test_volume_create_with_bootable_and_readonly_fail( + self, mock_error): + + self.volumes_mock.set_bootable.side_effect = ( + exceptions.CommandError()) + + self.volumes_mock.update_readonly_flag.side_effect = ( + exceptions.CommandError()) + + arglist = [ + '--bootable', + '--read-only', + '--size', str(self.new_volume.size), + self.new_volume.display_name, + ] + verifylist = [ + ('bootable', True), + ('non_bootable', False), + ('read_only', True), + ('read_write', False), + ('size', self.new_volume.size), + ('name', self.new_volume.display_name), + ] + + parsed_args = self.check_parser( + self.cmd, arglist, verifylist) + + columns, data = self.cmd.take_action(parsed_args) + + self.volumes_mock.create.assert_called_with( + self.new_volume.size, + None, + None, + self.new_volume.display_name, + None, + None, + None, + None, + None, + None, + None, + ) + + self.assertEqual(2, mock_error.call_count) + self.assertEqual(self.columns, columns) + self.assertEqual(self.datalist, data) + self.volumes_mock.set_bootable.assert_called_with( + self.new_volume.id, True) + self.volumes_mock.update_readonly_flag.assert_called_with( + self.new_volume.id, True) + def test_volume_create_without_size(self): arglist = [ self.new_volume.display_name, diff --git a/openstackclient/tests/unit/volume/v2/test_snapshot.py b/openstackclient/tests/unit/volume/v2/test_snapshot.py index cedf21a9..8ce356ae 100644 --- a/openstackclient/tests/unit/volume/v2/test_snapshot.py +++ b/openstackclient/tests/unit/volume/v2/test_snapshot.py @@ -67,6 +67,7 @@ class TestSnapshotCreate(TestSnapshot): self.volumes_mock.get.return_value = self.volume self.snapshots_mock.create.return_value = self.new_snapshot + self.snapshots_mock.manage.return_value = self.new_snapshot # Get the command object to test self.cmd = volume_snapshot.CreateVolumeSnapshot(self.app, None) @@ -152,6 +153,33 @@ class TestSnapshotCreate(TestSnapshot): self.assertEqual(self.columns, columns) self.assertEqual(self.data, data) + def test_snapshot_create_without_remote_source(self): + arglist = [ + '--remote-source', 'source-name=test_source_name', + '--remote-source', 'source-id=test_source_id', + '--volume', self.new_snapshot.volume_id, + ] + ref_dict = {'source-name': 'test_source_name', + 'source-id': 'test_source_id'} + verifylist = [ + ('remote_source', ref_dict), + ('volume', self.new_snapshot.volume_id), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + columns, data = self.cmd.take_action(parsed_args) + + self.snapshots_mock.manage.assert_called_with( + volume_id=self.new_snapshot.volume_id, + ref=ref_dict, + name=None, + description=None, + metadata=None, + ) + self.snapshots_mock.create.assert_not_called() + self.assertEqual(self.columns, columns) + self.assertEqual(self.data, data) + class TestSnapshotDelete(TestSnapshot): diff --git a/openstackclient/tests/unit/volume/v2/test_type.py b/openstackclient/tests/unit/volume/v2/test_type.py index 325872d7..0d556e13 100644 --- a/openstackclient/tests/unit/volume/v2/test_type.py +++ b/openstackclient/tests/unit/volume/v2/test_type.py @@ -172,7 +172,11 @@ class TestTypeList(TestType): "Description", "Properties" ] - + data_with_default_type = [( + volume_types[0].id, + volume_types[0].name, + True + )] data = [] for t in volume_types: data.append(( @@ -194,6 +198,7 @@ class TestTypeList(TestType): super(TestTypeList, self).setUp() self.types_mock.list.return_value = self.volume_types + self.types_mock.default.return_value = self.volume_types[0] # get the command to test self.cmd = volume_type.ListVolumeType(self.app, None) @@ -203,6 +208,7 @@ class TestTypeList(TestType): ("long", False), ("private", False), ("public", False), + ("default", False), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -220,6 +226,7 @@ class TestTypeList(TestType): ("long", True), ("private", False), ("public", True), + ("default", False), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -236,6 +243,7 @@ class TestTypeList(TestType): ("long", False), ("private", True), ("public", False), + ("default", False), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -244,6 +252,23 @@ class TestTypeList(TestType): self.assertEqual(self.columns, columns) self.assertEqual(self.data, list(data)) + def test_type_list_with_default_option(self): + arglist = [ + "--default", + ] + verifylist = [ + ("long", False), + ("private", False), + ("public", False), + ("default", True), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + columns, data = self.cmd.take_action(parsed_args) + self.types_mock.default.assert_called_once_with() + self.assertEqual(self.columns, columns) + self.assertEqual(self.data_with_default_type, list(data)) + class TestTypeSet(TestType): diff --git a/openstackclient/tests/unit/volume/v2/test_volume.py b/openstackclient/tests/unit/volume/v2/test_volume.py index 41728342..1529c2e2 100644 --- a/openstackclient/tests/unit/volume/v2/test_volume.py +++ b/openstackclient/tests/unit/volume/v2/test_volume.py @@ -450,6 +450,154 @@ class TestVolumeCreate(TestVolume): self.assertEqual(self.columns, columns) self.assertEqual(self.datalist, data) + def test_volume_create_with_bootable_and_readonly(self): + arglist = [ + '--bootable', + '--read-only', + '--size', str(self.new_volume.size), + self.new_volume.name, + ] + verifylist = [ + ('bootable', True), + ('non_bootable', False), + ('read_only', True), + ('read_write', False), + ('size', self.new_volume.size), + ('name', self.new_volume.name), + ] + + parsed_args = self.check_parser( + self.cmd, arglist, verifylist) + + columns, data = self.cmd.take_action(parsed_args) + + self.volumes_mock.create.assert_called_with( + size=self.new_volume.size, + snapshot_id=None, + name=self.new_volume.name, + description=None, + volume_type=None, + user_id=None, + project_id=None, + availability_zone=None, + metadata=None, + imageRef=None, + source_volid=None, + consistencygroup_id=None, + source_replica=None, + multiattach=False, + scheduler_hints=None, + ) + + self.assertEqual(self.columns, columns) + self.assertEqual(self.datalist, data) + self.volumes_mock.set_bootable.assert_called_with( + self.new_volume.id, True) + self.volumes_mock.update_readonly_flag.assert_called_with( + self.new_volume.id, True) + + def test_volume_create_with_nonbootable_and_readwrite(self): + arglist = [ + '--non-bootable', + '--read-write', + '--size', str(self.new_volume.size), + self.new_volume.name, + ] + verifylist = [ + ('bootable', False), + ('non_bootable', True), + ('read_only', False), + ('read_write', True), + ('size', self.new_volume.size), + ('name', self.new_volume.name), + ] + + parsed_args = self.check_parser( + self.cmd, arglist, verifylist) + + columns, data = self.cmd.take_action(parsed_args) + + self.volumes_mock.create.assert_called_with( + size=self.new_volume.size, + snapshot_id=None, + name=self.new_volume.name, + description=None, + volume_type=None, + user_id=None, + project_id=None, + availability_zone=None, + metadata=None, + imageRef=None, + source_volid=None, + consistencygroup_id=None, + source_replica=None, + multiattach=False, + scheduler_hints=None, + ) + + self.assertEqual(self.columns, columns) + self.assertEqual(self.datalist, data) + self.volumes_mock.set_bootable.assert_called_with( + self.new_volume.id, False) + self.volumes_mock.update_readonly_flag.assert_called_with( + self.new_volume.id, False) + + @mock.patch.object(volume.LOG, 'error') + def test_volume_create_with_bootable_and_readonly_fail( + self, mock_error): + + self.volumes_mock.set_bootable.side_effect = ( + exceptions.CommandError()) + + self.volumes_mock.update_readonly_flag.side_effect = ( + exceptions.CommandError()) + + arglist = [ + '--bootable', + '--read-only', + '--size', str(self.new_volume.size), + self.new_volume.name, + ] + verifylist = [ + ('bootable', True), + ('non_bootable', False), + ('read_only', True), + ('read_write', False), + ('size', self.new_volume.size), + ('name', self.new_volume.name), + ] + + parsed_args = self.check_parser( + self.cmd, arglist, verifylist) + + columns, data = self.cmd.take_action(parsed_args) + + self.volumes_mock.create.assert_called_with( + size=self.new_volume.size, + snapshot_id=None, + name=self.new_volume.name, + description=None, + volume_type=None, + user_id=None, + project_id=None, + availability_zone=None, + metadata=None, + imageRef=None, + source_volid=None, + consistencygroup_id=None, + source_replica=None, + multiattach=False, + scheduler_hints=None, + ) + + self.assertEqual(2, mock_error.call_count) + self.assertEqual(self.columns, columns) + self.assertEqual(self.datalist, data) + self.volumes_mock.set_bootable.assert_called_with( + self.new_volume.id, True) + self.volumes_mock.update_readonly_flag.assert_called_with( + self.new_volume.id, True) + def test_volume_create_with_source_replicated(self): self.volumes_mock.get.return_value = self.new_volume arglist = [ |
