Files
OpenJarvis/tests/speech/test_discovery.py
T
Prathap PandGitHub c2756964a7 fix(channels): wire channel→agent handler and fix Telegram send pipeline (#94)
* fix(channels): wire channel→agent handler and fix Telegram send pipeline

* format code

* add supported tests
2026-03-20 18:35:18 -07:00

49 lines
1.4 KiB
Python

"""Tests for speech backend auto-discovery."""
from unittest.mock import patch
from openjarvis.core.config import JarvisConfig
def test_get_speech_backend_explicit():
"""Explicit backend selection works."""
from openjarvis.speech._discovery import get_speech_backend
config = JarvisConfig()
config.speech.backend = "faster-whisper"
with patch("openjarvis.speech._discovery._create_backend") as mock_create:
mock_backend = type(
"MockBackend",
(),
{
"backend_id": "faster-whisper",
"health": lambda self: True,
},
)()
mock_create.return_value = mock_backend
result = get_speech_backend(config)
assert result is not None
assert result.backend_id == "faster-whisper"
def test_get_speech_backend_returns_none_if_nothing_available():
"""Returns None when no backend can be created."""
from openjarvis.speech._discovery import get_speech_backend
config = JarvisConfig()
config.speech.backend = "nonexistent"
result = get_speech_backend(config)
assert result is None
def test_auto_discovery_priority():
"""Auto mode tries backends in priority order."""
from openjarvis.speech._discovery import DISCOVERY_ORDER
assert DISCOVERY_ORDER[0] == "faster-whisper"
assert "openai" in DISCOVERY_ORDER
assert "deepgram" in DISCOVERY_ORDER