test: cover missing-id and non-list roots; drop unreachable empty-nodes guard

This commit is contained in:
2026-07-15 22:11:36 -04:00
parent e6adaad8b3
commit 05294412df
2 changed files with 18 additions and 2 deletions
+18
View File
@@ -50,6 +50,24 @@ def test_empty_roots_raises_value_error(tmp_path):
load_tree_nodes(tmp_path, "vX")
def test_node_missing_id_raises_value_error(tmp_path):
vdir = tmp_path / "videos" / "vX"
vdir.mkdir(parents=True)
(vdir / "tree.json").write_text(
json.dumps({"roots": [{"card": {}, "time_range": [0, 1]}]}), encoding="utf-8"
)
with pytest.raises(ValueError):
load_tree_nodes(tmp_path, "vX")
def test_roots_not_list_raises_value_error(tmp_path):
vdir = tmp_path / "videos" / "vX"
vdir.mkdir(parents=True)
(vdir / "tree.json").write_text(json.dumps({"roots": "not-a-list"}), encoding="utf-8")
with pytest.raises(ValueError):
load_tree_nodes(tmp_path, "vX")
def test_load_for_videos_dedups():
data = load_tree_data_for_videos(_STORE, [_VID, _VID])
assert set(data.keys()) == {_VID}