59 lines
1.9 KiB
Python
59 lines
1.9 KiB
Python
import pytest
|
|
from typer.testing import CliRunner
|
|
|
|
from reyna_cli.cli import app
|
|
from reyna_cli.qwen_tts_direct import (
|
|
JV_SAMPLE_TEXT,
|
|
MODEL_ID,
|
|
Qwen3TTSDirectClient,
|
|
)
|
|
|
|
runner = CliRunner()
|
|
|
|
|
|
def test_qwen_defaults_match_gitea_voiceagent():
|
|
client = Qwen3TTSDirectClient()
|
|
assert client.model_id == MODEL_ID
|
|
assert client.model_id == "mlx-community/Qwen3-TTS-12Hz-0.6B-Base-bf16"
|
|
assert client.ref_audio.name == "jv_voice_sample.wav"
|
|
assert client.ref_text == JV_SAMPLE_TEXT
|
|
assert client.instruct is None
|
|
|
|
|
|
def test_qwen_config_is_offline_and_reports_jv_asset(tmp_path):
|
|
ref_audio = tmp_path / "jv_voice_sample.wav"
|
|
ref_audio.write_bytes(b"not-a-real-wav")
|
|
client = Qwen3TTSDirectClient(ref_audio=ref_audio)
|
|
|
|
status = client.config_status()
|
|
|
|
assert status["source"] == "direct"
|
|
assert status["engine"] == "qwen3-tts"
|
|
assert status["model_id"] == MODEL_ID
|
|
assert status["ref_audio"] == str(ref_audio)
|
|
assert status["ref_audio_exists"] is True
|
|
assert status["ref_text_configured"] is True
|
|
assert status["offline"] is True
|
|
|
|
|
|
def test_qwen_validation_rejects_missing_text_or_reference(tmp_path):
|
|
client = Qwen3TTSDirectClient(ref_audio=tmp_path / "missing.wav")
|
|
|
|
with pytest.raises(ValueError, match="text required"):
|
|
client.validate_generate("")
|
|
with pytest.raises(FileNotFoundError, match="reference audio"):
|
|
client.validate_generate("hello")
|
|
|
|
|
|
def test_qwen_cli_is_registered_alongside_kokoro():
|
|
result = runner.invoke(app, ["local-services", "qwen3-tts", "--help"])
|
|
assert result.exit_code == 0, result.output
|
|
assert "generate" in result.output
|
|
assert "config" in result.output
|
|
|
|
|
|
def test_qwen_cli_exposes_instruct_prompt():
|
|
result = runner.invoke(app, ["local-services", "qwen3-tts", "generate", "--help"])
|
|
assert result.exit_code == 0, result.output
|
|
assert "--instruct" in result.output
|