35 lines
1.4 KiB
Python
35 lines
1.4 KiB
Python
"""A designed voice's benchmark must explain an unreachable Voice Design service."""
|
|
import os
|
|
import tempfile
|
|
import unittest
|
|
from unittest import mock
|
|
|
|
os.environ.setdefault("CONFIG_DIR", tempfile.mkdtemp(prefix="ttvc-test-config-"))
|
|
|
|
import requests
|
|
|
|
from core import tts_helpers
|
|
|
|
|
|
class VoiceDesignUnreachableTest(unittest.TestCase):
|
|
def test_connection_error_becomes_actionable_message(self):
|
|
with mock.patch.object(tts_helpers, "_post_tts_with_fallback",
|
|
side_effect=requests.ConnectionError("Max retries exceeded")):
|
|
with self.assertRaises(RuntimeError) as ctx:
|
|
tts_helpers._voice_design_voice_request_audio(
|
|
"DE_F_Test", "Hallo", {"voice_design_url": "http://127.0.0.1:9"})
|
|
self.assertIn("Voice Design service unreachable", str(ctx.exception))
|
|
self.assertIn("tts-faster-qwen3-tts-voicedesign", str(ctx.exception))
|
|
|
|
def test_http_errors_are_not_masked(self):
|
|
resp = mock.Mock(status_code=500)
|
|
resp.raise_for_status.side_effect = requests.HTTPError("500")
|
|
with mock.patch.object(tts_helpers, "_post_tts_with_fallback", return_value=resp):
|
|
with self.assertRaises(requests.HTTPError):
|
|
tts_helpers._voice_design_voice_request_audio(
|
|
"DE_F_Test", "Hallo", {"voice_design_url": "http://127.0.0.1:9"})
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|