Merge pull request #2402 from gruebel/fix-sqs-maxReceiveCount
Store SQS RedrivePolicy maxReceiveCount value as int
This commit is contained in:
commit
d88e1fbdda
@ -265,6 +265,9 @@ class Queue(BaseModel):
|
|||||||
if 'maxReceiveCount' not in self.redrive_policy:
|
if 'maxReceiveCount' not in self.redrive_policy:
|
||||||
raise RESTError('InvalidParameterValue', 'Redrive policy does not contain maxReceiveCount')
|
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():
|
for queue in sqs_backends[self.region].queues.values():
|
||||||
if queue.queue_arn == self.redrive_policy['deadLetterTargetArn']:
|
if queue.queue_arn == self.redrive_policy['deadLetterTargetArn']:
|
||||||
self.dead_letter_queue = queue
|
self.dead_letter_queue = queue
|
||||||
|
@ -1117,6 +1117,28 @@ def test_redrive_policy_set_attributes():
|
|||||||
assert copy_policy == redrive_policy
|
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
|
@mock_sqs
|
||||||
def test_receive_messages_with_message_group_id():
|
def test_receive_messages_with_message_group_id():
|
||||||
sqs = boto3.resource('sqs', region_name='us-east-1')
|
sqs = boto3.resource('sqs', region_name='us-east-1')
|
||||||
|
Loading…
Reference in New Issue
Block a user