Fix : SQS Create Queue with attributes (#3345)

* Considering only new attributes while queue creation

* Linting

Co-authored-by: usmankb <usman@krazybee.com>
Co-authored-by: Bert Blommers <info@bertblommers.nl>
This commit is contained in:
usmangani1 2020-09-30 21:04:15 +05:30 committed by GitHub
parent 1dd5cf08a8
commit 1c3ba83fc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 15 deletions

View File

@ -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:

View File

@ -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():