diff --git a/moto/sqs/models.py b/moto/sqs/models.py index c0ac5926d..3f3b6b493 100644 --- a/moto/sqs/models.py +++ b/moto/sqs/models.py @@ -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: diff --git a/moto/sqs/responses.py b/moto/sqs/responses.py index 484fe681d..0f582cf85 100644 --- a/moto/sqs/responses.py +++ b/moto/sqs/responses.py @@ -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) - template = Template(GET_QUEUE_URL_RESPONSE) - return template.render(queue=queue) + 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() diff --git a/tests/test_sqs/test_sqs.py b/tests/test_sqs/test_sqs.py index eef6b29e7..e4d7de655 100644 --- a/tests/test_sqs/test_sqs.py +++ b/tests/test_sqs/test_sqs.py @@ -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():