django-commons/django-cookie-consent

Manage.py Missing And New Structure For Test App

Closed this issue · 1 comments

In previous versions, manage.py existed and it was easy for people to use the testapp and make changes to the code.

Manage.py used to be inside the tests folder. Now we have other files located here:

https://github.com/jazzband/django-cookie-consent/tree/master/tests

Conftest.py is blank:

https://github.com/jazzband/django-cookie-consent/blob/master/tests/conftest.py

There was some restructuring done to the app.

47bced6

Versions:

https://github.com/jazzband/django-cookie-consent/tags

If anyone could figure out how to run the testapp using this new structure, it would be appreciated. We should really add docs about how to do this for people who are not familiar with running an app or tests this way.

It seems like we would need to install pytest.

pip3 install pytest pytest-django
cd django-cookie-consent/tests
python3 -m pytest

I recreated the manage.py file inside of the tests folder.

https://github.com/jazzband/django-cookie-consent/blob/443dc60c020867e81349cb5b1fed285ef45a1e19/tests/manage.py

Then I ran

export DJANGO_SETTINGS_MODULE=testapp.settings
python3 manage.py makemigrations
python3 manage.py migrate

manage.py is more or less a wrapper around django-admin
DJANGO_SETTINGS_MODULE=testapp.settings django-admin test

Now when you run python3 manage.py runserver in the tests folder you see 'testapp.settings' in your terminal output:

Django version 4.1.7, using settings 'testapp.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

Good suggestion - since this is our default library structure it's "obvious" for us, but not for people unfamiliar with it. I'm adding this to the contributing documentation, but you pretty much found the gist of the involved steps:

export DJANGO_SETTINGS_MODULE=testapp.settings

django-admin migrate
django-admin createsuperuser
django-admin runserver