Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions tests/unit/test_tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,21 @@ def test_convert_with_different_backend(self, tts_client, mock_client_wrapper):
call_args = mock_client_wrapper.request.call_args
assert call_args[1]["headers"]["model"] == "s1"

def test_convert_unknown_model_passed_through_to_header(
self, tts_client, mock_client_wrapper
):
"""Test that an unknown model name is passed through to the HTTP header as-is."""
mock_response = Mock()
mock_response.iter_bytes.return_value = iter([b"audio"])
mock_client_wrapper.request.return_value = mock_response

# Pass a model name that doesn't exist in the Model Literal type
tts_client.convert(text="Hello", model="speech-99-nonexistent")
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test passes a model value that is not part of the Model = Literal[...] type used by TTSClient.convert, which will likely fail the repo's ty check type-check job. To keep the runtime behavior test while satisfying type checking, add an explicit cast (e.g., to Any) or a targeted # type: ignore[arg-type] on the tts_client.convert(...) call; alternatively, if unknown models are intentionally supported, consider widening the model parameter type in the public API to accept str.

Suggested change
tts_client.convert(text="Hello", model="speech-99-nonexistent")
tts_client.convert(text="Hello", model="speech-99-nonexistent") # type: ignore[arg-type]

Copilot uses AI. Check for mistakes.

# Verify the unknown model name still ends up in the request header
call_args = mock_client_wrapper.request.call_args
assert call_args[1]["headers"]["model"] == "speech-99-nonexistent"

def test_convert_with_prosody(self, tts_client, mock_client_wrapper):
"""Test TTS with prosody settings."""
mock_response = Mock()
Expand Down