store SQS RedrivePolicy maxReceiveCount value as int
This commit is contained in:
parent
94fd5c4128
commit
9ac20ad5f1
@ -263,6 +263,9 @@ class Queue(BaseModel):
|
||||
if 'maxReceiveCount' not in self.redrive_policy:
|
||||
raise RESTError('InvalidParameterValue', 'Redrive policy does not contain maxReceiveCount')
|
||||
|
||||
# 'maxReceiveCount' is stored as int
|
||||
self.redrive_policy['maxReceiveCount'] = int(self.redrive_policy['maxReceiveCount'])
|
||||
|
||||
for queue in sqs_backends[self.region].queues.values():
|
||||
if queue.queue_arn == self.redrive_policy['deadLetterTargetArn']:
|
||||
self.dead_letter_queue = queue
|
||||
|
@ -1117,6 +1117,28 @@ def test_redrive_policy_set_attributes():
|
||||
assert copy_policy == redrive_policy
|
||||
|
||||
|
||||
@mock_sqs
|
||||
def test_redrive_policy_set_attributes_with_string_value():
|
||||
sqs = boto3.resource('sqs', region_name='us-east-1')
|
||||
|
||||
queue = sqs.create_queue(QueueName='test-queue')
|
||||
deadletter_queue = sqs.create_queue(QueueName='test-deadletter')
|
||||
|
||||
queue.set_attributes(Attributes={
|
||||
'RedrivePolicy': json.dumps({
|
||||
'deadLetterTargetArn': deadletter_queue.attributes['QueueArn'],
|
||||
'maxReceiveCount': '1',
|
||||
})})
|
||||
|
||||
copy = sqs.get_queue_by_name(QueueName='test-queue')
|
||||
assert 'RedrivePolicy' in copy.attributes
|
||||
copy_policy = json.loads(copy.attributes['RedrivePolicy'])
|
||||
assert copy_policy == {
|
||||
'deadLetterTargetArn': deadletter_queue.attributes['QueueArn'],
|
||||
'maxReceiveCount': 1,
|
||||
}
|
||||
|
||||
|
||||
@mock_sqs
|
||||
def test_receive_messages_with_message_group_id():
|
||||
sqs = boto3.resource('sqs', region_name='us-east-1')
|
||||
|
Loading…
Reference in New Issue
Block a user