feat: finalize multimodal test client flow

parent 9876a8fe
......@@ -549,3 +549,37 @@ def test_task5_execute_request_filters_method_and_url_from_forwarded_kwargs(monk
assert captured["kwargs"] == {"params": {"verbose": "1"}}
assert "method" not in captured["kwargs"]
assert "url" not in captured["kwargs"]
def test_main_runs_selected_mode_and_prints_text(monkeypatch, capsys, tmp_path):
monkeypatch.setattr("tools.manual_multimodal_test_client.choose_mode_interactively", lambda: "llm")
monkeypatch.setattr(
"tools.manual_multimodal_test_client.execute_mode",
lambda args, selected_mode: {"text": "done", "artifact_path": None},
)
from tools.manual_multimodal_test_client import main
exit_code = main(["--output-dir", str(tmp_path)])
captured = capsys.readouterr()
assert exit_code == 0
assert "done" in captured.out
def test_main_prints_artifact_path_when_present(monkeypatch, capsys, tmp_path):
artifact = tmp_path / "out.wav"
artifact.write_bytes(b"bytes")
monkeypatch.setattr(
"tools.manual_multimodal_test_client.execute_mode",
lambda args, selected_mode: {"text": "summary", "artifact_path": artifact},
)
from tools.manual_multimodal_test_client import main
exit_code = main(["audio-generation", "--output-dir", str(tmp_path)])
captured = capsys.readouterr()
assert exit_code == 0
assert "summary" in captured.out
assert str(artifact) in captured.out
......@@ -275,3 +275,30 @@ def execute_request(spec: dict):
finally:
if cleanup is not None:
cleanup()
def execute_mode(args: argparse.Namespace, selected_mode: str) -> dict:
config = resolve_mode_config(args, selected_mode)
spec = build_request_spec(config)
response = execute_request(spec)
return handle_response_payload(selected_mode, response, config["output_dir"])
def main(argv: list[str] | None = None) -> int:
args = parse_args(argv)
selected_mode = args.mode or choose_mode_interactively()
try:
result = execute_mode(args, selected_mode)
except Exception as exc:
print(f"ERROR [{selected_mode}]: {exc}")
return 1
if result.get("text"):
print(result["text"])
if result.get("artifact_path") is not None:
print(result["artifact_path"])
return 0
if __name__ == "__main__":
raise SystemExit(main())
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