feat: establish voice assistant V1 baseline
This commit is contained in:
75
tests/test_providers.py
Normal file
75
tests/test_providers.py
Normal file
@@ -0,0 +1,75 @@
|
||||
import pytest
|
||||
|
||||
|
||||
from voice_assistant.agent.mock import MockAgentAdapter
|
||||
from voice_assistant.config.loader import load_provider_catalog
|
||||
from voice_assistant.tts.voxcpm import VoxCPMTTSAdapter
|
||||
from voice_assistant.config.models import ProviderCatalog
|
||||
from voice_assistant.providers import load_provider_class
|
||||
|
||||
|
||||
def test_provider_must_implement_component_contract():
|
||||
catalog = ProviderCatalog.model_validate(
|
||||
{
|
||||
"providers": {
|
||||
"tts": {
|
||||
"invalid": {
|
||||
"name": "Invalid TTS Provider",
|
||||
"implementation": (
|
||||
"voice_assistant.agent.mock:"
|
||||
"MockAgentAdapter"
|
||||
),
|
||||
"capabilities": {},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
with pytest.raises(
|
||||
TypeError,
|
||||
match="must implement TTSAdapter",
|
||||
):
|
||||
load_provider_class(
|
||||
catalog=catalog,
|
||||
component="tts",
|
||||
provider="invalid",
|
||||
)
|
||||
|
||||
|
||||
def test_load_tts_provider_class():
|
||||
catalog = load_provider_catalog()
|
||||
|
||||
provider_class = load_provider_class(
|
||||
catalog=catalog,
|
||||
component="tts",
|
||||
provider="voxcpm",
|
||||
)
|
||||
|
||||
assert provider_class is VoxCPMTTSAdapter
|
||||
|
||||
|
||||
def test_load_agent_provider_class():
|
||||
catalog = load_provider_catalog()
|
||||
|
||||
provider_class = load_provider_class(
|
||||
catalog=catalog,
|
||||
component="agent",
|
||||
provider="mock",
|
||||
)
|
||||
|
||||
assert provider_class is MockAgentAdapter
|
||||
|
||||
|
||||
def test_unknown_provider_fails():
|
||||
catalog = load_provider_catalog()
|
||||
|
||||
with pytest.raises(
|
||||
ValueError,
|
||||
match="is not registered",
|
||||
):
|
||||
load_provider_class(
|
||||
catalog=catalog,
|
||||
component="tts",
|
||||
provider="does-not-exist",
|
||||
)
|
||||
Reference in New Issue
Block a user