diff --git a/moto/sqs/models.py b/moto/sqs/models.py index ea3b89f0..5b6e6410 100644 --- a/moto/sqs/models.py +++ b/moto/sqs/models.py @@ -685,6 +685,8 @@ class SQSBackend(BaseBackend): entry["MessageBody"], message_attributes=entry["MessageAttributes"], delay_seconds=entry["DelaySeconds"], + group_id=entry.get("MessageGroupId"), + deduplication_id=entry.get("MessageDeduplicationId"), ) message.user_id = entry["Id"] diff --git a/moto/sqs/responses.py b/moto/sqs/responses.py index eed50a52..54a8bc26 100644 --- a/moto/sqs/responses.py +++ b/moto/sqs/responses.py @@ -291,6 +291,16 @@ class SQSResponse(BaseResponse): [None], )[0], "MessageAttributes": message_attributes, + "MessageGroupId": self.querystring.get( + "SendMessageBatchRequestEntry.{}.MessageGroupId".format(index), + [None], + )[0], + "MessageDeduplicationId": self.querystring.get( + "SendMessageBatchRequestEntry.{}.MessageDeduplicationId".format( + index + ), + [None], + )[0], } if entries == {}: diff --git a/tests/test_sqs/test_sqs.py b/tests/test_sqs/test_sqs.py index 31bbafff..2ed757f6 100644 --- a/tests/test_sqs/test_sqs.py +++ b/tests/test_sqs/test_sqs.py @@ -1044,6 +1044,8 @@ def test_send_message_batch(): "DataType": "String", } }, + "MessageGroupId": "message_group_id_1", + "MessageDeduplicationId": "message_deduplication_id_1", }, { "Id": "id_2", @@ -1052,6 +1054,8 @@ def test_send_message_batch(): "MessageAttributes": { "attribute_name_2": {"StringValue": "123", "DataType": "Number"} }, + "MessageGroupId": "message_group_id_2", + "MessageDeduplicationId": "message_deduplication_id_2", }, ], ) @@ -1066,10 +1070,22 @@ def test_send_message_batch(): response["Messages"][0]["MessageAttributes"].should.equal( {"attribute_name_1": {"StringValue": "attribute_value_1", "DataType": "String"}} ) + response["Messages"][0]["Attributes"]["MessageGroupId"].should.equal( + "message_group_id_1" + ) + response["Messages"][0]["Attributes"]["MessageDeduplicationId"].should.equal( + "message_deduplication_id_1" + ) response["Messages"][1]["Body"].should.equal("body_2") response["Messages"][1]["MessageAttributes"].should.equal( {"attribute_name_2": {"StringValue": "123", "DataType": "Number"}} ) + response["Messages"][1]["Attributes"]["MessageGroupId"].should.equal( + "message_group_id_2" + ) + response["Messages"][1]["Attributes"]["MessageDeduplicationId"].should.equal( + "message_deduplication_id_2" + ) @mock_sqs