mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-05 10:38:12 +08:00
allow Null results - added test
This commit is contained in:
@@ -1,13 +1,7 @@
|
|||||||
import time
|
# simple countdown, returns nothing
|
||||||
|
|
||||||
# simple countdown
|
|
||||||
def countdown(n):
|
def countdown(n):
|
||||||
start_time = time.time()
|
|
||||||
while n > 0:
|
while n > 0:
|
||||||
n -= 1
|
n -= 1
|
||||||
stop_time = time.time()
|
|
||||||
return stop_time - start_time
|
|
||||||
|
|
||||||
|
|
||||||
def count_letters(tup):
|
def count_letters(tup):
|
||||||
total = 0
|
total = 0
|
||||||
|
|||||||
@@ -108,10 +108,13 @@ def blah_async():
|
|||||||
hook='django_q.tests.test_q.assert_bad_result')
|
hook='django_q.tests.test_q.assert_bad_result')
|
||||||
# unknown function
|
# unknown function
|
||||||
d = async('django_q.tests.tasks.does_not_exist', WordClass(), hook='django_q.tests.test_q.assert_bad_result')
|
d = async('django_q.tests.tasks.does_not_exist', WordClass(), hook='django_q.tests.test_q.assert_bad_result')
|
||||||
|
# function without result
|
||||||
|
e = async('django_q.tests.tasks.countdown', 100000)
|
||||||
assert isinstance(a, str)
|
assert isinstance(a, str)
|
||||||
assert isinstance(b, str)
|
assert isinstance(b, str)
|
||||||
assert isinstance(c, str)
|
assert isinstance(c, str)
|
||||||
assert isinstance(d, str)
|
assert isinstance(d, str)
|
||||||
|
assert isinstance(e, str)
|
||||||
run_cluster()
|
run_cluster()
|
||||||
result_a = get_task(a)
|
result_a = get_task(a)
|
||||||
assert result_a is not None
|
assert result_a is not None
|
||||||
@@ -127,6 +130,10 @@ def blah_async():
|
|||||||
result_d = get_task(d)
|
result_d = get_task(d)
|
||||||
assert result_d is not None
|
assert result_d is not None
|
||||||
assert result_d.success is False
|
assert result_d.success is False
|
||||||
|
result_e = get_task(e)
|
||||||
|
assert result_e is not None
|
||||||
|
assert result_e.success is True
|
||||||
|
assert result(b) is None
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
|
|||||||
Reference in New Issue
Block a user