mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-06 09:18:11 +08:00
Updates test for new wait and count options
This commit is contained in:
@@ -33,8 +33,13 @@ def test_cached(broker):
|
|||||||
async('math.copysign', 1, -1, cached=True, broker=broker, group=group)
|
async('math.copysign', 1, -1, cached=True, broker=broker, group=group)
|
||||||
async('math.popysign', 1, -1, cached=True, broker=broker, group=group)
|
async('math.popysign', 1, -1, cached=True, broker=broker, group=group)
|
||||||
# test wait on cache
|
# test wait on cache
|
||||||
assert result(task_id, wait=1, cached=True) is None
|
# test wait timeout
|
||||||
assert fetch(task_id, wait=1, cached=True) is None
|
assert result(task_id, wait=10, cached=True) is None
|
||||||
|
assert fetch(task_id, wait=10, cached=True) is None
|
||||||
|
assert result_group(group, wait=10, cached=True) is None
|
||||||
|
assert result_group(group, count=2, wait=10, cached=True) is None
|
||||||
|
assert fetch_group(group, wait=10, cached=True) is None
|
||||||
|
assert fetch_group(group, count=2, wait=10, cached=True) is None
|
||||||
# run a single cluster
|
# run a single cluster
|
||||||
start_event = Event()
|
start_event = Event()
|
||||||
stop_event = Event()
|
stop_event = Event()
|
||||||
@@ -42,7 +47,7 @@ def test_cached(broker):
|
|||||||
Sentinel(stop_event, start_event, broker=broker)
|
Sentinel(stop_event, start_event, broker=broker)
|
||||||
# assert results
|
# assert results
|
||||||
assert result(task_id, wait=500, cached=True) == -1
|
assert result(task_id, wait=500, cached=True) == -1
|
||||||
assert fetch(task_id,wait=500, cached=True).result == -1
|
assert fetch(task_id, wait=500, cached=True).result == -1
|
||||||
# make sure it's not in the db backend
|
# make sure it's not in the db backend
|
||||||
assert fetch(task_id) is None
|
assert fetch(task_id) is None
|
||||||
# assert group
|
# assert group
|
||||||
|
|||||||
@@ -160,6 +160,13 @@ def test_async(broker, admin_user):
|
|||||||
assert broker.queue_size() == 0
|
assert broker.queue_size() == 0
|
||||||
assert task_queue.qsize() == task_count
|
assert task_queue.qsize() == task_count
|
||||||
task_queue.put('STOP')
|
task_queue.put('STOP')
|
||||||
|
# test wait timeout
|
||||||
|
assert result(j, wait=10) is None
|
||||||
|
assert fetch(j, wait=10) is None
|
||||||
|
assert result_group('test_j', wait=10) is None
|
||||||
|
assert result_group('test_j', count=2, wait=10) is None
|
||||||
|
assert fetch_group('test_j', wait=10) is None
|
||||||
|
assert fetch_group('test_j', count=2, wait=10) is None
|
||||||
# let a worker handle them
|
# let a worker handle them
|
||||||
result_queue = Queue()
|
result_queue = Queue()
|
||||||
worker(task_queue, result_queue, Value('f', -1))
|
worker(task_queue, result_queue, Value('f', -1))
|
||||||
|
|||||||
Reference in New Issue
Block a user