Skip to content

Testing

Luke Parkinson edited this page Jul 28, 2022 · 3 revisions

Tests exist for each module (i.e. lidar_fetch).

Automated testing

Github Actions are used to run tests after each push to remote (i.e. github). Miniconda from the GitHub Actions marketplace is used to install the package dependencies. Linting with Flake8 and testing with PyTest is then performed. Several tests require an API key. This is stored as a GitHub secret and accessed by the workflow.

See Package Requirements for details about the required API tokens. This blog was used to create the secret string directly from an .env file, and to set the GitHub Actions workflow to create a local instance of the .env file for each workflow run.

Check the actions tab after you push to check if your tests run successfully.

Running tests locally

The test_vector_fetch requires a LINZ API token. Create an API token using the instructions under the Requirements section then store it in an .env file under root.

LINZ_API="COPY_YOUR_API_KEY_HERE"

In the conda environment defined in the root\environment.yml, run the following in the repository root folder:

  1. to run individual tests call python -m tests.lidar_fetch_test.lidar_fetch_test or python -m tests.test_vector_fetch.test_vector_fetch etc.
  2. to run all tests call python -m unittest
Clone this wiki locally