mindnet/tests/test_graph_unit.py

21 lines
828 B
Python
Raw Permalink Normal View History

2025-10-07 13:24:11 +02:00
from fastapi.testclient import TestClient
from app.main import create_app
2025-12-28 11:04:40 +01:00
import app.core.graph.graph_subgraph as ga
2025-10-07 13:24:11 +02:00
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