I have an API endpoint to register new user. The "welcome email" will enqueue and do this task async. I have 2 unit tests to check:
- Api does save user's information to DB OK
- The Celery task does send email with right content+template
I want to add 3rd unit test to ensure "The endpoint has to enqueue email-sending after saving user form to DB"
I try with celery.AsyncResult but it ask me to run the worker. For further, even if the worker is ready, we still can't verify the task was enqueued or not because the ambiguous PENDING state:
- Task exists in queue but not execute yet: PENDING
- Task doesn't exist in queue: PENDING
Does anyone face this problem? How do I solve it?