From 3fd33c03bfea3f7e50804c7f10de3076cf186b10 Mon Sep 17 00:00:00 2001 From: Scott Leishman Date: Fri, 19 Feb 2016 23:32:01 -0800 Subject: [PATCH] boto3 SQS set attributes fix. --- moto/sqs/responses.py | 11 ++++++++--- tests/test_sqs/test_sqs.py | 11 +++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/moto/sqs/responses.py b/moto/sqs/responses.py index d1ba5b6dd..7d37c44fb 100644 --- a/moto/sqs/responses.py +++ b/moto/sqs/responses.py @@ -90,9 +90,14 @@ class SQSResponse(BaseResponse): def set_queue_attributes(self): queue_name = self._get_queue_name() - key = camelcase_to_underscores(self.querystring.get('Attribute.Name')[0]) - value = self.querystring.get('Attribute.Value')[0] - self.sqs_backend.set_queue_attribute(queue_name, key, value) + if "Attribute.Name" in self.querystring: + key = camelcase_to_underscores(self.querystring.get("Attribute.Name")[0]) + value = self.querystring.get("Attribute.Value")[0] + self.sqs_backend.set_queue_attribute(queue_name, key, value) + for a in self._get_list_prefix("Attribute"): + key = camelcase_to_underscores(a["name"]) + value = a["value"] + self.sqs_backend.set_queue_attribute(queue_name, key, value) return SET_QUEUE_ATTRIBUTE_RESPONSE def delete_queue(self): diff --git a/tests/test_sqs/test_sqs.py b/tests/test_sqs/test_sqs.py index 1e300fa57..cc7ac7d10 100644 --- a/tests/test_sqs/test_sqs.py +++ b/tests/test_sqs/test_sqs.py @@ -491,3 +491,14 @@ def test_boto3_message_send(): messages = queue.receive_messages() messages.should.have.length_of(1) + + +@mock_sqs +def test_boto3_set_queue_attributes(): + sqs = boto3.resource('sqs', region_name='us-east-1') + queue = sqs.create_queue(QueueName="blah") + + queue.attributes['VisibilityTimeout'].should.equal("30") + + queue.set_attributes(Attributes={"VisibilityTimeout": "45"}) + queue.attributes['VisibilityTimeout'].should.equal("45")