SQS: send_message() should respect DelaySeconds of 0 (#7373)
This commit is contained in:
parent
f7b8a92212
commit
f9add957c9
@ -845,7 +845,7 @@ class SQSBackend(BaseBackend):
|
||||
|
||||
self._validate_message(queue, message_body, deduplication_id, group_id)
|
||||
|
||||
if delay_seconds:
|
||||
if delay_seconds is not None:
|
||||
delay_seconds = int(delay_seconds)
|
||||
else:
|
||||
delay_seconds = queue.delay_seconds # type: ignore
|
||||
|
@ -308,7 +308,7 @@ class SQSResponse(BaseResponse):
|
||||
@jsonify_error
|
||||
def send_message(self) -> Union[str, TYPE_RESPONSE]:
|
||||
message = self._get_param("MessageBody")
|
||||
delay_seconds = int(self._get_param("DelaySeconds", 0))
|
||||
delay_seconds = self._get_param("DelaySeconds")
|
||||
message_group_id = self._get_param("MessageGroupId")
|
||||
message_dedupe_id = self._get_param("MessageDeduplicationId")
|
||||
|
||||
|
@ -1438,6 +1438,19 @@ def test_send_message_with_delay():
|
||||
assert len(messages) == 0
|
||||
|
||||
|
||||
@mock_aws
|
||||
def test_send_message_with_message_delay_overriding_queue_delay():
|
||||
sqs = boto3.client("sqs", region_name="us-east-1")
|
||||
name = str(uuid4())[0:6]
|
||||
# By default, all messages on this queue are delayed
|
||||
resp = sqs.create_queue(QueueName=name, Attributes={"DelaySeconds": "10"})
|
||||
queue_url = resp["QueueUrl"]
|
||||
# But this particular message should have no delay
|
||||
sqs.send_message(QueueUrl=queue_url, MessageBody="test", DelaySeconds=0)
|
||||
resp = sqs.receive_message(QueueUrl=queue_url, MaxNumberOfMessages=10)
|
||||
assert len(resp["Messages"]) == 1
|
||||
|
||||
|
||||
@mock_aws
|
||||
def test_send_large_message_fails():
|
||||
sqs = boto3.resource("sqs", region_name="us-east-1")
|
||||
|
Loading…
Reference in New Issue
Block a user