SQS - get_queue_attributes() might not have AttributeNames-parameter (#4236)

This commit is contained in:
Bert Blommers 2021-08-28 09:34:33 +01:00 committed by GitHub
parent 532386327d
commit ec70d3cd14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -642,6 +642,8 @@ class SQSBackend(BaseBackend):
def get_queue_attributes(self, queue_name, attribute_names):
queue = self.get_queue(queue_name)
if not attribute_names:
return {}
valid_names = (
["All"]

View File

@ -1253,6 +1253,21 @@ def test_fifo_send_receive_message_with_attribute_name(attribute_name, expected)
expected["SequenceNumber"](message["Attributes"].get("SequenceNumber"))
@mock_sqs
def test_get_queue_attributes_no_param():
"""
AWS does not return the Attributes-key when omitting the AttributeNames-parameter
"""
sqs = boto3.client("sqs", region_name="ap-northeast-3")
queue_url = sqs.create_queue(QueueName="test-queue")["QueueUrl"]
queue_attrs = sqs.get_queue_attributes(QueueUrl=queue_url)
queue_attrs.shouldnt.have.key("Attributes")
queue_attrs = sqs.get_queue_attributes(QueueUrl=queue_url, AttributeNames=["All"])
queue_attrs.should.have.key("Attributes")
@mock_sqs
def test_max_number_of_messages_invalid_param():
sqs = boto3.resource("sqs", region_name="us-east-1")