add set_queue_attributes

This commit is contained in:
Steve Pulec 2013-02-23 22:35:05 -05:00
parent 89364ed864
commit 67261d3125
3 changed files with 33 additions and 1 deletions

View File

@ -38,5 +38,9 @@ class SQSBackend(BaseBackend):
return self.queues.pop(queue_name)
return False
def set_queue_attribute(self, queue_name, key, value):
queue = self.get_queue(queue_name)
setattr(queue, key, value)
return queue
sqs_backend = SQSBackend()

View File

@ -51,6 +51,13 @@ class QueueResponse(BaseResponse):
template = Template(GET_QUEUE_ATTRIBUTES_RESPONSE)
return template.render(queue=queue)
def set_queue_attributes(self):
queue_name = self.path.split("/")[-1]
key = camelcase_to_underscores(self.querystring.get('Attribute.Name')[0])
value = self.querystring.get('Attribute.Value')[0]
queue = sqs_backend.set_queue_attribute(queue_name, key, value)
return SET_QUEUE_ATTRIBUTE_RESPONSE
def delete_queue(self):
queue_name = self.path.split("/")[-1]
queue = sqs_backend.delete_queue(queue_name)
@ -107,4 +114,12 @@ GET_QUEUE_ATTRIBUTES_RESPONSE = """<GetQueueAttributesResponse>
<ResponseMetadata>
<RequestId>1ea71be5-b5a2-4f9d-b85a-945d8d08cd0b</RequestId>
</ResponseMetadata>
</GetQueueAttributesResponse>"""
</GetQueueAttributesResponse>"""
SET_QUEUE_ATTRIBUTE_RESPONSE = """<SetQueueAttributesResponse>
<ResponseMetadata>
<RequestId>
e5cca473-4fc0-4198-a451-8abb94d02c75
</RequestId>
</ResponseMetadata>
</SetQueueAttributesResponse>"""

View File

@ -28,3 +28,16 @@ def test_delete_queue():
conn.get_all_queues().should.have.length_of(0)
queue.delete.when.called_with().should.throw(SQSError)
@mock_sqs
def test_set_queue_attribute():
conn = boto.connect_sqs('the_key', 'the_secret')
conn.create_queue("test-queue", visibility_timeout=60)
queue = conn.get_all_queues()[0]
queue.get_timeout().should.equal(60)
queue.set_attribute("VisibilityTimeout", 45)
queue = conn.get_all_queues()[0]
queue.get_timeout().should.equal(45)