fix: harden multimodal client entry flow

parent 8fe20489
...@@ -564,7 +564,7 @@ def test_main_runs_selected_mode_and_prints_text(monkeypatch, capsys, tmp_path): ...@@ -564,7 +564,7 @@ def test_main_runs_selected_mode_and_prints_text(monkeypatch, capsys, tmp_path):
captured = capsys.readouterr() captured = capsys.readouterr()
assert exit_code == 0 assert exit_code == 0
assert "done" in captured.out assert captured.out == "done\n"
def test_main_prints_artifact_path_when_present(monkeypatch, capsys, tmp_path): def test_main_prints_artifact_path_when_present(monkeypatch, capsys, tmp_path):
...@@ -581,5 +581,19 @@ def test_main_prints_artifact_path_when_present(monkeypatch, capsys, tmp_path): ...@@ -581,5 +581,19 @@ def test_main_prints_artifact_path_when_present(monkeypatch, capsys, tmp_path):
captured = capsys.readouterr() captured = capsys.readouterr()
assert exit_code == 0 assert exit_code == 0
assert "summary" in captured.out assert captured.out == f"summary\n{artifact}\n"
assert str(artifact) in captured.out
def test_main_returns_error_when_interactive_mode_selection_fails(monkeypatch, capsys, tmp_path):
monkeypatch.setattr(
"tools.manual_multimodal_test_client.choose_mode_interactively",
lambda: (_ for _ in ()).throw(ValueError("Invalid mode selection: 99")),
)
from tools.manual_multimodal_test_client import main
exit_code = main(["--output-dir", str(tmp_path)])
captured = capsys.readouterr()
assert exit_code == 1
assert captured.out == "ERROR [interactive]: Invalid mode selection: 99\n"
...@@ -286,10 +286,11 @@ def execute_mode(args: argparse.Namespace, selected_mode: str) -> dict: ...@@ -286,10 +286,11 @@ def execute_mode(args: argparse.Namespace, selected_mode: str) -> dict:
def main(argv: list[str] | None = None) -> int: def main(argv: list[str] | None = None) -> int:
args = parse_args(argv) args = parse_args(argv)
selected_mode = args.mode or choose_mode_interactively()
try: try:
selected_mode = args.mode or choose_mode_interactively()
result = execute_mode(args, selected_mode) result = execute_mode(args, selected_mode)
except Exception as exc: except Exception as exc:
selected_mode = args.mode or "interactive"
print(f"ERROR [{selected_mode}]: {exc}") print(f"ERROR [{selected_mode}]: {exc}")
return 1 return 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment