Skip to content

Testing

Clawbolt uses pytest with FastAPI’s TestClient. Tests run against in-memory SQLite, so no database setup is needed.

Terminal window
uv sync --all-extras
DATABASE_URL=sqlite:// uv run pytest -v
Terminal window
uv run ruff check backend/ tests/
uv run ruff format --check backend/ tests/
Terminal window
uv run ty check --python .venv backend/ tests/

Tests use in-memory SQLite with StaticPool. The get_db dependency is overridden via FastAPI dependency injection to use the test database.

All external services are mocked in tests. Mock factories live in tests/mocks/:

MockWhat it replaces
TelegramTelegram Bot API calls
LLMany-llm acompletion calls
faster-whisperAudio transcription
Dropbox/DriveCloud storage operations
StorageMockStorageBackend for file operations

The get_current_user dependency is overridden in tests to return a fixed test user, bypassing authentication.

Every change should pass all checks:

Terminal window
uv run pytest -v # tests pass
uv run ruff check backend/ tests/ # lint passes
uv run ruff format --check backend/ tests/ # format passes
uv run ty check --python .venv backend/ tests/ # type checking passes

Bug fixes must include regression tests.