summaryrefslogtreecommitdiff
path: root/openstackclient/tests/volume
diff options
context:
space:
mode:
authorHuanxuan Ao <huanxuan.ao@easystack.cn>2016-08-05 18:54:29 +0800
committerHuanxuan Ao <huanxuan.ao@easystack.cn>2016-08-06 09:15:21 +0800
commit3202fefc654bc32fd7e02b12b76a4ea55f7f53c0 (patch)
tree1b67496e0355b3b844f913f306195092f3e20f13 /openstackclient/tests/volume
parent0472b9ec6d461d8731f106ce62a6b44d50a5c310 (diff)
downloadpython-openstackclient-3202fefc654bc32fd7e02b12b76a4ea55f7f53c0.tar.gz
Support multi REST API calls error handling for "volume set" command
Support the error handling follow the rule in doc/source/command-errors.rst Also add a unit test for testing the error handling Change-Id: I98064f4b8c1dc17eb3874f7b25c827a568463c0f
Diffstat (limited to 'openstackclient/tests/volume')
-rw-r--r--openstackclient/tests/volume/v2/test_volume.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/openstackclient/tests/volume/v2/test_volume.py b/openstackclient/tests/volume/v2/test_volume.py
index c2740cab..1bb5c192 100644
--- a/openstackclient/tests/volume/v2/test_volume.py
+++ b/openstackclient/tests/volume/v2/test_volume.py
@@ -860,6 +860,27 @@ class TestVolumeSet(TestVolume):
self.new_volume.id, 'error')
self.assertIsNone(result)
+ def test_volume_set_state_failed(self):
+ self.volumes_mock.reset_state.side_effect = exceptions.CommandError()
+ arglist = [
+ '--state', 'error',
+ self.new_volume.id
+ ]
+ verifylist = [
+ ('state', 'error'),
+ ('volume', self.new_volume.id)
+ ]
+
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+ try:
+ self.cmd.take_action(parsed_args)
+ self.fail('CommandError should be raised.')
+ except exceptions.CommandError as e:
+ self.assertEqual('One or more of the set operations failed',
+ str(e))
+ self.volumes_mock.reset_state.assert_called_with(
+ self.new_volume.id, 'error')
+
class TestVolumeShow(TestVolume):