diff options
| author | Huanxuan Ao <huanxuan.ao@easystack.cn> | 2016-09-06 15:15:01 +0800 |
|---|---|---|
| committer | Huanxuan Ao <huanxuan.ao@easystack.cn> | 2016-09-11 11:00:09 +0800 |
| commit | cb6c11b0a87ba99e01eff52204b2406e8517aeaa (patch) | |
| tree | 15e2a7890ca3d692b9c361da1a9b68650c8852de /openstackclient/tests/unit/volume | |
| parent | 676a0e9696ba7550132e4501bdbf3160608faed6 (diff) | |
| download | python-openstackclient-cb6c11b0a87ba99e01eff52204b2406e8517aeaa.tar.gz | |
Multi REST API calls error handling of "volume unset" command
Support multi REST API calls error handling for "volume unset"
command follow the rule in doc/source/command-errors.rst.
Also add a unit test for testing the error handling
Change-Id: I2de7a7bd5a7a5e39817ed5cf6952abf4afba75e4
Diffstat (limited to 'openstackclient/tests/unit/volume')
| -rw-r--r-- | openstackclient/tests/unit/volume/v2/test_volume.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/openstackclient/tests/unit/volume/v2/test_volume.py b/openstackclient/tests/unit/volume/v2/test_volume.py index 66f8f74d..e9f1629e 100644 --- a/openstackclient/tests/unit/volume/v2/test_volume.py +++ b/openstackclient/tests/unit/volume/v2/test_volume.py @@ -964,3 +964,30 @@ class TestVolumeUnset(TestVolume): self.volumes_mock.delete_image_metadata.assert_called_with( self.new_volume.id, parsed_args_unset.image_property) + + def test_volume_unset_image_property_fail(self): + self.volumes_mock.delete_image_metadata.side_effect = ( + exceptions.CommandError()) + arglist = [ + '--image-property', 'Alpha', + '--property', 'Beta', + self.new_volume.id, + ] + verifylist = [ + ('image_property', ['Alpha']), + ('property', ['Beta']), + ('volume', self.new_volume.id), + ] + parsed_args = self.check_parser( + self.cmd_unset, arglist, verifylist) + + try: + self.cmd_unset.take_action(parsed_args) + self.fail('CommandError should be raised.') + except exceptions.CommandError as e: + self.assertEqual('One or more of the unset operations failed', + str(e)) + self.volumes_mock.delete_image_metadata.assert_called_with( + self.new_volume.id, parsed_args.image_property) + self.volumes_mock.delete_metadata.assert_called_with( + self.new_volume.id, parsed_args.property) |
