51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
import os
|
|
import tempfile
|
|
from unittest.mock import patch
|
|
|
|
|
|
def test_config_loads_defaults():
|
|
with tempfile.TemporaryDirectory() as tmpdir:
|
|
cfg_path = os.path.join(tmpdir, "config.toml")
|
|
import config
|
|
with patch("config.CONFIG_PATH", cfg_path):
|
|
cfg = config.load()
|
|
assert cfg["ollama"]["model"] == "gemma3:12b"
|
|
assert cfg["whisper"]["model"] == "large-v3"
|
|
assert cfg["server"]["port"] == 8765
|
|
|
|
|
|
def test_config_creates_file_on_first_run():
|
|
with tempfile.TemporaryDirectory() as tmpdir:
|
|
import importlib, config
|
|
importlib.reload(config)
|
|
cfg_path = os.path.join(tmpdir, "config.toml")
|
|
with patch("config.CONFIG_PATH", cfg_path):
|
|
config.load()
|
|
assert os.path.exists(cfg_path)
|
|
|
|
|
|
def test_config_has_audio_and_whisper_base_url():
|
|
import config
|
|
from unittest.mock import patch
|
|
import tempfile, os
|
|
with tempfile.TemporaryDirectory() as tmpdir:
|
|
cfg_path = os.path.join(tmpdir, "config.toml")
|
|
with patch("config.CONFIG_PATH", cfg_path):
|
|
cfg = config.load()
|
|
assert "audio" in cfg
|
|
assert cfg["audio"]["device"] == ""
|
|
assert cfg["whisper"]["base_url"] == ""
|
|
|
|
|
|
def test_config_has_diarization_defaults():
|
|
from unittest.mock import patch
|
|
import tempfile, os
|
|
with tempfile.TemporaryDirectory() as tmpdir:
|
|
cfg_path = os.path.join(tmpdir, "config.toml")
|
|
with patch("config.CONFIG_PATH", cfg_path):
|
|
import config
|
|
cfg = config.load()
|
|
assert "diarization" in cfg
|
|
assert cfg["diarization"]["enabled"] is False
|
|
assert cfg["diarization"]["hf_token"] == ""
|