From 1ff9a635bd9b033b631a6b525891b7eb44e189d3 Mon Sep 17 00:00:00 2001 From: historia Date: Mon, 24 Aug 2026 16:08:33 -0400 Subject: feat: clearer split between local (managed) and remote URLs and server status --- app/tests/test_tts.py | 51 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-) (limited to 'app/tests/test_tts.py') diff --git a/app/tests/test_tts.py b/app/tests/test_tts.py index f99e257..0026702 100644 --- a/app/tests/test_tts.py +++ b/app/tests/test_tts.py @@ -84,6 +84,19 @@ class QwenTTSClientLanguageTests(unittest.TestCase): QwenTTSClient(language="klingon") mock_connect.assert_not_called() + def test_api_url_override_stored(self): + client = self._make_client(voice_mode=tts.VOICE_MODE_CUSTOM, + api_url="http://10.0.0.5:7860") + self.assertEqual(client.api_url, "http://10.0.0.5:7860") + + def test_api_url_override_used_by_connect(self): + with patch.object(QwenTTSClient, "_init_client") as mk_init: + client = QwenTTSClient.__new__(QwenTTSClient) + client.voice_mode = tts.VOICE_MODE_CUSTOM + client.api_url = "http://10.0.0.5:7860" + client._connect() + mk_init.assert_called_once_with("http://10.0.0.5:7860", clone=False) + class SeedResolutionTests(unittest.TestCase): """CONSTANT_SEED: one seed per run, reused for every request, so the @@ -1391,7 +1404,7 @@ class BackendWiringTests(unittest.TestCase): patch("converter.converter.AudioCppTTSClient") as mock_audiocpp: AudiobookConverter(voice_mode=tts.VOICE_MODE_CLONE, backend=tts.BACKEND_FASTER, voice="narrator") - mock_faster.assert_called_once_with(voice="narrator") + mock_faster.assert_called_once_with(voice="narrator", api_url=None) mock_qwen.assert_not_called() mock_audiocpp.assert_not_called() @@ -1405,7 +1418,8 @@ class BackendWiringTests(unittest.TestCase): mock_audiocpp.assert_called_once_with(voice="narrator", language="Japanese", model_id=None, instructions=None, - request_options={}) + request_options={}, + api_url=None) mock_faster.assert_not_called() mock_qwen.assert_not_called() @@ -1416,7 +1430,8 @@ class BackendWiringTests(unittest.TestCase): mock_audiocpp.assert_called_once_with(voice=None, language=config.LANGUAGE, model_id=None, instructions=None, - request_options={}) + request_options={}, + api_url=None) def test_audiocpp_backend_model_id_is_wired_through(self): with patch("converter.converter.AudioCppTTSClient") as mock_audiocpp: @@ -1426,7 +1441,7 @@ class BackendWiringTests(unittest.TestCase): mock_audiocpp.assert_called_once_with( voice="narrator", language=config.LANGUAGE, model_id="higgs", instructions=None, - request_options={}) + request_options={}, api_url=None) def test_audiocpp_backend_instructions_and_options_are_wired_through(self): with patch("converter.converter.AudioCppTTSClient") as mock_audiocpp: @@ -1439,7 +1454,8 @@ class BackendWiringTests(unittest.TestCase): voice=None, language=config.LANGUAGE, model_id=None, instructions="A warm adult narrator", - request_options={"emotion": "neutral", "speed": "1.1"}) + request_options={"emotion": "neutral", "speed": "1.1"}, + api_url=None) def test_qwen_backend_uses_qwen_client(self): with patch("converter.converter.FasterTTSClient") as mock_faster, \ @@ -1457,6 +1473,31 @@ class BackendWiringTests(unittest.TestCase): AudiobookConverter(voice_mode=tts.VOICE_MODE_CLONE, backend=tts.BACKEND_QWEN) + def test_api_url_override_reaches_each_client(self): + # A remote conversion threads api_url through to the selected client. + with patch("converter.converter.AudioCppTTSClient") as mock_audiocpp: + AudiobookConverter(voice_mode=tts.VOICE_MODE_CLONE, + backend=tts.BACKEND_AUDIOCPP, voice="narrator", + api_url="http://10.0.0.5:8080") + mock_audiocpp.assert_called_once_with( + voice="narrator", language=config.LANGUAGE, model_id=None, + instructions=None, request_options={}, + api_url="http://10.0.0.5:8080") + with patch("converter.converter.FasterTTSClient") as mock_faster: + AudiobookConverter(voice_mode=tts.VOICE_MODE_CLONE, + backend=tts.BACKEND_FASTER, voice="narrator", + api_url="http://10.0.0.5:8000") + mock_faster.assert_called_once_with(voice="narrator", + api_url="http://10.0.0.5:8000") + with patch("converter.converter.QwenTTSClient") as mock_qwen: + AudiobookConverter(voice_mode=tts.VOICE_MODE_CUSTOM, + backend=tts.BACKEND_QWEN, + api_url="http://10.0.0.5:7860") + mock_qwen.assert_called_once_with( + voice_mode=tts.VOICE_MODE_CUSTOM, voice_clone_ref_audio=None, + voice_clone_ref_text=None, skip_transcription=False, + language=config.LANGUAGE, api_url="http://10.0.0.5:7860") + def test_audiocpp_clone_mode_does_not_require_reference(self): # Cloning is server-side for the audiocpp backend, so the # clone-mode voice can be selected without local reference audio. -- cgit v1.2.3