[BangPypers] Django - Testing Celery Tasks!

Anand Reddy Pandikunta anand21nanda at gmail.com
Wed Aug 6 08:47:46 CEST 2014


Hi,

Here is one simple model and a celery task.
Can some one tell me how to write a test for this task?
Thank you!

*my_app/models.py*
*class MyModel(models.Model):*
*    x = models.IntegerField()*
*    y = models.IntegerField()*
*    sum = models.IntegerField()*

*my_app/tests/test_tasks.py*
*@celery.task()*
*def add(id):*
*    m = MyModel.objects.get(pk=id)*
*    m.sum = m.x + m.y*
*    m.save()*
*    return True*

-- 
- Anand Reddy Pandikunta
www.avilpage.com
www.quotes160.com


More information about the BangPypers mailing list