Adding MessageGroupId and MessageDeduplicationId (#3163)

Adding MessageGroupId and MessageDeduplicationId when sent from batch (#3101)
This commit is contained in:
ryanlchandler 2020-07-22 08:09:12 -04:00 committed by GitHub
parent b09c8034e6
commit bf8eb11dc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 0 deletions

View File

@ -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"]

View File

@ -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 == {}:

View File

@ -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