From 5ed62e712b473a6d33a9dca799b67b3ca8cd32d2 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Thu, 18 Jun 2026 20:17:45 +0200 Subject: [PATCH] test: stub build_chunk_embeddings in parity tests --- .../test_kb_persistence_filesystem_parity.py | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/surfsense_backend/tests/unit/middleware/test_kb_persistence_filesystem_parity.py b/surfsense_backend/tests/unit/middleware/test_kb_persistence_filesystem_parity.py index e78db1e76..3968eb090 100644 --- a/surfsense_backend/tests/unit/middleware/test_kb_persistence_filesystem_parity.py +++ b/surfsense_backend/tests/unit/middleware/test_kb_persistence_filesystem_parity.py @@ -69,13 +69,25 @@ class _FakeSession: @pytest.fixture(autouse=True) def _stub_embeddings_and_chunks(monkeypatch: pytest.MonkeyPatch) -> None: - """Avoid loading the embedding model in unit tests.""" + """Avoid loading the embedding model in unit tests. + + Mirrors the legacy stub: one chunk spanning the whole content, with a + zero summary/chunk vector, routed through the shared span builder. + """ + from app.indexing_pipeline.document_chunker import ChunkSlice + + async def _fake_build_chunk_embeddings(content: str, *, use_code_chunker: bool): + summary = np.zeros(8, dtype=np.float32) + pairs = ( + [(ChunkSlice(content, 0, len(content)), np.zeros(8, dtype=np.float32))] + if content + else [] + ) + return summary, pairs + monkeypatch.setattr( - kb_persistence, - "embed_texts", - lambda texts: [np.zeros(8, dtype=np.float32) for _ in texts], + kb_persistence, "build_chunk_embeddings", _fake_build_chunk_embeddings ) - monkeypatch.setattr(kb_persistence, "chunk_text", lambda content: [content]) @pytest.mark.asyncio