Merge "Fix glance doesn't catches exception NotFound from glance_store"
This commit is contained in:
commit
f9a458668c
|
@ -88,7 +88,9 @@ class ImageDataController(object):
|
|||
image_repo.save(image)
|
||||
image.set_data(data, size)
|
||||
image_repo.save(image, from_state='saving')
|
||||
except (exception.ImageNotFound, exception.Conflict):
|
||||
except (glance_store.NotFound,
|
||||
exception.ImageNotFound,
|
||||
exception.Conflict):
|
||||
msg = (_("Image %s could not be found after upload. "
|
||||
"The image may have been deleted during the "
|
||||
"upload, cleaning up the chunks uploaded.") %
|
||||
|
|
|
@ -251,7 +251,7 @@ class TestImagesController(base.StoreClearingUnitTest):
|
|||
request, str(uuid.uuid4()), 'ABC', 3)
|
||||
self.assertTrue(image.delete.called)
|
||||
|
||||
def test_upload_non_existent_image_raises_not_found_exception(self):
|
||||
def test_upload_non_existent_image_raises_image_not_found_exception(self):
|
||||
def fake_save(self):
|
||||
raise exception.ImageNotFound()
|
||||
|
||||
|
@ -266,6 +266,21 @@ class TestImagesController(base.StoreClearingUnitTest):
|
|||
self.assertRaises(webob.exc.HTTPGone, self.controller.upload,
|
||||
request, str(uuid.uuid4()), 'ABC', 3)
|
||||
|
||||
def test_upload_non_existent_image_raises_store_not_found_exception(self):
|
||||
def fake_save(self):
|
||||
raise glance_store.NotFound()
|
||||
|
||||
def fake_delete():
|
||||
raise exception.ImageNotFound()
|
||||
|
||||
request = unit_test_utils.get_fake_request()
|
||||
image = FakeImage('abcd', locations=['http://example.com/image'])
|
||||
self.image_repo.result = image
|
||||
self.image_repo.save = fake_save
|
||||
image.delete = fake_delete
|
||||
self.assertRaises(webob.exc.HTTPGone, self.controller.upload,
|
||||
request, str(uuid.uuid4()), 'ABC', 3)
|
||||
|
||||
def test_upload_non_existent_image_before_save(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
self.image_repo.result = exception.NotFound()
|
||||
|
|
Loading…
Reference in New Issue