43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
import sys
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
SRC = ROOT / "src"
|
|
if str(SRC) not in sys.path:
|
|
sys.path.insert(0, str(SRC))
|
|
|
|
from config import Config
|
|
from config_ui import (
|
|
RUNTIME_MODE_EXPERT,
|
|
RUNTIME_MODE_MANAGED,
|
|
apply_canonical_runtime_defaults,
|
|
infer_runtime_mode,
|
|
)
|
|
|
|
|
|
class ConfigUiRuntimeModeTests(unittest.TestCase):
|
|
def test_infer_runtime_mode_defaults_to_managed(self):
|
|
cfg = Config()
|
|
self.assertEqual(infer_runtime_mode(cfg), RUNTIME_MODE_MANAGED)
|
|
|
|
def test_infer_runtime_mode_detects_expert_overrides(self):
|
|
cfg = Config()
|
|
cfg.models.allow_custom_models = True
|
|
self.assertEqual(infer_runtime_mode(cfg), RUNTIME_MODE_EXPERT)
|
|
|
|
def test_apply_canonical_runtime_defaults_resets_expert_fields(self):
|
|
cfg = Config()
|
|
cfg.stt.provider = "local_whisper"
|
|
cfg.models.allow_custom_models = True
|
|
cfg.models.whisper_model_path = "/tmp/custom-whisper.bin"
|
|
|
|
apply_canonical_runtime_defaults(cfg)
|
|
|
|
self.assertEqual(cfg.stt.provider, "local_whisper")
|
|
self.assertFalse(cfg.models.allow_custom_models)
|
|
self.assertEqual(cfg.models.whisper_model_path, "")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|