Merge pull request #1439 from anderson-dan-w/redrive-policy

Redrive policy
This commit is contained in:
Steve Pulec 2018-03-06 22:22:49 -05:00 committed by GitHub
commit 8b3743fa9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 0 deletions

View File

@ -166,6 +166,7 @@ class Queue(BaseModel):
'MessageRetentionPeriod',
'QueueArn',
'ReceiveMessageWaitTimeSeconds',
'RedrivePolicy',
'VisibilityTimeout',
'WaitTimeSeconds']
ALLOWED_PERMISSIONS = ('*', 'ChangeMessageVisibility', 'DeleteMessage', 'GetQueueAttributes',
@ -285,6 +286,8 @@ class Queue(BaseModel):
attr = getattr(self, camelcase_to_underscores(attribute))
if isinstance(attr, bool):
attr = str(attr).lower()
elif attribute == 'RedrivePolicy':
attr = json.dumps(attr)
result[attribute] = attr
return result

View File

@ -932,3 +932,27 @@ def test_queue_with_dlq():
resp = sqs.list_dead_letter_source_queues(QueueUrl=queue_url1)
resp['queueUrls'][0].should.equal(queue_url2)
@mock_sqs
def test_redrive_policy_available():
sqs = boto3.client('sqs', region_name='us-east-1')
resp = sqs.create_queue(QueueName='test-deadletter')
queue_url1 = resp['QueueUrl']
queue_arn1 = sqs.get_queue_attributes(QueueUrl=queue_url1)['Attributes']['QueueArn']
redrive_policy = {
'deadLetterTargetArn': queue_arn1,
'maxReceiveCount': 1,
}
resp = sqs.create_queue(
QueueName='test-queue',
Attributes={
'RedrivePolicy': json.dumps(redrive_policy)
}
)
queue_url2 = resp['QueueUrl']
attributes = sqs.get_queue_attributes(QueueUrl=queue_url2)['Attributes']
assert 'RedrivePolicy' in attributes
assert json.loads(attributes['RedrivePolicy']) == redrive_policy