-
Notifications
You must be signed in to change notification settings - Fork 0
Unit Tests and Coverage
To create the database for the first time, a virtual environment should be created, the requirements should be installed from the "requirements.txt" file using pip and the environment should be activated.
Currently, the unit tests use a SQLite database as the back-end rather than mocking the database.
To run the unit tests, a virtual environment should be created, the requirements should be installed using pip and the environment should be activated.
The tests can then be run from the command line, at the root of the project folder, as follows:
$env:PYTHONPATH="$pwd\src\"
python -m unittest
export PYTHONPATH=`pwd`/src/
python -m unittest
The first command adds the source folder, containing the two packages under test, to the PYTHONPATH environment variable so the packages will be found when the tests attempt to import them.
Similarly, a coverage report can be generated by running the following commands from the root of the project folder:
$env:PYTHONPATH="$pwd\src\"
coverage run --branch --source src -m unittest discover
coverage html -d cov_html
export PYTHONPATH=`pwd`/src/
coverage run --branch --source src -m unittest discover
coverage html -d cov_html
This will create a folder "cov_html" containing the coverage report in HTML format.