This projects contains the source code examples accompanying the blog post: https://www.python-celery.com/2018/05/01/unit-testing-celery-tasks.
Docker use is highly recommended.
-
Bring up the docker stack:
docker-compose up -d
-
Run unit tests:
docker-compose exec app pyton -m unittest discover -vv
-
Install and start RabbitMQ: Ensure RabbitMQ runs on port 5672 and the user
user
with passwordpassword
is set up -
Create virtual environment:
virtualenv celery-unit-test
-
Activate virtual environment:
source activate celery-unit-test
-
Install pip packages:
pip install -r requirements.txt
-
Run unit tests:
RABBITMQ_DEFAULT_USER=user CELERY_BROKER_URL=amqp://user:password@localhost:5672 python -m unittest discover -vv