Merge "Fix 500 from image-import on 'active' image"
This commit is contained in:
commit
044f6f8488
|
@ -109,6 +109,8 @@ class ImagesController(object):
|
|||
raise webob.exc.HTTPForbidden(explanation=e.msg)
|
||||
except exception.Conflict as e:
|
||||
raise webob.exc.HTTPConflict(explanation=e.msg)
|
||||
except exception.InvalidImageStatusTransition as e:
|
||||
raise webob.exc.HTTPConflict(explanation=e.msg)
|
||||
|
||||
return image_id
|
||||
|
||||
|
|
|
@ -612,6 +612,19 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||
self.controller.import_image, request, UUID4,
|
||||
{})
|
||||
|
||||
def test_image_import_raises_conflict_for_invalid_status_change(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
# NOTE(abhishekk): Due to
|
||||
# https://bugs.launchpad.net/glance/+bug/1712463 taskflow is not
|
||||
# executing. Once it is fixed instead of mocking spawn_n method
|
||||
# we should mock execute method of _ImportToStore task.
|
||||
with mock.patch.object(
|
||||
eventlet.GreenPool, 'spawn_n',
|
||||
side_effect=exception.InvalidImageStatusTransition):
|
||||
self.assertRaises(webob.exc.HTTPConflict,
|
||||
self.controller.import_image, request, UUID4,
|
||||
{})
|
||||
|
||||
def test_create(self):
|
||||
request = unit_test_utils.get_fake_request()
|
||||
image = {'name': 'image-1'}
|
||||
|
|
Loading…
Reference in New Issue