From 1c3ba83fc2df785eea6db36ca058df2ff1727e40 Mon Sep 17 00:00:00 2001 From: usmangani1 Date: Wed, 30 Sep 2020 21:04:15 +0530 Subject: [PATCH] Fix : SQS Create Queue with attributes (#3345) * Considering only new attributes while queue creation * Linting Co-authored-by: usmankb Co-authored-by: Bert Blommers --- moto/sqs/models.py | 18 +++--------------- tests/test_sqs/test_sqs.py | 12 ++++++++++++ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/moto/sqs/models.py b/moto/sqs/models.py index 71ca62941..720ab6e75 100644 --- a/moto/sqs/models.py +++ b/moto/sqs/models.py @@ -545,22 +545,10 @@ class SQSBackend(BaseBackend): queue_attributes = queue.attributes new_queue_attributes = new_queue.attributes - static_attributes = ( - "DelaySeconds", - "MaximumMessageSize", - "MessageRetentionPeriod", - "Policy", - "QueueArn", - "ReceiveMessageWaitTimeSeconds", - "RedrivePolicy", - "VisibilityTimeout", - "KmsMasterKeyId", - "KmsDataKeyReusePeriodSeconds", - "FifoQueue", - "ContentBasedDeduplication", - ) - for key in static_attributes: + # only the attributes which are being sent for the queue + # creation have to be compared if the queue is existing. + for key in kwargs: if queue_attributes.get(key) != new_queue_attributes.get(key): raise QueueAlreadyExists("The specified queue already exists.") else: diff --git a/tests/test_sqs/test_sqs.py b/tests/test_sqs/test_sqs.py index 8c05e0f35..9ce0f21cd 100644 --- a/tests/test_sqs/test_sqs.py +++ b/tests/test_sqs/test_sqs.py @@ -89,6 +89,18 @@ def test_create_queue_with_different_attributes_fail(): else: raise RuntimeError("Should of raised QueueAlreadyExists Exception") + response = sqs.create_queue( + QueueName="test-queue1", Attributes={"FifoQueue": "True"} + ) + + attributes = {"VisibilityTimeout": "60"} + sqs.set_queue_attributes(QueueUrl=response.get("QueueUrl"), Attributes=attributes) + + new_response = sqs.create_queue( + QueueName="test-queue1", Attributes={"FifoQueue": "True"} + ) + new_response["QueueUrl"].should.equal(response.get("QueueUrl")) + @mock_sqs def test_create_fifo_queue():