diff options
| author | wuyuting <wytdahu@gmail.com> | 2016-06-05 22:55:43 -0400 |
|---|---|---|
| committer | Rui Chen <chenrui.momo@gmail.com> | 2016-07-27 11:30:52 +0800 |
| commit | 954c28dfa21be76b0522af051d71fb9470877a1a (patch) | |
| tree | e39e3e3eeb5722a85259a72566987a8b876a10ed /openstackclient/tests | |
| parent | 7a667d700f97dda386c3db3bffc8138182fbeccb (diff) | |
| download | python-openstackclient-954c28dfa21be76b0522af051d71fb9470877a1a.tar.gz | |
Add support for deleting volumes with associated snapshots
OSC doesn't support deleting volumes with associated snapshots.
This patch provides support for deleting volumes with associated
snapshots by adding an optional argument.
Change-Id: I7e74f251574993ff13a38e508fd2f9debeda8d0a
Closes-Bug: #1589332
Co-Authored-By: Rui Chen <chenrui.momo@gmail.com>
Diffstat (limited to 'openstackclient/tests')
| -rw-r--r-- | openstackclient/tests/volume/v2/test_volume.py | 55 |
1 files changed, 50 insertions, 5 deletions
diff --git a/openstackclient/tests/volume/v2/test_volume.py b/openstackclient/tests/volume/v2/test_volume.py index 25d0e92f..6f552ad6 100644 --- a/openstackclient/tests/volume/v2/test_volume.py +++ b/openstackclient/tests/volume/v2/test_volume.py @@ -420,13 +420,16 @@ class TestVolumeDelete(TestVolume): volumes[0].id ] verifylist = [ - ("volumes", [volumes[0].id]) + ("force", False), + ("purge", False), + ("volumes", [volumes[0].id]), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) result = self.cmd.take_action(parsed_args) - self.volumes_mock.delete.assert_called_with(volumes[0].id) + self.volumes_mock.delete.assert_called_once_with( + volumes[0].id, cascade=False) self.assertIsNone(result) def test_volume_delete_multi_volumes(self): @@ -434,13 +437,15 @@ class TestVolumeDelete(TestVolume): arglist = [v.id for v in volumes] verifylist = [ + ('force', False), + ('purge', False), ('volumes', arglist), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) result = self.cmd.take_action(parsed_args) - calls = [call(v.id) for v in volumes] + calls = [call(v.id, cascade=False) for v in volumes] self.volumes_mock.delete.assert_has_calls(calls) self.assertIsNone(result) @@ -452,6 +457,8 @@ class TestVolumeDelete(TestVolume): 'unexist_volume', ] verifylist = [ + ('force', False), + ('purge', False), ('volumes', arglist), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -471,8 +478,46 @@ class TestVolumeDelete(TestVolume): self.assertEqual(2, find_mock.call_count) self.volumes_mock.delete.assert_called_once_with( - volumes[0].id - ) + volumes[0].id, cascade=False) + + def test_volume_delete_with_purge(self): + volumes = self.setup_volumes_mock(count=1) + + arglist = [ + '--purge', + volumes[0].id, + ] + verifylist = [ + ('force', False), + ('purge', True), + ('volumes', [volumes[0].id]), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + result = self.cmd.take_action(parsed_args) + + self.volumes_mock.delete.assert_called_once_with( + volumes[0].id, cascade=True) + self.assertIsNone(result) + + def test_volume_delete_with_force(self): + volumes = self.setup_volumes_mock(count=1) + + arglist = [ + '--force', + volumes[0].id, + ] + verifylist = [ + ('force', True), + ('purge', False), + ('volumes', [volumes[0].id]), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + result = self.cmd.take_action(parsed_args) + + self.volumes_mock.force_delete.assert_called_once_with(volumes[0].id) + self.assertIsNone(result) class TestVolumeList(TestVolume): |
