31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
import tempfile
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from beaver_gateway import config
|
|
|
|
|
|
def test_config_imports_sibling_modules():
|
|
root = Path(tempfile.mkdtemp(prefix="beaver-cfg-"))
|
|
(root / "policy_sibling.py").write_text("RULES = ('x',)\n")
|
|
(root / "config.py").write_text(
|
|
"from policy_sibling import RULES\n"
|
|
"assert RULES == ('x',)\n"
|
|
"gateway = Gateway()\n"
|
|
)
|
|
gw = config.load(root / "config.py")
|
|
assert gw.agents == []
|
|
|
|
|
|
def test_config_takes_transcribers_and_refuses_what_cannot_be_called():
|
|
root = Path(tempfile.mkdtemp(prefix="beaver-cfg-"))
|
|
(root / "config.py").write_text(
|
|
"gateway = Gateway(transcribers=[OpenAITranscriber(language='ru')])\n"
|
|
)
|
|
(gw_stt,) = config.load(root / "config.py").transcribers
|
|
assert gw_stt.language == "ru" and gw_stt.model == "whisper-1"
|
|
(root / "config.py").write_text("gateway = Gateway(transcribers=['whisper'])\n")
|
|
with pytest.raises(config.ConfigError, match=r"transcribers\[0\]"):
|
|
config.load(root / "config.py")
|