feat(v2): complete v2 reimplementation

This commit is contained in:
2026-07-31 13:33:39 +02:00
parent 396219e776
commit bd107d6a30
137 changed files with 20737 additions and 155 deletions
+34
View File
@@ -0,0 +1,34 @@
from __future__ import annotations
import importlib
import pytest
snapshot = importlib.import_module("backup_tool.snapshot")
def entry(path: str, kind: str) -> dict[str, object]:
return {"path": path, "type": kind}
def test_restore_selection_includes_selected_descendants_and_ancestors() -> None:
entries = [
entry("top", "directory"),
entry("top/keep", "directory"),
entry("top/keep/file.txt", "file"),
entry("top/drop.txt", "file"),
]
selected = snapshot._select_restore_entries(entries, ["top/keep"])
assert [item["path"] for item in selected] == [
"top",
"top/keep",
"top/keep/file.txt",
]
@pytest.mark.parametrize("selection", [["../escape"], ["/absolute"], ["a\\b"], [""]])
def test_restore_selection_rejects_unsafe_paths(selection: list[str]) -> None:
with pytest.raises(snapshot.SnapshotError):
snapshot._select_restore_entries([entry("safe", "file")], selection)