mardi 31 mars 2020

Is there a way to test Django project creation with pytest/Django test suite?

I created a Django plugin system which creates some boilerplate code. It can be used in any Django project (GDAPS), and provides a few management commands.

What is the best way to test this whole suite? I mean, I can create bash scripts that setup fake Django projects which include my project, and then call all the management commands like makemigrations, migrate etc. to set it up fully, call my special commands (./manage.py initfrontend) and check if the results created the right files correctly.

Now bash scripts are not my favourite testing suite, I'd keep with python and pytest if possible. Is there a way to test things like that? How can I start here - I can't wrap my head around this. I have already written plenty of unit tests for various features of the framework, but these tests are alike integration tests.

I know I can use django.core.management.call_command() to call mgmt commands from code. But how do I set up the "fake" project - for each test an own temp directory? Thanks for your help.

Aucun commentaire:

Enregistrer un commentaire