-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
48 lines (37 loc) · 845 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""
Test basic queue functionality
>>> from queues import queues
>>> import time
>>> queue_name = 'test_queues_%.f' % time.time()
Verify that the queue does not exist
>>> queue_name in queues.get_list()
False
Create the queue
>>> q = queues.Queue(queue_name)
Write to the queue
>>> q.write('test')
True
Verify that it is indeed in the list
>>> queue_name in queues.get_list()
True
Get the length of the queue
Note that SQS doesn't guarantee that the message
we just wrote will be immediately available
>>> len(q)
1
Read from the queue
>>> unicode(q.read())
u'test'
The queue should now be empty
Note that SQS doesn't guarantee an accurate count
>>> len(q)
0
>>> try:
... queues.delete_queue(queue_name)
... except NotImplementedError:
... print True
True
"""
if __name__ == "__main__":
import doctest
doctest.testmod()