I am using django now, I have created a django-project with three django-apps in it.
Each app can be used in isolation, without the others, but all three apps are working together somehow.
For each app I have custom commands for unit-, integration- and end-to-end-tests.
project/
+---- app1/
| +- management/commands/
| +- unittest.py
| |
| +- integrationtest.py
| |
| +- etoetest.py
+---- app2/
| +- management/commands/
| +- unittest.py
| |
| +- integrationtest.py
| |
| +- etoetest.py
+---- app3/
| +- management/commands/
| +- unittest.py
| |
| +- integrationtest.py
| |
| +- etoetest.py
What I want to know, is there a way to run manage.py inside the project and give it some kind of argument to specify the app for which a command has to be executed?
I want to do something like this:
./manage.py unittest app1 --arg0 ...
If there is a way, where in the project should the solution live?
I tried implementing djangos AppCommand or playing with different settings.py to execute the desired commands. But each of the two solutions did not feel right and did not really integrate well into the overall architecture of the project.
As far as I know there isn’t. Management commands are intended to be executed from a command line.
I would create app1_unittest, app2_unittest, app3_unittest. Ditto the others.
To run all, you would write a script. You might use bash, or you might use python subprocess.run. Bash might be as simple as
set -x
./manage.py app1_unittest $*
./manage.py app1_unittest $*
./manage.py app1_unittest $*
python subprocess.run would let you write it as a management command
./manage.py all_unittests