@@ -180,6 +180,59 @@ def test_snapshot_create_with_remote_source(self):
180180 )
181181 self .volume_sdk_client .create_snapshot .assert_not_called ()
182182
183+ def test_snapshot_create_pre_v366 (self ):
184+ self .set_volume_api_version ('3.65' )
185+
186+ arglist = ["--force" , self .snapshot .name ]
187+ verifylist = [("force" , True ), ("snapshot_name" , self .snapshot .name )]
188+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
189+
190+ self .cmd .take_action (parsed_args )
191+
192+ # force parameter should be passed
193+ self .volume_sdk_client .create_snapshot .assert_called_with (
194+ volume_id = self .snapshot .volume_id ,
195+ force = True ,
196+ name = self .snapshot .name ,
197+ description = None ,
198+ metadata = None ,
199+ )
200+
201+ def test_snapshot_create_v366_or_later (self ):
202+ self .set_volume_api_version ('3.66' )
203+
204+ arglist = [self .snapshot .name ]
205+ verifylist = [("force" , False ), ("snapshot_name" , self .snapshot .name )]
206+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
207+
208+ self .cmd .take_action (parsed_args )
209+
210+ # force parameter should not be passed, for >=3.66
211+ self .volume_sdk_client .create_snapshot .assert_called_with (
212+ volume_id = self .snapshot .volume_id ,
213+ name = self .snapshot .name ,
214+ description = None ,
215+ metadata = None ,
216+ )
217+
218+ def test_snapshot_create_v366_or_later_with_force (self ):
219+ """--force should be ignored for microversion >= 3.66."""
220+ self .set_volume_api_version ('3.66' )
221+
222+ arglist = ["--force" , self .snapshot .name ]
223+ verifylist = [("force" , True ), ("snapshot_name" , self .snapshot .name )]
224+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
225+
226+ self .cmd .take_action (parsed_args )
227+
228+ # passed but ignored
229+ self .volume_sdk_client .create_snapshot .assert_called_with (
230+ volume_id = self .snapshot .volume_id ,
231+ name = self .snapshot .name ,
232+ description = None ,
233+ metadata = None ,
234+ )
235+
183236
184237class TestVolumeSnapshotDelete (volume_fakes .TestVolume ):
185238 def setUp (self ):
0 commit comments