Merge "fix: Claim can return 404"
This commit is contained in:
commit
380e33c223
@ -118,9 +118,6 @@ class ClaimController(storage.ClaimBase):
|
|||||||
"""
|
"""
|
||||||
msg_ctrl = self.driver.message_controller
|
msg_ctrl = self.driver.message_controller
|
||||||
|
|
||||||
if not self.driver.queue_controller.exists(queue, project):
|
|
||||||
raise exceptions.QueueDoesNotExist(queue, project)
|
|
||||||
|
|
||||||
ttl = metadata['ttl']
|
ttl = metadata['ttl']
|
||||||
grace = metadata['grace']
|
grace = metadata['grace']
|
||||||
oid = objectid.ObjectId()
|
oid = objectid.ObjectId()
|
||||||
@ -148,7 +145,7 @@ class ClaimController(storage.ClaimBase):
|
|||||||
ids = [msg['_id'] for msg in msgs]
|
ids = [msg['_id'] for msg in msgs]
|
||||||
|
|
||||||
if len(ids) == 0:
|
if len(ids) == 0:
|
||||||
return (str(oid), messages)
|
return (None, messages)
|
||||||
|
|
||||||
now = timeutils.utcnow()
|
now = timeutils.utcnow()
|
||||||
|
|
||||||
|
@ -78,7 +78,10 @@ class ClaimController(base.ClaimBase):
|
|||||||
project = ''
|
project = ''
|
||||||
|
|
||||||
with self.driver('immediate'):
|
with self.driver('immediate'):
|
||||||
qid = utils.get_qid(self.driver, queue, project)
|
try:
|
||||||
|
qid = utils.get_qid(self.driver, queue, project)
|
||||||
|
except exceptions.QueueDoesNotExist:
|
||||||
|
return None, iter([])
|
||||||
|
|
||||||
# Clean up all expired claims in this queue
|
# Clean up all expired claims in this queue
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ class ClaimsBaseTest(base.TestBase):
|
|||||||
def test_nonexistent(self):
|
def test_nonexistent(self):
|
||||||
self.simulate_post('/v1/queues/nonexistent/claims', self.project_id,
|
self.simulate_post('/v1/queues/nonexistent/claims', self.project_id,
|
||||||
body='{"ttl": 100, "grace": 60}')
|
body='{"ttl": 100, "grace": 60}')
|
||||||
self.assertEquals(self.srmock.status, falcon.HTTP_404)
|
self.assertEquals(self.srmock.status, falcon.HTTP_204)
|
||||||
|
|
||||||
# NOTE(cpp-cabrera): regression test against bug #1203842
|
# NOTE(cpp-cabrera): regression test against bug #1203842
|
||||||
def test_get_nonexistent_claim_404s(self):
|
def test_get_nonexistent_claim_404s(self):
|
||||||
|
@ -76,9 +76,6 @@ class CollectionResource(object):
|
|||||||
except input_exceptions.ValidationFailed as ex:
|
except input_exceptions.ValidationFailed as ex:
|
||||||
raise wsgi_exceptions.HTTPBadRequestBody(str(ex))
|
raise wsgi_exceptions.HTTPBadRequestBody(str(ex))
|
||||||
|
|
||||||
except storage_exceptions.DoesNotExist:
|
|
||||||
raise falcon.HTTPNotFound()
|
|
||||||
|
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
LOG.exception(ex)
|
LOG.exception(ex)
|
||||||
description = _(u'Claim could not be created.')
|
description = _(u'Claim could not be created.')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user