I am trying to come up with a testing methodology for our django-celery project. I have read the notes in the documentation, but it didn\'t give me a good idea of what to a
This is what I did
Inside myapp.tasks.py I have:
from celery import shared_task
@shared_task()
def add(a, b):
return a + b
Inside myapp.test_tasks.py I have:
from django.test import TestCase, override_settings
from myapp.tasks import add
class TasksTestCase(TestCase):
def setUp(self):
...
@override_settings(CELERY_TASK_ALWAYS_EAGER=True,CELERY_TASK_EAGER_PROPOGATES=True)
def test_create_sections(self):
result= add.delay(1,2)
assert result.successful() == True
assert result.get() == 3