feat: wire managed sample resolution into request builders

parent 1f1d0393
...@@ -227,6 +227,45 @@ def test_build_request_spec_for_transcription_uses_multipart_file(tmp_path): ...@@ -227,6 +227,45 @@ def test_build_request_spec_for_transcription_uses_multipart_file(tmp_path):
uploaded_file.close() uploaded_file.close()
def test_build_request_spec_for_transcription_downloads_missing_managed_default(tmp_path, monkeypatch):
managed_path = tmp_path / "samples" / "transcription.wav"
downloaded = []
config = {
"mode": "transcription",
"url": "http://127.0.0.1:6745",
"model": "audio:test",
"prompt": "Transcribe carefully",
"output_dir": tmp_path,
"token": None,
"audio_file": str(managed_path),
"video_file": None,
"response_format": None,
}
def fake_download(path):
downloaded.append(path)
path.parent.mkdir(parents=True, exist_ok=True)
path.write_bytes(b"downloaded-wav")
return path
monkeypatch.setattr(
"tools.manual_multimodal_test_client.SAMPLE_URLS",
{managed_path.as_posix(): "https://example.invalid/transcription.wav"},
)
monkeypatch.setattr(
"tools.manual_multimodal_test_client.download_default_sample",
fake_download,
)
spec = build_request_spec(config)
uploaded_name, uploaded_file = spec["files"]["file"]
assert uploaded_name == "transcription.wav"
assert uploaded_file.read() == b"downloaded-wav"
assert downloaded == [managed_path]
uploaded_file.close()
def test_build_request_spec_for_audio_generation_uses_json_payload(tmp_path): def test_build_request_spec_for_audio_generation_uses_json_payload(tmp_path):
config = { config = {
"mode": "audio-generation", "mode": "audio-generation",
......
...@@ -139,7 +139,7 @@ def build_request_spec(config: dict) -> dict: ...@@ -139,7 +139,7 @@ def build_request_spec(config: dict) -> dict:
} }
if mode == "transcription": if mode == "transcription":
audio_path = _require_file(config.get("audio_file"), "--audio-file") audio_path = ensure_sample_file(config.get("audio_file"), "--audio-file")
file_stack = ExitStack() file_stack = ExitStack()
return { return {
"method": "POST", "method": "POST",
...@@ -180,7 +180,7 @@ def build_request_spec(config: dict) -> dict: ...@@ -180,7 +180,7 @@ def build_request_spec(config: dict) -> dict:
} }
if mode == "video-doubt": if mode == "video-doubt":
video_path = _require_file(config.get("video_file"), "--video-file") video_path = ensure_sample_file(config.get("video_file"), "--video-file")
content = ( content = (
f"Video file: {video_path}\n" f"Video file: {video_path}\n"
f"Question: {config['prompt']}\n" f"Question: {config['prompt']}\n"
...@@ -198,7 +198,7 @@ def build_request_spec(config: dict) -> dict: ...@@ -198,7 +198,7 @@ def build_request_spec(config: dict) -> dict:
} }
if mode == "music-audio-doubt": if mode == "music-audio-doubt":
audio_path = _require_file(config.get("audio_file"), "--audio-file") audio_path = ensure_sample_file(config.get("audio_file"), "--audio-file")
content = ( content = (
f"Audio file: {audio_path}\n" f"Audio file: {audio_path}\n"
f"Question: {config['prompt']}\n" f"Question: {config['prompt']}\n"
......
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