From 4dc78e4265f60356ea453c7f52fcdaeecec58fcb Mon Sep 17 00:00:00 2001 From: "zhiyong.dai" Date: Sun, 4 Dec 2016 13:11:24 +0800 Subject: Add "consistency group set" command Add "consistency group set" command in volume v2 (v2 only). Change-Id: I53116015388b7a4b0e15813f52c1246166bb0fc1 Implements: bp cinder-command-support Partial-Bug: #1613964 --- .../tests/unit/volume/v2/test_consistency_group.py | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'openstackclient/tests/unit/volume') diff --git a/openstackclient/tests/unit/volume/v2/test_consistency_group.py b/openstackclient/tests/unit/volume/v2/test_consistency_group.py index 5beb6ef2..8a997e18 100644 --- a/openstackclient/tests/unit/volume/v2/test_consistency_group.py +++ b/openstackclient/tests/unit/volume/v2/test_consistency_group.py @@ -355,6 +355,70 @@ class TestConsistencyGroupList(TestConsistencyGroup): self.assertEqual(self.data_long, list(data)) +class TestConsistencyGroupSet(TestConsistencyGroup): + + consistency_group = ( + volume_fakes.FakeConsistencyGroup.create_one_consistency_group()) + + def setUp(self): + super(TestConsistencyGroupSet, self).setUp() + + self.consistencygroups_mock.get.return_value = ( + self.consistency_group) + # Get the command object to test + self.cmd = consistency_group.SetConsistencyGroup(self.app, None) + + def test_consistency_group_set_name(self): + new_name = 'new_name' + arglist = [ + '--name', new_name, + self.consistency_group.id, + ] + verifylist = [ + ('name', new_name), + ('description', None), + ('consistency_group', self.consistency_group.id), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + result = self.cmd.take_action(parsed_args) + + # Set expected values + kwargs = { + 'name': new_name, + } + self.consistencygroups_mock.update.assert_called_once_with( + self.consistency_group.id, + **kwargs + ) + self.assertIsNone(result) + + def test_consistency_group_set_description(self): + new_description = 'new_description' + arglist = [ + '--description', new_description, + self.consistency_group.id, + ] + verifylist = [ + ('name', None), + ('description', new_description), + ('consistency_group', self.consistency_group.id), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + result = self.cmd.take_action(parsed_args) + + # Set expected values + kwargs = { + 'description': new_description, + } + self.consistencygroups_mock.update.assert_called_once_with( + self.consistency_group.id, + **kwargs + ) + self.assertIsNone(result) + + class TestConsistencyGroupShow(TestConsistencyGroup): columns = ( 'availability_zone', -- cgit v1.2.1