75 lines
1.8 KiB
Python
75 lines
1.8 KiB
Python
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",
|
|
) |