Skip to content

Hypergraph is more powerful. Transform unstructured text into structured knowledge with LLMs. Graphs, hypergraphs, and spatio-temporal extractions — with one command.

test: info reports item counts for list/set KAs

dex0shubham40d40f5a1fef
diff --git a/tests/cli/test_info.py b/tests/cli/test_info.py
index fb9545c..693d70f 100644
--- a/tests/cli/test_info.py
+++ b/tests/cli/test_info.py
@@ -63,3 +63,24 @@ class TestInfoSourcesCli:
assert result.exit_code == 0, result.output
assert "No source ledger" in result.output
+
+
+class TestInfoItemCounts:
+ def test_list_ka_counts_items_as_nodes(self, tmp_path):
+ """List/Set KAs store ``items``; ``Nodes`` is documented as entities/items."""
+ ka = tmp_path / "ka"
+ ka.mkdir()
+ (ka / "data.json").write_text(
+ json.dumps({"items": [{"name": "a"}, {"name": "b"}, {"name": "c"}]}),
+ encoding="utf-8",
+ )
+ (ka / "metadata.json").write_text(
+ json.dumps({"template": "general/base_list", "lang": "en"}),
+ encoding="utf-8",
+ )
+ result = runner.invoke(app, ["info", str(ka)])
+ assert result.exit_code == 0, result.output
+ nodes_line = next(
+ line for line in result.output.splitlines() if line.strip().startswith("Nodes")
+ )
+ assert nodes_line.split()[-1] == "3"
diff --git a/tests/test_mcp_server.py b/tests/test_mcp_server.py
index bab5477..ddd954f 100644
--- a/tests/test_mcp_server.py
+++ b/tests/test_mcp_server.py
@@ -92,6 +92,23 @@ def test_info_reports_counts(tmp_path):
assert "sources" not in out
+def test_info_counts_items_for_list_and_set_kas(tmp_path):
+ """List/Set KAs store ``items`` rather than ``nodes``/``edges``."""
+ ka = tmp_path / "ka"
+ ka.mkdir()
+ (ka / "data.json").write_text(
+ json.dumps({"items": [{"name": "a"}, {"name": "b"}, {"name": "c"}]}),
+ encoding="utf-8",
+ )
+ (ka / "metadata.json").write_text(
+ json.dumps({"template": "general/base_list", "lang": "en"}), encoding="utf-8"
+ )
+
+ out = json.loads(mcp_server.info(str(ka)))
+ assert out["nodes"] == 3
+ assert out["edges"] == 0
+
+
def test_info_includes_chunks_and_optional_sources(tmp_path):
ka = tmp_path / "doc_ka"
ka.mkdir()