Skip to content

Testing

Benjamin West edited this page Mar 18, 2023 · 10 revisions

Local running and testing

Pretty simplistic, there is a testing folder within the vets django application which houses the tests.

I wrote VetsTestRunner which loads test data once at the start of the run from VetsTestData. This gives a bit of data to get off the ground. This is explicitly defined in settings.py as the test runner for this project.

Env vars for local testing

export DJANGO_SECRET_KEY="<< some long string>>>"
export DJANGO_DATABASE="local"
export DJANGO_DEBUG="True" 

Running the tests

Just a call to:

# Grab the deps
pip install -r application/requirements.txt

# Make the initial db migration file and apply it to local DB.
python application/manage.py makemigrations
python application/manage.py migrate

# Time the big elements of the run (db creation) and verbosity == 2 
# Also you can keep the db for later if you wish (this is unreliable at best for me though!)
python application/manage.py test --timing -v 2 --keepdb

Running local server

Make a superuser in the db and fire up the dev server:

python application/manage.py createsuperuser
python application/manage.py runserver

Database interactions / manual validation

python application/manage.py dbshell

Deploying the CI pipeline

kubectl apply -f build-descriptors/vets
Clone this wiki locally