Delete image from specific store

Add support to delete image from specific store.

bp: delete-from-store
Change-Id: Ie57d7de5822264a5ea8a5f4587ab8cfb4afb79de
This commit is contained in:
Erno Kuvaja
2019-12-18 09:57:30 +00:00
committed by Abhishek Kekane
parent 6d506c3a36
commit d91bcae8a5
4 changed files with 53 additions and 0 deletions
@@ -2165,6 +2165,29 @@ class ShellV2Test(testtools.TestCase):
self.assertEqual(2, mocked_print_err.call_count)
mocked_utils_exit.assert_called_once_with()
@mock.patch.object(utils, 'exit')
def test_do_image_delete_from_store_not_found(self, mocked_utils_exit):
args = argparse.Namespace(id='image1', store='store1')
with mock.patch.object(self.gc.images,
'delete_from_store') as mocked_delete:
mocked_delete.side_effect = exc.HTTPNotFound
test_shell.do_stores_delete(self.gc, args)
self.assertEqual(1, mocked_delete.call_count)
mocked_utils_exit.assert_called_once_with('Multi Backend support '
'is not enabled or '
'Image/store not found.')
def test_do_image_delete_from_store(self):
args = argparse.Namespace(id='image1', store='store1')
with mock.patch.object(self.gc.images,
'delete_from_store') as mocked_delete:
test_shell.do_stores_delete(self.gc, args)
mocked_delete.assert_called_once_with('store1',
'image1')
@mock.patch.object(utils, 'exit')
@mock.patch.object(utils, 'print_err')
def test_do_image_delete_with_forbidden_ids(self, mocked_print_err,