Tests¶
- Tests are written using Pytest. Tests are split at the top folder level into
unit,e2e_integrationandmigrationtests (alongside some shared fixtures). - The distinction between
unitande2e_integrationhere is any test that requires some/all of the docker compose testing stack to be running is considered an end-to-end/integration test. - Note that there maybe "unit like" tests inside the
e2e_integrationdir, primarily for convenience/legacy reasons (before this top level split was made). - Unit tests should follow the pattern
tests/unit/<package>/<module>/<test_file_name>.py(i.e. match the module structure of the packages in the codebase). - migration tests cover the database migration scripts located in the Alembic migrations directory and are autogenerated by the pytest-alembic plugin. They check for things like if the database can be rolled back and forth cleanly through all migration scripts and if all db models in the code correctly match the state after applying all migration scripts (aka you haven't created a migration script for your latest model changes).
As we run tests for the frontend with playwright, you may need to install the browsers used by playwright for testing. You can do this by running:
playwright install
To run all tests¶
pytest # you may want to append the -s flag to print standard output.
To run only unit, e2e_integration or migration tests:
pytest tests/unit
pytest tests/e2e_integration
pytest tests/migration
The e2e_integration tests will be slower the first time you run them as the docker images will need to be downloaded and built. If you use "-s" you'll see the status of the docker compose building steps.