mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-24 21:38:09 +02:00
test: stub build_chunk_embeddings in parity tests
This commit is contained in:
parent
f2fe2e576e
commit
5ed62e712b
1 changed files with 17 additions and 5 deletions
|
|
@ -69,13 +69,25 @@ class _FakeSession:
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def _stub_embeddings_and_chunks(monkeypatch: pytest.MonkeyPatch) -> None:
|
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(
|
monkeypatch.setattr(
|
||||||
kb_persistence,
|
kb_persistence, "build_chunk_embeddings", _fake_build_chunk_embeddings
|
||||||
"embed_texts",
|
|
||||||
lambda texts: [np.zeros(8, dtype=np.float32) for _ in texts],
|
|
||||||
)
|
)
|
||||||
monkeypatch.setattr(kb_persistence, "chunk_text", lambda content: [content])
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue