A node with n_callers callers, spread across `files` (default: 3 files, so counts land above 1 per file and truncation kicks in — the CLI shows the top 20 by neighbor degree, cutting the rest).
(tmp_path, n_callers=30, files=None)
| 179 | # --- #2009: high-degree nodes must not silently hide the cut connections ------ |
| 180 | |
| 181 | def _write_high_degree_graph(tmp_path, n_callers=30, files=None): |
| 182 | """A node with n_callers callers, spread across `files` (default: 3 |
| 183 | files, so counts land above 1 per file and truncation kicks in — the |
| 184 | CLI shows the top 20 by neighbor degree, cutting the rest).""" |
| 185 | files = files or ["app/handlers/email.py", "app/jobs/retry.py", "lib/workers/queue.py"] |
| 186 | nodes = [{"id": "hub", "label": "hub()", |
| 187 | "source_file": "lib/hub.py", "community": 0}] |
| 188 | links = [] |
| 189 | for i in range(n_callers): |
| 190 | fpath = files[i % len(files)] |
| 191 | nid = f"caller_{i}" |
| 192 | nodes.append({"id": nid, "label": f"caller_{i}()", |
| 193 | "source_file": fpath, "community": 0}) |
| 194 | links.append({"source": nid, "target": "hub", "relation": "calls", |
| 195 | "confidence": "EXTRACTED", "source_file": fpath, |
| 196 | "source_location": f"L{10 + i}"}) |
| 197 | graph_data = {"directed": False, "multigraph": False, "graph": {}, |
| 198 | "nodes": nodes, "links": links} |
| 199 | p = tmp_path / "graph.json" |
| 200 | p.write_text(json.dumps(graph_data)) |
| 201 | return p |
| 202 | |
| 203 | |
| 204 | def test_explain_truncation_notice_present_for_high_degree_node(monkeypatch, tmp_path, capsys): |
no outgoing calls
no test coverage detected