Fix SQS send_message_batch empty array Exception handling

This commit is contained in:
usmankb 2020-05-02 01:33:58 +05:30
parent 4af10fe56b
commit 1431348161
2 changed files with 18 additions and 0 deletions

View File

@ -285,6 +285,9 @@ class SQSResponse(BaseResponse):
"MessageAttributes": message_attributes,
}
if entries == {}:
raise EmptyBatchRequest()
messages = self.sqs_backend.send_message_batch(queue_name, entries)
template = self.response_template(SEND_MESSAGE_BATCH_RESPONSE)

View File

@ -1147,6 +1147,21 @@ def test_send_message_batch_errors():
)
@mock_sqs
def test_send_message_batch_with_empty_list():
client = boto3.client("sqs", region_name="us-east-1")
response = client.create_queue(QueueName="test-queue")
queue_url = response["QueueUrl"]
client.send_message_batch.when.called_with(
QueueUrl=queue_url, Entries=[]
).should.throw(
ClientError,
"There should be at least one SendMessageBatchRequestEntry in the request.",
)
@mock_sqs
def test_batch_change_message_visibility():
if os.environ.get("TEST_SERVER_MODE", "false").lower() == "true":