@@ -420,27 +420,32 @@ def test_volume_delete_one_volume(self):
420420 volumes [0 ].id
421421 ]
422422 verifylist = [
423- ("volumes" , [volumes [0 ].id ])
423+ ("force" , False ),
424+ ("purge" , False ),
425+ ("volumes" , [volumes [0 ].id ]),
424426 ]
425427 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
426428
427429 result = self .cmd .take_action (parsed_args )
428430
429- self .volumes_mock .delete .assert_called_with (volumes [0 ].id )
431+ self .volumes_mock .delete .assert_called_once_with (
432+ volumes [0 ].id , cascade = False )
430433 self .assertIsNone (result )
431434
432435 def test_volume_delete_multi_volumes (self ):
433436 volumes = self .setup_volumes_mock (count = 3 )
434437
435438 arglist = [v .id for v in volumes ]
436439 verifylist = [
440+ ('force' , False ),
441+ ('purge' , False ),
437442 ('volumes' , arglist ),
438443 ]
439444 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
440445
441446 result = self .cmd .take_action (parsed_args )
442447
443- calls = [call (v .id ) for v in volumes ]
448+ calls = [call (v .id , cascade = False ) for v in volumes ]
444449 self .volumes_mock .delete .assert_has_calls (calls )
445450 self .assertIsNone (result )
446451
@@ -452,6 +457,8 @@ def test_volume_delete_multi_volumes_with_exception(self):
452457 'unexist_volume' ,
453458 ]
454459 verifylist = [
460+ ('force' , False ),
461+ ('purge' , False ),
455462 ('volumes' , arglist ),
456463 ]
457464 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
@@ -471,8 +478,46 @@ def test_volume_delete_multi_volumes_with_exception(self):
471478
472479 self .assertEqual (2 , find_mock .call_count )
473480 self .volumes_mock .delete .assert_called_once_with (
474- volumes [0 ].id
475- )
481+ volumes [0 ].id , cascade = False )
482+
483+ def test_volume_delete_with_purge (self ):
484+ volumes = self .setup_volumes_mock (count = 1 )
485+
486+ arglist = [
487+ '--purge' ,
488+ volumes [0 ].id ,
489+ ]
490+ verifylist = [
491+ ('force' , False ),
492+ ('purge' , True ),
493+ ('volumes' , [volumes [0 ].id ]),
494+ ]
495+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
496+
497+ result = self .cmd .take_action (parsed_args )
498+
499+ self .volumes_mock .delete .assert_called_once_with (
500+ volumes [0 ].id , cascade = True )
501+ self .assertIsNone (result )
502+
503+ def test_volume_delete_with_force (self ):
504+ volumes = self .setup_volumes_mock (count = 1 )
505+
506+ arglist = [
507+ '--force' ,
508+ volumes [0 ].id ,
509+ ]
510+ verifylist = [
511+ ('force' , True ),
512+ ('purge' , False ),
513+ ('volumes' , [volumes [0 ].id ]),
514+ ]
515+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
516+
517+ result = self .cmd .take_action (parsed_args )
518+
519+ self .volumes_mock .force_delete .assert_called_once_with (volumes [0 ].id )
520+ self .assertIsNone (result )
476521
477522
478523class TestVolumeList (TestVolume ):
0 commit comments