Test Suite
The test suite is located within the tests directory and is organized into two subdirectories: unit and selenium. The unit directory contains unit tests, which focus on testing individual components of the project in isolation. The selenium directory contains tests that utilize Selenium for browser-based testing, ensuring that the user interface and web interactions function as expected.
Run "Unit" tests
Unit tests are executed within a Docker container using the pytest framework. This ensures a consistent testing environment, isolated from local machine configurations.
docker compose run --rm backend pytest -n auto --reruns 3 -rP -p no:warnings --cov-report= --capture=sys ./tests/unit
Run "Selenium" functional test
Selenium tests run on the host machine. This is due to the fact that Selenium does not currently support the ARM64 architecture for Linux Docker images. This will require some more steps to be taken before running the tests.
Prerequisites
- uv
Installation
- Services
To run the tests locally, the following services are required:
- Postgres
- Redis
- Elasticsearch
You can either install these services manually or use the docker-compose
file located in the development_tools
directory.
- Running Services with Docker Compose
Make sure you have the required .env
file from the backend setup, then you can run the services using the following command:
cd development_tools
docker compose --profile services up
- Install system requirements on MACOS:
brew install wkhtmltopdf pango postgis gdal
- Create virtualenvironment:
uv venv .venv --python 3.12.0
- Register the created venv for the project with:
uv sync
- Activate your venv:
source .venv/bin/activate
- Check your environment:
eg.
$python --version
-> see that it uses Python 3.12.* - Install the packages:
uv build
- Run the tests:
source ./development_tools/local_selenium_init.sh` python -m pytest -svvv tests/selenium --html-report=./report/report.html`