import pytest DESIGN_DIR = "/workspace/arch-design-agent-skill-dashboard/design" @pytest.fixture def project_id(client): r = client.post("/api/projects", json={"name": "test", "design_dir": DESIGN_DIR}) return r.json()["id"] def test_get_graph(client, project_id): r = client.get(f"/api/projects/{project_id}/graph") assert r.status_code == 200 data = r.json() assert "nodes" in data assert "edges" in data assert "groups" in data assert len(data["nodes"]) > 0 assert len(data["groups"]) == 5 def test_get_graph_auto_scans(client, project_id): """Graph endpoint should auto-scan if no cached scan exists.""" r = client.get(f"/api/projects/{project_id}/graph") assert r.status_code == 200 def test_get_neighbors(client, project_id): # First trigger a scan via graph endpoint client.get(f"/api/projects/{project_id}/graph") r = client.get(f"/api/projects/{project_id}/graph/nodes/CAP-PROJ-REG/neighbors") assert r.status_code == 200 data = r.json() assert "nodes" in data assert len(data["nodes"]) > 0 def test_get_neighbors_unknown_node(client, project_id): client.get(f"/api/projects/{project_id}/graph") r = client.get(f"/api/projects/{project_id}/graph/nodes/NONEXISTENT/neighbors") assert r.status_code == 200 data = r.json() assert len(data["nodes"]) == 0