Skip to content

[Feature] Add pytest scaffolding and dev dependencies #8

Description

@sjohnston1972

Part of the "Add an automated backend test suite" parent issue. Do this first — the other test sub-issues depend on it.

Background

The backend has no test tooling at all. Before writing tests we need a runner and a place to put them.

Problem / Goal

Add pytest scaffolding so cd backend && pytest works offline and deterministically.

Where to look

  • backend/requirements.txt — where deps live today (no test deps).
  • backend/app/ — package layout; tests should import app.*.
  • backend/app/llm/router.py and backend/app/rag/chroma_client.py — async code, so pytest-asyncio is needed.
  • backend/app/db/session.pyengine is module-level from settings.data_dir; tests that touch the DB should use an in-memory engine, so note this for a fixture.

Suggested approach

  1. Add a dev-dependency file (e.g. backend/requirements-dev.txt) pinning pytest and pytest-asyncio, and reference it from the README.
  2. Create backend/tests/__init__.py and backend/tests/conftest.py.
  3. In conftest.py, configure asyncio mode (e.g. asyncio_mode = auto via pyproject.toml/pytest.ini, or the fixtures) and add a reusable fixture that yields an in-memory SQLModel engine + session for DB tests.
  4. Add one trivial smoke test (e.g. import app.main succeeds) to prove the harness runs.
  5. Document cd backend && pip install -r requirements-dev.txt && pytest in the README.

Acceptance criteria

  • cd backend && pytest discovers and runs tests, green, with no network and no .env.
  • An in-memory DB fixture is available for later DB tests.
  • README has a "Running tests" note.

Testing

From a clean checkout without API keys: pip install -r backend/requirements-dev.txt && cd backend && pytest -q passes.

Out of scope

  • Actual coverage of jsonblock/chroma/extractor (separate sub-issues).
  • CI configuration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions