add tests for canvas vault-relative paths and hook .exe skip

This commit is contained in:
Safi
2026-04-22 23:04:40 +01:00
parent 8981f7c8ef
commit e4bdcc2487
2 changed files with 22 additions and 1 deletions
+16 -1
View File
@@ -3,7 +3,7 @@ import tempfile
from pathlib import Path
from graphify.build import build_from_json
from graphify.cluster import cluster
from graphify.export import to_json, to_cypher, to_graphml, to_html
from graphify.export import to_json, to_cypher, to_graphml, to_html, to_canvas
FIXTURES = Path(__file__).parent / "fixtures"
@@ -125,3 +125,18 @@ def test_to_html_contains_nodes_and_edges():
content = out.read_text()
assert "RAW_NODES" in content
assert "RAW_EDGES" in content
def test_to_canvas_file_paths_relative_to_vault():
"""Node file paths in canvas must be vault-root-relative (just fname.md), not hardcoded."""
G = make_graph()
communities = cluster(G)
with tempfile.TemporaryDirectory() as tmp:
out = Path(tmp) / "graph.canvas"
to_canvas(G, communities, str(out))
data = json.loads(out.read_text())
file_nodes = [n for n in data["nodes"] if n.get("type") == "file"]
assert file_nodes, "canvas should contain file nodes"
for node in file_nodes:
assert "/" not in node["file"], f"file path should not contain '/': {node['file']}"
assert node["file"].endswith(".md")
+6
View File
@@ -117,3 +117,9 @@ def test_status_shows_both_hooks(tmp_path):
assert "post-commit" in result
assert "post-checkout" in result
assert result.count("installed") >= 2
def test_hook_skips_head_on_exe():
"""Hook script must skip shebang extraction for .exe binaries (Windows)."""
from graphify.hooks import _PYTHON_DETECT
assert "*.exe) _SHEBANG=" in _PYTHON_DETECT or '*.exe)' in _PYTHON_DETECT