Mock embedding model for test coverage of semantic search path #2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
src/tinyweb/embeddings.py has zero test coverage. The entire semantic search path — chunking, ONNX inference, HNSW indexing, hybrid search with RRF fusion — is untested because tests cannot download the model.
Affected code paths:
Current test coverage only hits the BM25 fallback path. Tests that enable semantic_search setting still never call into ONNX because the model isn't downloaded in CI.
Fix: Abstract the model behind a protocol/base class. Swap a FakeEmbeddingModel in tests that returns deterministic random vectors of the correct dimension. Build a real HNSW index from fake vectors and verify:
The fake model should be zero-dependency (numpy only, no ONNX/tokenizers). Set via env var or monkeypatch.
Synced from Codeberg issue #2 — opened by @fluffblankie on 2026-07-04.