Automated Testing

Testing and linting are handled by Tox. Using Tox, we can check code style and run the unit and integration tests with a single command.

$ tox

We use GitHub Actions to run these checks against new changes pushed to the GitHub repository. These checks are triggered with any commit pushed to or any Pull Request submitted to the master or dev branches.

On push to dev or master, the file .github/workflows/django.yml will run. Part of the workflow calls tox, which causes the file tox.ini to run. In the [testenv] section of tox.ini, manage.py test is called and this runs all files in the working directory that follow the pattern test*.py, in this case test_forms.py, test_models.py, and test_urls.py. These files contain the tests for lowFAT, written using django’s testing framework.

Manual Testing

If you want to test manually, run

$ python3 manage.py loaddata lowfat/fixtures/demo.json
$ python3 manage.py runserver

Logging in

To debug user reported issues it is somtimes necessary to mimic user behavior in a known environment. To this purpose we include several test users to log in as.

The users in the testing database:

Year Username Password Permissions
N/A admin 123admin456 staff
2014 tanisha 123tan456 fellow
2015 orlando 123orlan456 fellow
2015 sharon 123sharon456 fellow
2016 ali 123ali456 fellow
2016 maya 123maya456 fellow
2016 rooney 123rooney456 shortlisted

Avatars are from People vector created by Freepik.

Emails

LowFAT automates several email tasks. We use the Django text based email debugger. Any emails ‘sent’ by the test server will appear in tmp/emails/*.log. Note: it may be necessary to activate emails using the django admin panel located here: http://127.0.0.1:8000/admin/constance/config/ and selecting CLAIMANT_EMAIL_NOTIFICATION and/or STAFF_EMAIL_NOTIFICATION.

Updating the testing database

Occasionally it may be necessary to update the testing database, for example to add fellows from new intakes or test other kinds of users.

To export your changes on the database, run

$ python manage.py dumpdata -e sessions -e admin -e contenttypes -e auth.Permission -e lowfat.historicalclaimant -e lowfat.historicalfund -e lowfat.historicalexpense -e lowfat.historicalblog --indent 4 auth lowfat > fixtures/demo.json 

To share your changes on the database, run

$ git commit -am 'Update database'
$ git push origin master

and create a pull request.