commit remaining modified project files

This commit is contained in:
windyboy
2026-04-07 08:07:18 +08:00
parent d010cf936c
commit fb128c70d6
28 changed files with 4140 additions and 19643 deletions
+109
View File
@@ -232,3 +232,112 @@ def test_review_plan_show_all_overrides_preview_limit(tmp_path):
assert " - [2] " in result.output
assert " - [3] " in result.output
assert "more high-risk operations" not in result.output
def test_review_plan_tui_requires_interactive_terminal(tmp_path):
"""--tui should fail when stdin/stdout are not TTY (e.g. CliRunner)."""
config_path = tmp_path / "config.yaml"
_write_config(config_path, tmp_path / "library")
plan_path = tmp_path / "plan.json"
operations = [
{
"operation_type": "move",
"source_path": str(tmp_path / "a.mkv"),
"destination_path": str(tmp_path / "b.mkv"),
"reason": "organize",
"has_conflict": False,
"conflict_reason": None,
},
]
_write_plan(
plan_path,
operations=operations,
summary={"total": 1, "move": 1, "rename": 0, "quarantine": 0, "no-op": 0},
)
output_csv = tmp_path / "review.csv"
runner = CliRunner()
result = _invoke_review_plan(
runner,
config_path,
["--input", str(plan_path), "--output", str(output_csv), "--tui"],
)
assert result.exit_code == 1
assert "TTY" in result.output or "interactive terminal" in result.output
def test_review_plan_tui_stubbed_success(tmp_path, monkeypatch):
"""With TTY check stubbed and run_plan_review_tui stubbed, CLI should succeed."""
config_path = tmp_path / "config.yaml"
_write_config(config_path, tmp_path / "library")
plan_path = tmp_path / "plan.json"
operations = [
{
"operation_type": "move",
"source_path": str(tmp_path / "a.mkv"),
"destination_path": str(tmp_path / "b.mkv"),
"reason": "organize",
"has_conflict": False,
"conflict_reason": None,
},
]
_write_plan(
plan_path,
operations=operations,
summary={"total": 1, "move": 1, "rename": 0, "quarantine": 0, "no-op": 0},
)
monkeypatch.setattr("vlm.cli._review_plan_tui_streams_ok", lambda: True)
monkeypatch.setattr("vlm.review_tui.run_plan_review_tui", lambda ctx: 0)
output_csv = tmp_path / "review.csv"
runner = CliRunner()
result = _invoke_review_plan(
runner,
config_path,
["--input", str(plan_path), "--output", str(output_csv), "--tui"],
)
assert result.exit_code == 0
assert "Saved manual review CSV" in result.output
assert "Plan overview:" not in result.output
def test_review_plan_tui_stubbed_abort(tmp_path, monkeypatch):
"""TUI return code 1 should surface as CLI failure."""
config_path = tmp_path / "config.yaml"
_write_config(config_path, tmp_path / "library")
plan_path = tmp_path / "plan.json"
operations = [
{
"operation_type": "move",
"source_path": str(tmp_path / "a.mkv"),
"destination_path": str(tmp_path / "b.mkv"),
"reason": "organize",
"has_conflict": False,
"conflict_reason": None,
},
]
_write_plan(
plan_path,
operations=operations,
summary={"total": 1, "move": 1, "rename": 0, "quarantine": 0, "no-op": 0},
)
monkeypatch.setattr("vlm.cli._review_plan_tui_streams_ok", lambda: True)
monkeypatch.setattr("vlm.review_tui.run_plan_review_tui", lambda ctx: 1)
output_csv = tmp_path / "review.csv"
runner = CliRunner()
result = _invoke_review_plan(
runner,
config_path,
["--input", str(plan_path), "--output", str(output_csv), "--tui"],
)
assert result.exit_code == 1
assert "aborted" in result.output.lower()