summaryrefslogtreecommitdiff
path: root/openstackclient/tests/unit/volume
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-12-08 17:44:42 +0000
committerGerrit Code Review <review@openstack.org>2016-12-08 17:44:42 +0000
commitb18dcfc4cbaadc30a27550a2bb30f94200645b06 (patch)
tree6a7036b1fd5c8c46f0c22795526feb87a7e58075 /openstackclient/tests/unit/volume
parenta9be7a6c731c4f590004812a3b3737ea266e8fc2 (diff)
parent3e9109bc7c9511b45568b299da897d977852d76d (diff)
downloadpython-openstackclient-b18dcfc4cbaadc30a27550a2bb30f94200645b06.tar.gz
Merge "Add "consistency-group-snapshot" option to consistency group create"
Diffstat (limited to 'openstackclient/tests/unit/volume')
-rw-r--r--openstackclient/tests/unit/volume/v2/test_consistency_group.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/openstackclient/tests/unit/volume/v2/test_consistency_group.py b/openstackclient/tests/unit/volume/v2/test_consistency_group.py
index 5beb6ef2..0e2f162e 100644
--- a/openstackclient/tests/unit/volume/v2/test_consistency_group.py
+++ b/openstackclient/tests/unit/volume/v2/test_consistency_group.py
@@ -32,6 +32,10 @@ class TestConsistencyGroup(volume_fakes.TestVolume):
self.app.client_manager.volume.consistencygroups)
self.consistencygroups_mock.reset_mock()
+ self.cgsnapshots_mock = (
+ self.app.client_manager.volume.cgsnapshots)
+ self.cgsnapshots_mock.reset_mock()
+
self.types_mock = self.app.client_manager.volume.volume_types
self.types_mock.reset_mock()
@@ -41,6 +45,11 @@ class TestConsistencyGroupCreate(TestConsistencyGroup):
volume_type = volume_fakes.FakeType.create_one_type()
new_consistency_group = (
volume_fakes.FakeConsistencyGroup.create_one_consistency_group())
+ consistency_group_snapshot = (
+ volume_fakes.
+ FakeConsistencyGroupSnapshot.
+ create_one_consistency_group_snapshot()
+ )
columns = (
'availability_zone',
@@ -70,6 +79,8 @@ class TestConsistencyGroupCreate(TestConsistencyGroup):
self.consistencygroups_mock.get.return_value = (
self.new_consistency_group)
self.types_mock.get.return_value = self.volume_type
+ self.cgsnapshots_mock.get.return_value = (
+ self.consistency_group_snapshot)
# Get the command object to test
self.cmd = consistency_group.CreateConsistencyGroup(self.app, None)
@@ -164,6 +175,34 @@ class TestConsistencyGroupCreate(TestConsistencyGroup):
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, data)
+ def test_consistency_group_create_from_snapshot(self):
+ arglist = [
+ '--consistency-group-snapshot', self.consistency_group_snapshot.id,
+ '--description', self.new_consistency_group.description,
+ self.new_consistency_group.name,
+ ]
+ verifylist = [
+ ('consistency_group_snapshot', self.consistency_group_snapshot.id),
+ ('description', self.new_consistency_group.description),
+ ('name', self.new_consistency_group.name),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ columns, data = self.cmd.take_action(parsed_args)
+
+ self.types_mock.get.assert_not_called()
+ self.cgsnapshots_mock.get.assert_called_once_with(
+ self.consistency_group_snapshot.id)
+ self.consistencygroups_mock.create_from_src.assert_called_with(
+ self.consistency_group_snapshot.id,
+ None,
+ name=self.new_consistency_group.name,
+ description=self.new_consistency_group.description,
+ )
+
+ self.assertEqual(self.columns, columns)
+ self.assertEqual(self.data, data)
+
class TestConsistencyGroupDelete(TestConsistencyGroup):