diff options
Diffstat (limited to 'openstackclient/tests/volume')
| -rw-r--r-- | openstackclient/tests/volume/v2/fakes.py | 5 | ||||
| -rw-r--r-- | openstackclient/tests/volume/v2/test_volume.py | 82 |
2 files changed, 44 insertions, 43 deletions
diff --git a/openstackclient/tests/volume/v2/fakes.py b/openstackclient/tests/volume/v2/fakes.py index 2e58e58d..2fc5c8ff 100644 --- a/openstackclient/tests/volume/v2/fakes.py +++ b/openstackclient/tests/volume/v2/fakes.py @@ -256,9 +256,10 @@ class FakeVolume(object): 'key' + uuid.uuid4().hex: 'val' + uuid.uuid4().hex}, 'snapshot_id': random.randint(1, 5), 'availability_zone': 'zone' + uuid.uuid4().hex, - 'attachments': { + 'attachments': [{ 'device': '/dev/' + uuid.uuid4().hex, - 'server_id': uuid.uuid4().hex}, + 'server_id': uuid.uuid4().hex, + }, ], } # Overwrite default attributes if there are some attributes set diff --git a/openstackclient/tests/volume/v2/test_volume.py b/openstackclient/tests/volume/v2/test_volume.py index 4c583abd..76c7a27a 100644 --- a/openstackclient/tests/volume/v2/test_volume.py +++ b/openstackclient/tests/volume/v2/test_volume.py @@ -362,6 +362,47 @@ class TestVolumeCreate(TestVolume): self.assertEqual(self.datalist, data) +class TestVolumeDelete(TestVolume): + def setUp(self): + super(TestVolumeDelete, self).setUp() + + self.volumes_mock.delete.return_value = None + + # Get the command object to mock + self.cmd = volume.DeleteVolume(self.app, None) + + def test_volume_delete_one_volume(self): + volumes = self.setup_volumes_mock(count=1) + + arglist = [ + volumes[0].id + ] + verifylist = [ + ("volumes", [volumes[0].id]) + ] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args) + self.volumes_mock.delete.assert_called_with(volumes[0].id) + + def test_volume_delete_multi_volumes(self): + volumes = self.setup_volumes_mock(count=3) + + arglist = [v.id for v in volumes] + verifylist = [ + ('volumes', arglist), + ] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args) + + calls = [call(v.id) for v in volumes] + + self.volumes_mock.delete.assert_has_calls(calls) + + class TestVolumeList(TestVolume): columns = [ @@ -695,44 +736,3 @@ class TestVolumeShow(TestVolume): self.assertEqual(volume_fakes.VOLUME_columns, columns) self.assertEqual(volume_fakes.VOLUME_data, data) - - -class TestVolumeDelete(TestVolume): - def setUp(self): - super(TestVolumeDelete, self).setUp() - - self.volumes_mock.delete.return_value = None - - # Get the command object to mock - self.cmd = volume.DeleteVolume(self.app, None) - - def test_volume_delete_one_volume(self): - volumes = self.setup_volumes_mock(count=1) - - arglist = [ - volumes[0].id - ] - verifylist = [ - ("volumes", [volumes[0].id]) - ] - - parsed_args = self.check_parser(self.cmd, arglist, verifylist) - - self.cmd.take_action(parsed_args) - self.volumes_mock.delete.assert_called_with(volumes[0].id) - - def test_volume_delete_multi_volumes(self): - volumes = self.setup_volumes_mock(count=3) - - arglist = [v.id for v in volumes] - verifylist = [ - ('volumes', arglist), - ] - - parsed_args = self.check_parser(self.cmd, arglist, verifylist) - - self.cmd.take_action(parsed_args) - - calls = [call(v.id) for v in volumes] - - self.volumes_mock.delete.assert_has_calls(calls) |
