mirror of
https://github.com/calesthio/OpenMontage.git
synced 2026-08-25 17:42:50 +08:00
fix: scope fal providers and Google TTS networking
This commit is contained in:
@@ -37,6 +37,32 @@ def test_registry_discovers_fal_tts(monkeypatch):
|
||||
assert tool.get_status() == ToolStatus.AVAILABLE
|
||||
|
||||
|
||||
def test_tts_selector_routes_to_fal_provider(monkeypatch):
|
||||
from tools.audio.tts_selector import TTSSelector
|
||||
from tools.base_tool import ToolResult
|
||||
|
||||
monkeypatch.setenv("FAL_KEY", "test-key")
|
||||
tool = FalElevenLabsTTS()
|
||||
selector = TTSSelector()
|
||||
monkeypatch.setattr(selector, "_providers", lambda: [tool])
|
||||
monkeypatch.setattr(
|
||||
selector,
|
||||
"_select_best_tool",
|
||||
lambda _inputs, _candidates, _context: (tool, None),
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
tool,
|
||||
"execute",
|
||||
lambda inputs: ToolResult(success=True, data={"received": inputs}),
|
||||
)
|
||||
result = selector.execute(
|
||||
{"text": "hello", "preferred_provider": "fal.ai", "voice_id": "Rachel"}
|
||||
)
|
||||
assert result.success
|
||||
assert result.data["selected_tool"] == "fal_elevenlabs_tts"
|
||||
assert result.data["selected_provider"] == "fal.ai"
|
||||
|
||||
|
||||
def test_execute_submits_once_and_downloads_audio(tmp_path, monkeypatch):
|
||||
monkeypatch.setenv("FAL_KEY", "test-key")
|
||||
output_path = tmp_path / "speech.mp3"
|
||||
|
||||
@@ -34,26 +34,3 @@ def test_tts_key_uses_header_and_is_redacted_from_errors(monkeypatch, tmp_path):
|
||||
assert result.success is False
|
||||
assert secret not in result.error
|
||||
assert "[REDACTED]" in result.error
|
||||
|
||||
|
||||
def test_production_adapter_can_force_google_tts_to_ipv4(monkeypatch, tmp_path):
|
||||
import socket
|
||||
|
||||
import requests
|
||||
import urllib3.util.connection
|
||||
|
||||
monkeypatch.setenv("GOOGLE_TTS_API_KEY", "test-key")
|
||||
monkeypatch.setenv("GOOGLE_TTS_FORCE_IPV4", "1")
|
||||
original = urllib3.util.connection.allowed_gai_family
|
||||
|
||||
def inspect_request(url, **kwargs):
|
||||
assert urllib3.util.connection.allowed_gai_family() == socket.AF_INET
|
||||
raise requests.HTTPError("safe expected failure")
|
||||
|
||||
monkeypatch.setattr(requests, "post", inspect_request)
|
||||
result = GoogleTTS().execute(
|
||||
{"text": "safe test sentence", "output_path": str(tmp_path / "speech.mp3")}
|
||||
)
|
||||
|
||||
assert result.success is False
|
||||
assert urllib3.util.connection.allowed_gai_family is original
|
||||
|
||||
Reference in New Issue
Block a user