refactor review-plan safety and validation
This commit is contained in:
@@ -101,3 +101,37 @@ def test_executor_blocks_unsafe_destination_even_with_manual_plan(tmp_path):
|
||||
assert not results[0].success
|
||||
assert "outside library root" in (results[0].error_message or "")
|
||||
assert summary["failed"] == 1
|
||||
|
||||
|
||||
def test_executor_blocks_unsafe_source_even_with_manual_plan(tmp_path):
|
||||
library_root = tmp_path / "library"
|
||||
library_root.mkdir(parents=True, exist_ok=True)
|
||||
outside_root = tmp_path / "outside"
|
||||
outside_root.mkdir(parents=True, exist_ok=True)
|
||||
source = outside_root / "Sample.mkv"
|
||||
source.write_text("sample")
|
||||
|
||||
destination = library_root / "movie" / "Sample.mkv"
|
||||
operation = FileOperation(
|
||||
operation_type="move",
|
||||
source_path=source,
|
||||
destination_path=destination,
|
||||
reason="unsafe test",
|
||||
has_conflict=False,
|
||||
conflict_reason=None,
|
||||
)
|
||||
plan = ExecutionPlan(
|
||||
plan_id=str(uuid4()),
|
||||
created_at=datetime.now(timezone.utc),
|
||||
operations=[operation],
|
||||
summary={"total": 1, "move": 1, "rename": 0, "quarantine": 0, "no-op": 0},
|
||||
)
|
||||
|
||||
engine = ExecutionEngine(config=Config(library_root=library_root))
|
||||
results, summary, _ = engine.execute_plan(plan, mode="execute", confirmed=True)
|
||||
|
||||
assert not results[0].success
|
||||
assert "Unsafe source outside library root" in (results[0].error_message or "")
|
||||
assert summary["failed"] == 1
|
||||
assert source.exists()
|
||||
assert not destination.exists()
|
||||
|
||||
Reference in New Issue
Block a user