Returning None in get_queue when not found. Closes spulec/moto#23
This commit is contained in:
parent
6107658c65
commit
64baad79b0
@ -53,7 +53,7 @@ class SQSBackend(BaseBackend):
|
|||||||
return self.queues.values()
|
return self.queues.values()
|
||||||
|
|
||||||
def get_queue(self, queue_name):
|
def get_queue(self, queue_name):
|
||||||
return self.queues[queue_name]
|
return self.queues.get(queue_name, None)
|
||||||
|
|
||||||
def delete_queue(self, queue_name):
|
def delete_queue(self, queue_name):
|
||||||
if queue_name in self.queues:
|
if queue_name in self.queues:
|
||||||
|
@ -20,8 +20,12 @@ class QueuesResponse(BaseResponse):
|
|||||||
def get_queue_url(self):
|
def get_queue_url(self):
|
||||||
queue_name = self.querystring.get("QueueName")[0]
|
queue_name = self.querystring.get("QueueName")[0]
|
||||||
queue = sqs_backend.get_queue(queue_name)
|
queue = sqs_backend.get_queue(queue_name)
|
||||||
|
if queue:
|
||||||
template = Template(GET_QUEUE_URL_RESPONSE)
|
template = Template(GET_QUEUE_URL_RESPONSE)
|
||||||
return template.render(queue=queue)
|
return template.render(queue=queue)
|
||||||
|
else:
|
||||||
|
return "", dict(status=404)
|
||||||
|
|
||||||
|
|
||||||
def list_queues(self):
|
def list_queues(self):
|
||||||
queues = sqs_backend.list_queues()
|
queues = sqs_backend.list_queues()
|
||||||
|
@ -27,6 +27,9 @@ def test_get_queue():
|
|||||||
queue.name.should.equal("test-queue")
|
queue.name.should.equal("test-queue")
|
||||||
queue.get_timeout().should.equal(60)
|
queue.get_timeout().should.equal(60)
|
||||||
|
|
||||||
|
nonexisting_queue = conn.get_queue("nonexisting_queue")
|
||||||
|
nonexisting_queue.should.be.none
|
||||||
|
|
||||||
|
|
||||||
@mock_sqs
|
@mock_sqs
|
||||||
def test_delete_queue():
|
def test_delete_queue():
|
||||||
|
Loading…
Reference in New Issue
Block a user