refactor review-plan safety and validation
This commit is contained in:
@@ -946,3 +946,59 @@ class TestRollbackExecution:
|
||||
assert original_path.exists()
|
||||
assert original_path.read_text() == "movie content"
|
||||
assert not quarantine_path.exists()
|
||||
|
||||
|
||||
def test_execute_plan_continues_after_unexpected_operation_exception(temp_test_dir):
|
||||
logger = logging.getLogger("test_executor")
|
||||
logger.setLevel(logging.DEBUG)
|
||||
engine = ExecutionEngine(logger=logger)
|
||||
|
||||
source_ok = temp_test_dir["test_file1"]
|
||||
destination_ok = temp_test_dir["dest_dir"] / "moved1.mp4"
|
||||
source_broken = temp_test_dir["test_file2"]
|
||||
destination_broken = temp_test_dir["dest_dir"] / "broken.mkv"
|
||||
|
||||
operations = [
|
||||
FileOperation(
|
||||
operation_type="move",
|
||||
source_path=source_broken,
|
||||
destination_path=destination_broken,
|
||||
reason="broken operation",
|
||||
has_conflict=False,
|
||||
conflict_reason=None,
|
||||
),
|
||||
FileOperation(
|
||||
operation_type="move",
|
||||
source_path=source_ok,
|
||||
destination_path=destination_ok,
|
||||
reason="healthy operation",
|
||||
has_conflict=False,
|
||||
conflict_reason=None,
|
||||
),
|
||||
]
|
||||
plan = ExecutionPlan(
|
||||
plan_id=str(uuid4()),
|
||||
created_at=datetime.now(timezone.utc),
|
||||
operations=operations,
|
||||
summary={"move": 2},
|
||||
)
|
||||
|
||||
original_execute_operation = engine.execute_operation
|
||||
|
||||
def flaky_execute_operation(operation, mode):
|
||||
if operation.source_path == source_broken:
|
||||
raise RuntimeError("boom")
|
||||
return original_execute_operation(operation, mode)
|
||||
|
||||
engine.execute_operation = flaky_execute_operation # type: ignore[method-assign]
|
||||
|
||||
results, summary, _ = engine.execute_plan(plan, mode="execute", confirmed=True)
|
||||
|
||||
assert len(results) == 2
|
||||
assert results[0].success is False
|
||||
assert "Unexpected failure during move: boom" == results[0].error_message
|
||||
assert results[1].success is True
|
||||
assert summary["failed"] == 1
|
||||
assert summary["successful"] == 1
|
||||
assert source_broken.exists()
|
||||
assert destination_ok.exists()
|
||||
|
||||
Reference in New Issue
Block a user