32 lines
878 B
Python
32 lines
878 B
Python
|
|
"""Tests for TTS adapter module."""
|
||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
import pytest
|
||
|
|
|
||
|
|
from fusionagi.adapters.tts_adapter import StubTTSAdapter, audio_to_base64
|
||
|
|
|
||
|
|
|
||
|
|
class TestStubTTSAdapter:
|
||
|
|
@pytest.mark.asyncio
|
||
|
|
async def test_synthesize_returns_bytes(self) -> None:
|
||
|
|
adapter = StubTTSAdapter()
|
||
|
|
result = await adapter.synthesize("Hello world")
|
||
|
|
assert result == b""
|
||
|
|
|
||
|
|
@pytest.mark.asyncio
|
||
|
|
async def test_synthesize_with_voice_id(self) -> None:
|
||
|
|
adapter = StubTTSAdapter()
|
||
|
|
result = await adapter.synthesize("Test", voice_id="test_voice")
|
||
|
|
assert result is not None
|
||
|
|
|
||
|
|
|
||
|
|
class TestAudioToBase64:
|
||
|
|
def test_encodes_bytes(self) -> None:
|
||
|
|
result = audio_to_base64(b"hello")
|
||
|
|
assert result == "aGVsbG8="
|
||
|
|
|
||
|
|
def test_empty_bytes(self) -> None:
|
||
|
|
result = audio_to_base64(b"")
|
||
|
|
assert result == ""
|