Testing
Clawbolt uses pytest with FastAPI’s TestClient. Tests run against in-memory SQLite, so no database setup is needed.
Run all tests
Section titled “Run all tests”uv sync --all-extrasDATABASE_URL=sqlite:// uv run pytest -vLint and format
Section titled “Lint and format”uv run ruff check backend/ tests/uv run ruff format --check backend/ tests/Type checking
Section titled “Type checking”uv run ty check --python .venv backend/ tests/Test infrastructure
Section titled “Test infrastructure”Database
Section titled “Database”Tests use in-memory SQLite with StaticPool. The get_db dependency is overridden via FastAPI dependency injection to use the test database.
Mock factories
Section titled “Mock factories”All external services are mocked in tests. Mock factories live in tests/mocks/:
| Mock | What it replaces |
|---|---|
| Telegram | Telegram Bot API calls |
| LLM | any-llm acompletion calls |
| faster-whisper | Audio transcription |
| Dropbox/Drive | Cloud storage operations |
| Storage | MockStorageBackend for file operations |
Auth override
Section titled “Auth override”The get_current_user dependency is overridden in tests to return a fixed test user, bypassing authentication.
Definition of done
Section titled “Definition of done”Every change should pass all checks:
uv run pytest -v # tests passuv run ruff check backend/ tests/ # lint passesuv run ruff format --check backend/ tests/ # format passesuv run ty check --python .venv backend/ tests/ # type checking passesBug fixes must include regression tests.