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