@@ -32,6 +32,10 @@ def setUp(self):
3232 self .app .client_manager .volume .consistencygroups )
3333 self .consistencygroups_mock .reset_mock ()
3434
35+ self .cgsnapshots_mock = (
36+ self .app .client_manager .volume .cgsnapshots )
37+ self .cgsnapshots_mock .reset_mock ()
38+
3539 self .types_mock = self .app .client_manager .volume .volume_types
3640 self .types_mock .reset_mock ()
3741
@@ -41,6 +45,11 @@ class TestConsistencyGroupCreate(TestConsistencyGroup):
4145 volume_type = volume_fakes .FakeType .create_one_type ()
4246 new_consistency_group = (
4347 volume_fakes .FakeConsistencyGroup .create_one_consistency_group ())
48+ consistency_group_snapshot = (
49+ volume_fakes .
50+ FakeConsistencyGroupSnapshot .
51+ create_one_consistency_group_snapshot ()
52+ )
4453
4554 columns = (
4655 'availability_zone' ,
@@ -70,6 +79,8 @@ def setUp(self):
7079 self .consistencygroups_mock .get .return_value = (
7180 self .new_consistency_group )
7281 self .types_mock .get .return_value = self .volume_type
82+ self .cgsnapshots_mock .get .return_value = (
83+ self .consistency_group_snapshot )
7384
7485 # Get the command object to test
7586 self .cmd = consistency_group .CreateConsistencyGroup (self .app , None )
@@ -164,6 +175,34 @@ def test_consistency_group_create_from_source(self):
164175 self .assertEqual (self .columns , columns )
165176 self .assertEqual (self .data , data )
166177
178+ def test_consistency_group_create_from_snapshot (self ):
179+ arglist = [
180+ '--consistency-group-snapshot' , self .consistency_group_snapshot .id ,
181+ '--description' , self .new_consistency_group .description ,
182+ self .new_consistency_group .name ,
183+ ]
184+ verifylist = [
185+ ('consistency_group_snapshot' , self .consistency_group_snapshot .id ),
186+ ('description' , self .new_consistency_group .description ),
187+ ('name' , self .new_consistency_group .name ),
188+ ]
189+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
190+
191+ columns , data = self .cmd .take_action (parsed_args )
192+
193+ self .types_mock .get .assert_not_called ()
194+ self .cgsnapshots_mock .get .assert_called_once_with (
195+ self .consistency_group_snapshot .id )
196+ self .consistencygroups_mock .create_from_src .assert_called_with (
197+ self .consistency_group_snapshot .id ,
198+ None ,
199+ name = self .new_consistency_group .name ,
200+ description = self .new_consistency_group .description ,
201+ )
202+
203+ self .assertEqual (self .columns , columns )
204+ self .assertEqual (self .data , data )
205+
167206
168207class TestConsistencyGroupDelete (TestConsistencyGroup ):
169208
0 commit comments