From 6a914d0056e810e1ef37eaf4f01cd5c85217aba6 Mon Sep 17 00:00:00 2001 From: qtang Date: Thu, 25 Aug 2016 10:56:58 +0800 Subject: Support mark volume as bootable in volume set Add --bootable | --non-bootable option in volume set to mark or unmark volume as bootable. Change-Id: Ifa6c2dd1642202f55b6d50e3b8614d3513d488f6 Closes-Bug:#1535704 --- .../tests/unit/volume/v1/test_volume.py | 27 ++++++++++++++++++++++ .../tests/unit/volume/v2/test_volume.py | 27 ++++++++++++++++++++++ 2 files changed, 54 insertions(+) (limited to 'openstackclient/tests/unit') diff --git a/openstackclient/tests/unit/volume/v1/test_volume.py b/openstackclient/tests/unit/volume/v1/test_volume.py index 54ec9e7e..e95f42d0 100644 --- a/openstackclient/tests/unit/volume/v1/test_volume.py +++ b/openstackclient/tests/unit/volume/v1/test_volume.py @@ -844,6 +844,8 @@ class TestVolumeSet(TestVolume): ('size', None), ('property', {'myprop': 'myvalue'}), ('volume', volume_fakes.volume_name), + ('bootable', False), + ('non_bootable', False) ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -858,3 +860,28 @@ class TestVolumeSet(TestVolume): metadata ) self.assertIsNone(result) + + def test_volume_set_bootable(self): + arglist = [ + ['--bootable', volume_fakes.volume_id], + ['--non-bootable', volume_fakes.volume_id] + ] + verifylist = [ + [ + ('bootable', True), + ('non_bootable', False), + ('volume', volume_fakes.volume_id) + ], + [ + ('bootable', False), + ('non_bootable', True), + ('volume', volume_fakes.volume_id) + ] + ] + for index in range(len(arglist)): + parsed_args = self.check_parser( + self.cmd, arglist[index], verifylist[index]) + + self.cmd.take_action(parsed_args) + self.volumes_mock.set_bootable.assert_called_with( + volume_fakes.volume_id, verifylist[index][0][1]) diff --git a/openstackclient/tests/unit/volume/v2/test_volume.py b/openstackclient/tests/unit/volume/v2/test_volume.py index de059b1b..a42ce22b 100644 --- a/openstackclient/tests/unit/volume/v2/test_volume.py +++ b/openstackclient/tests/unit/volume/v2/test_volume.py @@ -905,6 +905,8 @@ class TestVolumeSet(TestVolume): verifylist = [ ('image_property', {'Alpha': 'a', 'Beta': 'b'}), ('volume', self.new_volume.id), + ('bootable', False), + ('non_bootable', False) ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -952,6 +954,31 @@ class TestVolumeSet(TestVolume): self.volumes_mock.reset_state.assert_called_with( self.new_volume.id, 'error') + def test_volume_set_bootable(self): + arglist = [ + ['--bootable', self.new_volume.id], + ['--non-bootable', self.new_volume.id] + ] + verifylist = [ + [ + ('bootable', True), + ('non_bootable', False), + ('volume', self.new_volume.id) + ], + [ + ('bootable', False), + ('non_bootable', True), + ('volume', self.new_volume.id) + ] + ] + for index in range(len(arglist)): + parsed_args = self.check_parser( + self.cmd, arglist[index], verifylist[index]) + + self.cmd.take_action(parsed_args) + self.volumes_mock.set_bootable.assert_called_with( + self.new_volume.id, verifylist[index][0][1]) + class TestVolumeShow(TestVolume): -- cgit v1.2.1