Skip to content

Testing

PantheraNestah edited this page Nov 5, 2026 · 1 revision

Testing

pip install pytest          # not listed in requirements.txt
python -m pytest tests -q   # from the repository root

Expected: 47 passed (plus a harmless third-party deprecation warning). The suite needs no network access and no API keys, and it never touches your real database: tests/conftest.py points DATABASE_URL at a temporary file before the app is imported.

What is covered

File Tests Covers
tests/test_llm.py 33 Tier setting parsing and defaults; Anthropic request shape (no temperature, effort, cache breakpoint on the system prompt, usage logging); Sonnet refusal fallback and its retry; refusal and empty-output errors; missing-key error; DeepSeek thinking on and off, low and high effort, blank-JSON retry, usage logging; mixed providers; JSON parsing; the generator's tier choices and fallbacks. Uses fake clients
tests/test_concurrency.py 5 SQLite uses WAL and a 30 s timeout; verification, LLM calls and retrieval do not block the event loop; verification runs one at a time
tests/test_build_vector_store.py 4 The vector-store build script: builds the collection with the expected metadata, a re-run embeds nothing and does not fail, only new or edited chunks are re-embedded, --reset drops stale chunks. Uses a fake embedder
tests/test_warmup.py 5 PRELOAD_MODELS switch; both models are preloaded; a preload failure is logged, not raised; startup runs or skips the preload

The concurrency tests measure the longest pause of a heartbeat task while slow stand-ins run. They fail against the pre-fix code, which is how they were checked.

What is not covered

  • Retrieval quality and the embedding, re-ranking and NLI models (see Evaluation).
  • The HTTP endpoints end to end. A TestClient test of /query with a stubbed pipeline would have caught citations_present being dropped from the response (Known Issues and Limitations).
  • Prompt quality, database migrations and real provider calls.

Real provider calls are checked by hand: start the app and call each endpoint (Getting Started). Watch the log for the [LLM] ... usage: lines.

Adding tests

Follow tests/test_llm.py: inject a fake client into llm._clients and set LLM_MODEL_* with monkeypatch. Keep tests offline.

Clone this wiki locally