diff options
| author | Xi Yang <yang.xi@99cloud.net> | 2016-01-18 15:47:23 +0800 |
|---|---|---|
| committer | Huanxuan Ao <huanxuan.ao@easystack.cn> | 2016-08-03 12:19:16 +0800 |
| commit | 20ae54045cef136a8d0665aab0d45698e12ed21c (patch) | |
| tree | d50a920f55d5dd93c3b78db41345f1908e36c556 /openstackclient/tests/volume | |
| parent | eaee74bba253bf04471055bbe51db6aad2975a7a (diff) | |
| download | python-openstackclient-20ae54045cef136a8d0665aab0d45698e12ed21c.tar.gz | |
Add support of setting volume's state
OSC does not support to set volume's state, this
patch is going to add this functionality.
Closes-Bug:#1535213
Change-Id: I5bc1c7e81b8ba61c37f4bfd209fc86c5857fb050
Co-Authored-By: Huanxuan Ao <huanxuan.ao@easystack.cn>
Diffstat (limited to 'openstackclient/tests/volume')
| -rw-r--r-- | openstackclient/tests/volume/v2/test_volume.py | 77 |
1 files changed, 47 insertions, 30 deletions
diff --git a/openstackclient/tests/volume/v2/test_volume.py b/openstackclient/tests/volume/v2/test_volume.py index 6f552ad6..c2740cab 100644 --- a/openstackclient/tests/volume/v2/test_volume.py +++ b/openstackclient/tests/volume/v2/test_volume.py @@ -814,6 +814,53 @@ class TestVolumeList(TestVolume): self.assertEqual(datalist, tuple(data)) +class TestVolumeSet(TestVolume): + + def setUp(self): + super(TestVolumeSet, self).setUp() + + self.new_volume = volume_fakes.FakeVolume.create_one_volume() + self.volumes_mock.get.return_value = self.new_volume + + # Get the command object to test + self.cmd = volume.SetVolume(self.app, None) + + def test_volume_set_image_property(self): + arglist = [ + '--image-property', 'Alpha=a', + '--image-property', 'Beta=b', + self.new_volume.id, + ] + verifylist = [ + ('image_property', {'Alpha': 'a', 'Beta': 'b'}), + ('volume', self.new_volume.id), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + # In base command class ShowOne in cliff, abstract method take_action() + # returns nothing + self.cmd.take_action(parsed_args) + self.volumes_mock.set_image_metadata.assert_called_with( + self.volumes_mock.get().id, parsed_args.image_property) + + def test_volume_set_state(self): + arglist = [ + '--state', 'error', + self.new_volume.id + ] + verifylist = [ + ('state', 'error'), + ('volume', self.new_volume.id) + ] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + result = self.cmd.take_action(parsed_args) + self.volumes_mock.reset_state.assert_called_with( + self.new_volume.id, 'error') + self.assertIsNone(result) + + class TestVolumeShow(TestVolume): def setUp(self): @@ -845,36 +892,6 @@ class TestVolumeShow(TestVolume): data) -class TestVolumeSet(TestVolume): - - def setUp(self): - super(TestVolumeSet, self).setUp() - - self.new_volume = volume_fakes.FakeVolume.create_one_volume() - self.volumes_mock.create.return_value = self.new_volume - - # Get the command object to test - self.cmd = volume.SetVolume(self.app, None) - - def test_volume_set_image_property(self): - arglist = [ - '--image-property', 'Alpha=a', - '--image-property', 'Beta=b', - self.new_volume.id, - ] - verifylist = [ - ('image_property', {'Alpha': 'a', 'Beta': 'b'}), - ('volume', self.new_volume.id), - ] - parsed_args = self.check_parser(self.cmd, arglist, verifylist) - - # In base command class ShowOne in cliff, abstract method take_action() - # returns nothing - self.cmd.take_action(parsed_args) - self.volumes_mock.set_image_metadata.assert_called_with( - self.volumes_mock.get().id, parsed_args.image_property) - - class TestVolumeUnset(TestVolume): def setUp(self): |
