diff --git a/backend/app/modules/graph/interfaces/http/router.py b/backend/app/modules/graph/interfaces/http/router.py index 400e8bb..e6dd1de 100644 --- a/backend/app/modules/graph/interfaces/http/router.py +++ b/backend/app/modules/graph/interfaces/http/router.py @@ -40,17 +40,17 @@ def _get_or_trigger_scan(project_id: str): @router.get("") def get_graph(project_id: str): """Build and return the full panorama graph for a project.""" - _project_service.get_project(project_id) # Ensure project exists (raises 404) + project = _project_service.get_project(project_id) # Ensure project exists (raises 404) scan_result = _get_or_trigger_scan(project_id) - view = _graph_service.build_panorama(scan_result) + view = _graph_service.build_panorama(scan_result, design_dir=project.design_dir) return asdict(view) @router.get("/nodes/{node_id}/neighbors") def get_neighbors(project_id: str, node_id: str): """Return the subgraph of neighbors for a given node.""" - _project_service.get_project(project_id) # Ensure project exists (raises 404) + project = _project_service.get_project(project_id) # Ensure project exists (raises 404) scan_result = _get_or_trigger_scan(project_id) - view = _graph_service.build_panorama(scan_result) + view = _graph_service.build_panorama(scan_result, design_dir=project.design_dir) neighbors = _graph_service.get_neighbors(view, node_id) return asdict(neighbors) diff --git a/backend/tests/test_graph_service.py b/backend/tests/test_graph_service.py index f84c5ac..647eb2b 100644 --- a/backend/tests/test_graph_service.py +++ b/backend/tests/test_graph_service.py @@ -27,8 +27,8 @@ def graph_service(): return GraphService() -def test_panorama_has_groups(graph_service, scan_result): - view = graph_service.build_panorama(scan_result) +def test_panorama_has_groups(graph_service, scan_result, design_dir): + view = graph_service.build_panorama(scan_result, design_dir=design_dir) group_ids = {g.id for g in view.groups} assert "business" in group_ids assert "application" in group_ids @@ -37,42 +37,42 @@ def test_panorama_has_groups(graph_service, scan_result): assert "cross-layer" in group_ids -def test_panorama_has_capability_nodes(graph_service, scan_result): - view = graph_service.build_panorama(scan_result) +def test_panorama_has_capability_nodes(graph_service, scan_result, design_dir): + view = graph_service.build_panorama(scan_result, design_dir=design_dir) cap_nodes = [n for n in view.nodes if n.type == "capability"] assert len(cap_nodes) > 0 assert all(n.group_id == "business" for n in cap_nodes) -def test_panorama_has_module_nodes(graph_service, scan_result): - view = graph_service.build_panorama(scan_result) +def test_panorama_has_module_nodes(graph_service, scan_result, design_dir): + view = graph_service.build_panorama(scan_result, design_dir=design_dir) mod_nodes = [n for n in view.nodes if n.type == "module"] assert len(mod_nodes) > 0 assert all(n.group_id == "application" for n in mod_nodes) -def test_panorama_has_entity_nodes(graph_service, scan_result): - view = graph_service.build_panorama(scan_result) +def test_panorama_has_entity_nodes(graph_service, scan_result, design_dir): + view = graph_service.build_panorama(scan_result, design_dir=design_dir) ent_nodes = [n for n in view.nodes if n.type == "entity"] assert len(ent_nodes) > 0 assert all(n.group_id == "data" for n in ent_nodes) -def test_panorama_has_edges(graph_service, scan_result): - view = graph_service.build_panorama(scan_result) +def test_panorama_has_edges(graph_service, scan_result, design_dir): + view = graph_service.build_panorama(scan_result, design_dir=design_dir) assert len(view.edges) > 0 relations = {e.relation for e in view.edges} assert "traces_to" in relations -def test_panorama_depends_on_edges(graph_service, scan_result): - view = graph_service.build_panorama(scan_result) +def test_panorama_depends_on_edges(graph_service, scan_result, design_dir): + view = graph_service.build_panorama(scan_result, design_dir=design_dir) dep_edges = [e for e in view.edges if e.relation == "depends_on"] assert len(dep_edges) > 0 -def test_neighbors_returns_subgraph(graph_service, scan_result): - view = graph_service.build_panorama(scan_result) +def test_neighbors_returns_subgraph(graph_service, scan_result, design_dir): + view = graph_service.build_panorama(scan_result, design_dir=design_dir) # Use a known capability node neighbors = graph_service.get_neighbors(view, "CAP-PROJ-REG") assert len(neighbors.nodes) > 0 @@ -80,15 +80,15 @@ def test_neighbors_returns_subgraph(graph_service, scan_result): assert len(neighbors.edges) > 0 -def test_neighbors_unknown_node(graph_service, scan_result): - view = graph_service.build_panorama(scan_result) +def test_neighbors_unknown_node(graph_service, scan_result, design_dir): + view = graph_service.build_panorama(scan_result, design_dir=design_dir) neighbors = graph_service.get_neighbors(view, "NONEXISTENT") assert len(neighbors.nodes) == 0 assert len(neighbors.edges) == 0 -def test_graph_node_has_parent_field(graph_service, scan_result): - view = graph_service.build_panorama(scan_result) +def test_graph_node_has_parent_field(graph_service, scan_result, design_dir): + view = graph_service.build_panorama(scan_result, design_dir=design_dir) for node in view.nodes: assert hasattr(node, 'parent')