From 02a61cdf0d54ea5c05bb0cf6c46f886e8778edc7 Mon Sep 17 00:00:00 2001 From: Lars Date: Tue, 7 Oct 2025 13:24:11 +0200 Subject: [PATCH] =?UTF-8?q?tests/test=5Fgraph=5Funit.py=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_graph_unit.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/test_graph_unit.py diff --git a/tests/test_graph_unit.py b/tests/test_graph_unit.py new file mode 100644 index 0000000..2e3b14c --- /dev/null +++ b/tests/test_graph_unit.py @@ -0,0 +1,20 @@ +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