Testing
Structure
Unit tests live in test/unit, integration tests live in test/system/integration, and E2E tests live in test/system/e2e.
General
When populating the database with data, if this data will be used by multiple tests, do so in fixtures. Such fixtures should always return a domain object.
Where possible, perform assertions against domain objects, dictionaries, or lists, rather than on individual properties.
Always test only public methods.
Never import from conftest.py.
Never use datetime.now in tests.
Integration Tests
Each test should call exactly one repository method (the method under test). All setup and verification should use raw SQL via the executor fixture.
When inserting multiple rows into the same table during test setup, use execute_many instead of multiple execute calls.
E2E Tests
Locate elements the way a user would: by visible text (get_by_text), accessible role (get_by_role), or label (get_by_label).
Scope to page regions using semantic landmarks (e.g. a section identified by its heading).
Avoid DOM-structure selectors like child combinators (> div), .first on structural elements, or tag-based traversal.