People-Places-Solutions/floodmodeller-api

Improved test module

Closed this issue · 2 comments

Currently we have a simple unittest suite in one file with multiple unittest classes. Better practice would be to separate each class and theme into separate files. For example the test folder would look something like this:

test/
    test_dat.py
    test_ied.py
    test_ief.py
    test_zzn.py
    test_backup.py
    test_units/
        test_section.py  # Example of testing a single unit class

We should aslo consider using the pytest package which allows for simpler test set up and provides some extra useful things like parameterisation and fixtures.

Tasks

Update:
I've altered the test structure, converted all tests to pytest and made a start on documentation. I have also set up a GitHub action to automatically run tests on pull requests to master and pushes on any branch. This will help us keep track if a bug gets introduced.

We should alter the repository settings to prevent merges to the main branch if tests are failling. I've added a task for this. There are some instructions here:
https://www.freecodecamp.org/news/what-are-github-actions-and-how-can-you-automate-tests-and-slack-notifications/

Code Coverage:
We can use codecov for code coverage but we would need to get the admins of the GitHub org to approve it to access private information. Might be worth discussing this with IT if we decide to go down this route. Pytest does provide tools to check code coverage (pip install pytest-cov then pytest --cov to get a report).

Here is the warning it gives before making the request:
Owners will receive an email regarding your request.
By requesting this approval, you are asking owners of the People-Places-Solutions organization to allow this application to access private organization data and modify public organization data.