from fastapi.testclient import TestClient from app.main import create_app import app.core.graph.graph_subgraph 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