mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-02 08:38:11 +08:00
fixed typo and added group tests
This commit is contained in:
+1
-1
@@ -48,7 +48,7 @@ class Task(models.Model):
|
|||||||
group = Task.objects.filter(group=group_id)
|
group = Task.objects.filter(group=group_id)
|
||||||
if objects:
|
if objects:
|
||||||
return group.delete()
|
return group.delete()
|
||||||
return group.update(group_id=None)
|
return group.update(group=None)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_task(task_id):
|
def get_task(task_id):
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ sys.path.insert(0, myPath + '/../')
|
|||||||
|
|
||||||
from django_q.cluster import Cluster, Sentinel, pusher, worker, monitor
|
from django_q.cluster import Cluster, Sentinel, pusher, worker, monitor
|
||||||
from django_q.humanhash import DEFAULT_WORDLIST
|
from django_q.humanhash import DEFAULT_WORDLIST
|
||||||
from django_q.tasks import fetch, fetch_group, async, result, result_group
|
from django_q.tasks import fetch, fetch_group, async, result, result_group, count_group, delete_group
|
||||||
from django_q.models import Task
|
from django_q.models import Task
|
||||||
from django_q.conf import Conf, redis_client
|
from django_q.conf import Conf, redis_client
|
||||||
from .tasks import multiply
|
from .tasks import multiply
|
||||||
@@ -197,8 +197,17 @@ def test_async(r, admin_user):
|
|||||||
assert result_j is not None
|
assert result_j is not None
|
||||||
assert result_j.success is True
|
assert result_j.success is True
|
||||||
assert result_j.result == result_j.args[0].id
|
assert result_j.result == result_j.args[0].id
|
||||||
|
# check fetch, result by name
|
||||||
|
assert fetch(result_j.name) == result_j
|
||||||
|
assert result(result_j.name) == result_j.result
|
||||||
|
# groups
|
||||||
assert result_group('test_j') == [result_j.result]
|
assert result_group('test_j') == [result_j.result]
|
||||||
assert fetch_group('test_j')[0].id == [result_j][0].id
|
assert fetch_group('test_j')[0].id == [result_j][0].id
|
||||||
|
assert count_group('test_j') == 1
|
||||||
|
assert count_group('test_j', failures=True) == 0
|
||||||
|
assert delete_group('test_j') == 1
|
||||||
|
assert delete_group('test_j', tasks=True) is None
|
||||||
|
|
||||||
r.delete(list_key)
|
r.delete(list_key)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user