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.py — engine 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
- Add a dev-dependency file (e.g.
backend/requirements-dev.txt) pinning pytest and pytest-asyncio, and reference it from the README.
- Create
backend/tests/__init__.py and backend/tests/conftest.py.
- 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.
- Add one trivial smoke test (e.g.
import app.main succeeds) to prove the harness runs.
- 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.
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 && pytestworks offline and deterministically.Where to look
backend/requirements.txt— where deps live today (no test deps).backend/app/— package layout; tests should importapp.*.backend/app/llm/router.pyandbackend/app/rag/chroma_client.py— async code, sopytest-asynciois needed.backend/app/db/session.py—engineis module-level fromsettings.data_dir; tests that touch the DB should use an in-memory engine, so note this for a fixture.Suggested approach
backend/requirements-dev.txt) pinningpytestandpytest-asyncio, and reference it from the README.backend/tests/__init__.pyandbackend/tests/conftest.py.conftest.py, configure asyncio mode (e.g.asyncio_mode = autoviapyproject.toml/pytest.ini, or the fixtures) and add a reusable fixture that yields an in-memory SQLModel engine + session for DB tests.import app.mainsucceeds) to prove the harness runs.cd backend && pip install -r requirements-dev.txt && pytestin the README.Acceptance criteria
cd backend && pytestdiscovers and runs tests, green, with no network and no.env.Testing
From a clean checkout without API keys:
pip install -r backend/requirements-dev.txt && cd backend && pytest -qpasses.Out of scope