Hi, I’m developing the django-simple-deploy project to help make the initial deployment process much easier for people who are new to Django. Basically, if you have a simple Django project that works locally on your system you can deploy your project in just three steps. The only assumptions are that you’re using Git, you’ve specified your project’s requirements, and you have an account on a platform like Heroku.
I’m unclear on the best way to approach testing the project, because it’s a standalone management command. Currently I have a sample_project/ folder with a simple blog app. I have a test script I wrote in bash that copies the blog project to a tmp directory, and then uses django-simple-deploy just as a user would. It then calls a .py file that uses requests to run a number of tests on the deployed version of the blog project, to ensure that the deployment process worked. There are some improvements I can make to this testing, but overall I’m comfortable with it because it mimics how users interact with the project. This integration test takes minutes to run because it deploys the project to Heroku or Azure. I don’t think there’s any way to speed this up, because I’m limited by the time these platforms take to process a deployment.
My main question is how to approach unit testing the project. The command,
python manage.py simple_deploy, needs to run against a Django project. The concept is simple;
simple_deploy modifies the project, and I want to verify that those modifications are correct. But I’m not sure how to structure the unit testing overall:
- Use pytest, and figure out how to bring the sample blog project into the testing framework?
- Move the blog project up to the root level of the project, and then I can use standard approaches to testing management commands?
The first approach seems complicated because I would have to activate a Django project inside the Django project I’m testing. But the second approach feels like it would really clutter the overall organization of the django-simple-deploy project itself.
Does anyone have any clear thoughts on how to approach this, or suggestions for how to organize the project differently to better support unit testing?