Merge pull request #398 from jotes/sqs_polling_messages
Added support for WaitTimeSeconds in SQS #392
This commit is contained in:
commit
ebfe7bb7b8
3 changed files with 81 additions and 17 deletions
|
|
@ -1,6 +1,9 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import re
|
||||
import sure # noqa
|
||||
import threading
|
||||
import time
|
||||
|
||||
import moto.server as server
|
||||
|
||||
|
|
@ -30,3 +33,38 @@ def test_sqs_list_identities():
|
|||
|
||||
message = re.search("<Body>(.*?)</Body>", res.data.decode('utf-8')).groups()[0]
|
||||
message.should.equal('test-message')
|
||||
|
||||
|
||||
def test_messages_polling():
|
||||
backend = server.create_backend_app("sqs")
|
||||
test_client = backend.test_client()
|
||||
messages = []
|
||||
|
||||
test_client.put('/?Action=CreateQueue&QueueName=testqueue')
|
||||
|
||||
def insert_messages():
|
||||
messages_count = 5
|
||||
while messages_count > 0:
|
||||
test_client.put(
|
||||
'/123/testqueue?MessageBody=test-message&Action=SendMessage'
|
||||
'&Attribute.1.Name=WaitTimeSeconds&Attribute.1.Value=10'
|
||||
)
|
||||
messages_count -= 1
|
||||
time.sleep(.5)
|
||||
|
||||
def get_messages():
|
||||
msg_res = test_client.get(
|
||||
'/123/testqueue?Action=ReceiveMessage&MaxNumberOfMessages=1&WaitTimeSeconds=5'
|
||||
)
|
||||
[messages.append(m) for m in re.findall("<Body>(.*?)</Body>", msg_res.data.decode('utf-8'))]
|
||||
|
||||
get_messages_thread = threading.Thread(target=get_messages)
|
||||
insert_messages_thread = threading.Thread(target=insert_messages)
|
||||
|
||||
get_messages_thread.start()
|
||||
insert_messages_thread.start()
|
||||
|
||||
get_messages_thread.join()
|
||||
insert_messages_thread.join()
|
||||
|
||||
assert len(messages) == 5
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue