diff options
| author | Jenkins <jenkins@review.openstack.org> | 2017-01-26 06:38:31 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2017-01-26 06:38:31 +0000 |
| commit | da2a820d2f4e5589671f494edcd8e8b3e69b7cb0 (patch) | |
| tree | 741b3f26bfc312ddcc546da63a306984ad6462d2 /openstackclient/tests/unit/volume/v2 | |
| parent | d189e807fdfc7222b18844a56db2e43412f49abb (diff) | |
| parent | 26d50be79a401322f4e74b94c066257ddf0f287c (diff) | |
| download | python-openstackclient-da2a820d2f4e5589671f494edcd8e8b3e69b7cb0.tar.gz | |
Merge "Support "--no-property" option in volume snapshot set"
Diffstat (limited to 'openstackclient/tests/unit/volume/v2')
| -rw-r--r-- | openstackclient/tests/unit/volume/v2/test_snapshot.py | 63 |
1 files changed, 62 insertions, 1 deletions
diff --git a/openstackclient/tests/unit/volume/v2/test_snapshot.py b/openstackclient/tests/unit/volume/v2/test_snapshot.py index 12d1e390..1ad97e85 100644 --- a/openstackclient/tests/unit/volume/v2/test_snapshot.py +++ b/openstackclient/tests/unit/volume/v2/test_snapshot.py @@ -512,7 +512,23 @@ class TestSnapshotSet(TestSnapshot): # Get the command object to mock self.cmd = volume_snapshot.SetVolumeSnapshot(self.app, None) - def test_snapshot_set(self): + def test_snapshot_set_no_option(self): + arglist = [ + self.snapshot.id, + ] + verifylist = [ + ("snapshot", self.snapshot.id), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + result = self.cmd.take_action(parsed_args) + self.snapshots_mock.get.assert_called_once_with(parsed_args.snapshot) + self.assertNotCalled(self.snapshots_mock.reset_state) + self.assertNotCalled(self.snapshots_mock.update) + self.assertNotCalled(self.snapshots_mock.set_metadata) + self.assertIsNone(result) + + def test_snapshot_set_name_and_property(self): arglist = [ "--name", "new_snapshot", "--property", "x=y", @@ -539,6 +555,51 @@ class TestSnapshotSet(TestSnapshot): ) self.assertIsNone(result) + def test_snapshot_set_with_no_property(self): + arglist = [ + "--no-property", + self.snapshot.id, + ] + verifylist = [ + ("no_property", True), + ("snapshot", self.snapshot.id), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + result = self.cmd.take_action(parsed_args) + self.snapshots_mock.get.assert_called_once_with(parsed_args.snapshot) + self.assertNotCalled(self.snapshots_mock.reset_state) + self.assertNotCalled(self.snapshots_mock.update) + self.assertNotCalled(self.snapshots_mock.set_metadata) + self.snapshots_mock.delete_metadata.assert_called_with( + self.snapshot.id, ["foo"] + ) + self.assertIsNone(result) + + def test_snapshot_set_with_no_property_and_property(self): + arglist = [ + "--no-property", + "--property", "foo_1=bar_1", + self.snapshot.id, + ] + verifylist = [ + ("no_property", True), + ("property", {"foo_1": "bar_1"}), + ("snapshot", self.snapshot.id), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + result = self.cmd.take_action(parsed_args) + self.snapshots_mock.get.assert_called_once_with(parsed_args.snapshot) + self.assertNotCalled(self.snapshots_mock.reset_state) + self.assertNotCalled(self.snapshots_mock.update) + self.snapshots_mock.delete_metadata.assert_called_with( + self.snapshot.id, ["foo"] + ) + self.snapshots_mock.set_metadata.assert_called_once_with( + self.snapshot.id, {"foo_1": "bar_1"}) + self.assertIsNone(result) + def test_snapshot_set_state_to_error(self): arglist = [ "--state", "error", |
