Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions tests/test_merge_chunks_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_merge_chunks_skips_chunk_with_path_escape_id(tmp_path, monkeypatch, cap

_run_merge(monkeypatch, ["graphify", "merge-chunks", str(good), str(bad), "--out", str(out)])

merged = json.loads(out.read_text())
merged = json.loads(out.read_text(encoding="utf-8"))
assert {n["id"] for n in merged["nodes"]} == {"pkg.mod.good"}
captured = capsys.readouterr()
assert "skipping invalid chunk" in captured.err
Expand All @@ -48,7 +48,7 @@ def test_merge_chunks_fails_closed_when_every_chunk_is_invalid(tmp_path, monkeyp
_run_merge(monkeypatch, ["graphify", "merge-chunks", str(bad), "--out", str(out)])

assert exc.value.code == 1
assert json.loads(out.read_text()) == {"previous": "semantic result"}
assert json.loads(out.read_text(encoding="utf-8")) == {"previous": "semantic result"}
err = capsys.readouterr().err
assert "skipping invalid chunk" in err
assert "no valid chunks to merge" in err
Expand All @@ -62,7 +62,7 @@ def test_merge_chunks_accepts_valid_empty_chunk(tmp_path, monkeypatch):

_run_merge(monkeypatch, ["graphify", "merge-chunks", str(empty), "--out", str(out)])

merged = json.loads(out.read_text())
merged = json.loads(out.read_text(encoding="utf-8"))
assert merged["nodes"] == []
assert merged["edges"] == []

Expand All @@ -87,7 +87,7 @@ def test_merge_chunks_fails_closed_on_unmatched_glob(tmp_path, monkeypatch, caps
_run_merge(monkeypatch, ["graphify", "merge-chunks", unmatched, "--out", str(out)])

assert exc.value.code == 1
assert json.loads(out.read_text()) == {"previous": True}
assert json.loads(out.read_text(encoding="utf-8")) == {"previous": True}
err = capsys.readouterr().err
assert "skipping invalid chunk" in err
assert "no valid chunks to merge" in err
Expand All @@ -102,7 +102,7 @@ def test_merge_chunks_accepts_synonym_file_type(tmp_path, monkeypatch):
"edges": [], "hyperedges": []})
out = tmp_path / "merged.json"
_run_merge(monkeypatch, ["graphify", "merge-chunks", str(c), "--out", str(out)])
merged = json.loads(out.read_text())
merged = json.loads(out.read_text(encoding="utf-8"))
assert {n["id"] for n in merged["nodes"]} == {"pkg.readme", "pkg.tool"}


Expand All @@ -114,7 +114,7 @@ def test_merge_chunks_accepts_unicode_id(tmp_path, monkeypatch):
"edges": [], "hyperedges": []})
out = tmp_path / "merged.json"
_run_merge(monkeypatch, ["graphify", "merge-chunks", str(c), "--out", str(out)])
merged = json.loads(out.read_text())
merged = json.loads(out.read_text(encoding="utf-8"))
assert {n["id"] for n in merged["nodes"]} == {"mod_处理数据"}


Expand Down Expand Up @@ -144,7 +144,7 @@ def test_merge_chunks_merges_valid_chunks(tmp_path, monkeypatch):

_run_merge(monkeypatch, ["graphify", "merge-chunks", str(c0), str(c1), "--out", str(out)])

merged = json.loads(out.read_text())
merged = json.loads(out.read_text(encoding="utf-8"))
assert {n["id"] for n in merged["nodes"]} == {"a", "b"}
assert merged["input_tokens"] == 17
assert merged["output_tokens"] == 8
4 changes: 2 additions & 2 deletions tests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ def run_pipeline(tmp_path: Path) -> dict:
json_path = tmp_path / "graph.json"
to_json(G, communities, str(json_path))
assert json_path.exists()
data = json.loads(json_path.read_text())
data = json.loads(json_path.read_text(encoding="utf-8"))
assert "nodes" in data and "links" in data
assert all("community" in n for n in data["nodes"])

# Step 8: export - HTML
html_path = tmp_path / "graph.html"
to_html(G, communities, str(html_path), community_labels=labels)
assert html_path.exists()
html = html_path.read_text()
html = html_path.read_text(encoding="utf-8")
assert "vis-network" in html
assert "RAW_NODES" in html

Expand Down