64 lines
2.5 KiB
Python
64 lines
2.5 KiB
Python
"""Phase 5 tests: ASR configuration validation.
|
|
|
|
Covers:
|
|
- Valid ASR_PROVIDER values (dashscope, openrouter) load correctly
|
|
- Invalid ASR_PROVIDER raises ValueError
|
|
- Default values for new Phase 5 settings
|
|
"""
|
|
import os
|
|
|
|
import pytest
|
|
|
|
|
|
class TestAsrProviderConfig:
|
|
def test_dashscope_is_default(self, monkeypatch, tmp_path):
|
|
monkeypatch.setenv("ASR_PROVIDER", "dashscope")
|
|
monkeypatch.setenv("DASHSCOPE_API_KEY", "sk-test")
|
|
from app.core.config import get_settings
|
|
get_settings.cache_clear()
|
|
s = get_settings()
|
|
assert s.asr_provider == "dashscope"
|
|
|
|
def test_openrouter_provider_loads(self, monkeypatch, tmp_path):
|
|
monkeypatch.setenv("ASR_PROVIDER", "openrouter")
|
|
monkeypatch.setenv("DASHSCOPE_API_KEY", "sk-test")
|
|
monkeypatch.setenv("OPENROUTER_API_KEY", "sk-or-test")
|
|
from app.core.config import get_settings
|
|
get_settings.cache_clear()
|
|
s = get_settings()
|
|
assert s.asr_provider == "openrouter"
|
|
|
|
def test_invalid_provider_raises_valueerror(self, monkeypatch, tmp_path):
|
|
monkeypatch.setenv("ASR_PROVIDER", "invalid_provider")
|
|
monkeypatch.setenv("DASHSCOPE_API_KEY", "sk-test")
|
|
monkeypatch.setenv("OPENROUTER_API_KEY", "")
|
|
from app.core.config import get_settings
|
|
get_settings.cache_clear()
|
|
with pytest.raises(ValueError, match="Invalid ASR_PROVIDER"):
|
|
get_settings()
|
|
|
|
def test_openrouter_api_key_defaults_empty(self, monkeypatch, tmp_path):
|
|
monkeypatch.setenv("ASR_PROVIDER", "dashscope")
|
|
monkeypatch.setenv("DASHSCOPE_API_KEY", "sk-test")
|
|
monkeypatch.setenv("OPENROUTER_API_KEY", "")
|
|
from app.core.config import get_settings
|
|
get_settings.cache_clear()
|
|
s = get_settings()
|
|
assert s.openrouter_api_key == ""
|
|
|
|
def test_asr_openrouter_model_default(self, monkeypatch, tmp_path):
|
|
monkeypatch.setenv("ASR_PROVIDER", "dashscope")
|
|
monkeypatch.setenv("DASHSCOPE_API_KEY", "sk-test")
|
|
from app.core.config import get_settings
|
|
get_settings.cache_clear()
|
|
s = get_settings()
|
|
assert s.asr_openrouter_model == "google/gemini-3.1-flash-lite"
|
|
|
|
def test_openrouter_model_customizable(self, monkeypatch, tmp_path):
|
|
monkeypatch.setenv("DASHSCOPE_API_KEY", "sk-test")
|
|
monkeypatch.setenv("ASR_OPENROUTER_MODEL", "openai/whisper-large-v3")
|
|
from app.core.config import get_settings
|
|
get_settings.cache_clear()
|
|
s = get_settings()
|
|
assert s.asr_openrouter_model == "openai/whisper-large-v3"
|