mindnet/tests/test_graph_unit.py
Lars 02a61cdf0d
All checks were successful
Deploy mindnet to llm-node / deploy (push) Successful in 3s
tests/test_graph_unit.py hinzugefügt
2025-10-07 13:24:11 +02:00

21 lines
821 B
Python

from fastapi.testclient import TestClient
from app.main import create_app
import app.core.graph_adapter as ga
def _fake_get_edges_for_sources(client, prefix, source_ids, edge_types=None, limit=2048):
note_id = source_ids[0]
return [
{"source_id":note_id,"target_id":f"{note_id}#c1","kind":"references","weight":0.2},
{"source_id":note_id,"target_id":f"{note_id}#c2","kind":"belongs_to","weight":0.1},
]
def test_graph_neighbors(monkeypatch):
monkeypatch.setattr(ga, "get_edges_for_sources", _fake_get_edges_for_sources, raising=False)
app = create_app()
with TestClient(app) as c:
r = c.get("/graph/TEST-NOTE?depth=1")
assert r.status_code == 200
g = r.json()
assert g["center_note_id"] == "TEST-NOTE"
assert g["stats"]["edge_count"] == 2