tests/test_query_text_embed_unit.py hinzugefügt
All checks were successful
Deploy mindnet to llm-node / deploy (push) Successful in 3s
All checks were successful
Deploy mindnet to llm-node / deploy (push) Successful in 3s
This commit is contained in:
parent
3111a26229
commit
c8c4c7fa00
39
tests/test_query_text_embed_unit.py
Normal file
39
tests/test_query_text_embed_unit.py
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
from fastapi.testclient import TestClient
|
||||||
|
from app.main import create_app
|
||||||
|
import app.services.embeddings_client as ec
|
||||||
|
import app.core.qdrant_points as qp
|
||||||
|
import app.core.graph_adapter as ga
|
||||||
|
|
||||||
|
def _fake_embed_text(text: str):
|
||||||
|
# Liefert stabilen 384-d Vektor ohne echtes Modell
|
||||||
|
return [0.01] * 384
|
||||||
|
|
||||||
|
def _fake_search_chunks_by_vector(client, prefix, vector, top=10, filters=None):
|
||||||
|
# einfache Hitliste
|
||||||
|
return [
|
||||||
|
("chunk:1", 0.9, {"note_id":"note:1","path":"a.md","section_title":"S1"}),
|
||||||
|
("chunk:2", 0.7, {"note_id":"note:2","path":"b.md","section_title":"S2"}),
|
||||||
|
("chunk:3", 0.5, {"note_id":"note:3","path":"c.md","section_title":"S3"}),
|
||||||
|
]
|
||||||
|
|
||||||
|
def _fake_get_edges_for_sources(client, prefix, source_ids, edge_types=None, limit=2048):
|
||||||
|
out=[]
|
||||||
|
for sid in source_ids:
|
||||||
|
out.append({"source_id":sid,"target_id":f"{sid}-x","kind":"references","weight":0.2})
|
||||||
|
return out
|
||||||
|
|
||||||
|
def test_query_with_text(monkeypatch):
|
||||||
|
# Patch Embedding + Qdrant-Aufrufe
|
||||||
|
monkeypatch.setattr(ec, "embed_text", _fake_embed_text)
|
||||||
|
monkeypatch.setattr(qp, "search_chunks_by_vector", _fake_search_chunks_by_vector)
|
||||||
|
monkeypatch.setattr(ga, "get_edges_for_sources", _fake_get_edges_for_sources, raising=False)
|
||||||
|
|
||||||
|
app = create_app()
|
||||||
|
with TestClient(app) as c:
|
||||||
|
payload = {"mode":"hybrid","query":"karate trainingsplan", "top_k":2,
|
||||||
|
"expand":{"depth":1,"edge_types":["references"]}}
|
||||||
|
r = c.post("/query", json=payload)
|
||||||
|
assert r.status_code == 200, r.text
|
||||||
|
body = r.json()
|
||||||
|
assert body["used_mode"] == "hybrid"
|
||||||
|
assert len(body["results"]) == 2
|
||||||
Loading…
Reference in New Issue
Block a user