@@ -520,7 +520,29 @@ def test_image_delete_no_options(self):
520520
521521 result = self .cmd .take_action (parsed_args )
522522
523- self .client .delete_image .assert_called_with (images [0 ].id )
523+ self .client .delete_image .assert_called_with (
524+ images [0 ].id , store = parsed_args .store , ignore_missing = False
525+ )
526+ self .assertIsNone (result )
527+
528+ def test_image_delete_from_store (self ):
529+ images = self .setup_images_mock (count = 1 )
530+
531+ arglist = [
532+ images [0 ].id ,
533+ '--store' ,
534+ 'store1' ,
535+ ]
536+ verifylist = [('images' , [images [0 ].id ]), ('store' , 'store1' )]
537+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
538+
539+ self .client .find_image .side_effect = images
540+
541+ result = self .cmd .take_action (parsed_args )
542+
543+ self .client .delete_image .assert_called_with (
544+ images [0 ].id , store = parsed_args .store , ignore_missing = False
545+ )
524546 self .assertIsNone (result )
525547
526548 def test_image_delete_multi_images (self ):
@@ -536,10 +558,33 @@ def test_image_delete_multi_images(self):
536558
537559 result = self .cmd .take_action (parsed_args )
538560
539- calls = [mock .call (i .id ) for i in images ]
561+ calls = [
562+ mock .call (i .id , store = parsed_args .store , ignore_missing = False )
563+ for i in images
564+ ]
540565 self .client .delete_image .assert_has_calls (calls )
541566 self .assertIsNone (result )
542567
568+ def test_image_delete_from_store_without_multi_backend (self ):
569+ images = self .setup_images_mock (count = 1 )
570+
571+ arglist = [images [0 ].id , '--store' , 'store1' ]
572+ verifylist = [('images' , [images [0 ].id ]), ('store' , 'store1' )]
573+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
574+
575+ self .client .find_image .side_effect = images
576+
577+ self .client .delete_image .side_effect = sdk_exceptions .ResourceNotFound
578+ exc = self .assertRaises (
579+ exceptions .CommandError ,
580+ self .cmd .take_action ,
581+ parsed_args ,
582+ )
583+ self .assertIn (
584+ "Multi Backend support not enabled" ,
585+ str (exc ),
586+ )
587+
543588 def test_image_delete_multi_images_exception (self ):
544589 images = image_fakes .create_images (count = 2 )
545590 arglist = [
@@ -562,7 +607,10 @@ def test_image_delete_multi_images_exception(self):
562607 self .assertRaises (
563608 exceptions .CommandError , self .cmd .take_action , parsed_args
564609 )
565- calls = [mock .call (i .id ) for i in images ]
610+ calls = [
611+ mock .call (i .id , store = parsed_args .store , ignore_missing = False )
612+ for i in images
613+ ]
566614 self .client .delete_image .assert_has_calls (calls )
567615
568616
0 commit comments