diff options
Diffstat (limited to 'openstackclient/tests/unit/volume')
| -rw-r--r-- | openstackclient/tests/unit/volume/v1/test_snapshot.py | 13 | ||||
| -rw-r--r-- | openstackclient/tests/unit/volume/v2/test_snapshot.py | 63 |
2 files changed, 71 insertions, 5 deletions
diff --git a/openstackclient/tests/unit/volume/v1/test_snapshot.py b/openstackclient/tests/unit/volume/v1/test_snapshot.py index fd878f45..87a62b0a 100644 --- a/openstackclient/tests/unit/volume/v1/test_snapshot.py +++ b/openstackclient/tests/unit/volume/v1/test_snapshot.py @@ -429,15 +429,17 @@ class TestSnapshotSet(TestSnapshot): arglist = [ "--name", "new_snapshot", "--description", "new_description", - "--property", "x=y", - "--property", "foo=foo", + "--property", "foo_1=foo_1", + "--property", "foo_2=foo_2", + "--no-property", self.snapshot.id, ] - new_property = {"x": "y", "foo": "foo"} + new_property = {"foo_1": "foo_1", "foo_2": "foo_2"} verifylist = [ ("name", "new_snapshot"), ("description", "new_description"), ("property", new_property), + ("no_property", True), ("snapshot", self.snapshot.id), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -449,8 +451,11 @@ class TestSnapshotSet(TestSnapshot): "display_description": "new_description", } self.snapshot.update.assert_called_with(**kwargs) + self.snapshots_mock.delete_metadata.assert_called_with( + self.snapshot.id, ["foo"] + ) self.snapshots_mock.set_metadata.assert_called_with( - self.snapshot.id, new_property + self.snapshot.id, {"foo_2": "foo_2", "foo_1": "foo_1"} ) self.assertIsNone(result) 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", |
