Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def create_queue(self, queue_name: str, attributes: dict | None = None) -> dict:
:return: dict with the information about the queue.
"""
self.log.debug("Creating SQS queue %s with attributes %s", queue_name, attributes)
result = self.get_conn().create_queue(QueueName=queue_name, Attributes=attributes or {})
safe_attributes = {k: str(v) for k, v in (attributes or {}).items()}
result = self.get_conn().create_queue(QueueName=queue_name, Attributes=safe_attributes or {})
self.log.debug("Created SQS queue %s, response: %s", queue_name, result.get("QueueUrl"))
return result

Expand Down
23 changes: 23 additions & 0 deletions providers/amazon/tests/unit/amazon/aws/hooks/test_sqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,29 @@ def test_send_message_with_delay(self, hook):
immediate_receive = hook.get_conn().receive_message(QueueUrl=self.queue_url, WaitTimeSeconds=0)
assert "Messages" not in immediate_receive or len(immediate_receive.get("Messages", [])) == 0

def test_create_queue_with_int_attributes(self, hook):
"""Test that int attribute values are internally cast to strings and queue creation succeeds."""
queue_name = "test-queue-int-casting"
# These are the int values that the casting logic (fixed in SqsHook) should handle.
attributes = {
"DelaySeconds": 10,
"MaximumMessageSize": 262144,
}

response = hook.create_queue(queue_name=queue_name, attributes=attributes)

assert "QueueUrl" in response
assert queue_name in response["QueueUrl"]

# Verify that the attributes were correctly cast and stored as strings in the SQS service (moto).
queue_attrs = hook.get_conn().get_queue_attributes(
QueueUrl=response["QueueUrl"], AttributeNames=["DelaySeconds", "MaximumMessageSize"]
)

# moto/boto3 returns values as strings; if these assertions pass, the casting logic is verified.
assert queue_attrs["Attributes"]["DelaySeconds"] == "10"
assert queue_attrs["Attributes"]["MaximumMessageSize"] == "262144"


@pytest.mark.asyncio
class TestAsyncSqsHook:
Expand Down
Loading