view dictation/config_test.py @ 278:8d560f50ed4c

Improve infinite canvas interactions and browser chrome Render Lucide icons directly with Raylib, add searchable icon browsing, robust text editing, entity lifecycle animations, z-order-safe input, semantic themes, and animated editable browser controls. Document rendering, pinning, context, and component extension for future agents. Co-authored-by: Copilot <[email protected]> Copilot-Session: f68442b1-fa8f-46a0-9689-81710613bbd4
author MrJuneJune <me@mrjunejune.com>
date Mon, 17 Aug 2026 22:16:14 -0700
parents 78699f810817
children 49e9e591c9bb
line wrap: on
line source

import os
from pathlib import Path
import unittest
from unittest.mock import patch

from dictation.config import DictationConfig


class DictationConfigTest(unittest.TestCase):
    def test_defaults_are_local_and_bounded(self):
        with patch.dict(os.environ, {}, clear=True):
            config = DictationConfig.from_environment()
        self.assertEqual(config.host, "127.0.0.1")
        self.assertEqual(config.port, 8090)
        self.assertEqual(config.max_sessions, 1)
        self.assertEqual(config.compute_type, "int8_float16")
        self.assertTrue(str(config.model_dir).endswith("faster-whisper-small"))

    def test_rejects_invalid_session_limit(self):
        with patch.dict(
            os.environ,
            {"DICTATION_MAX_SESSIONS": "0"},
            clear=True,
        ):
            with self.assertRaisesRegex(ValueError, "between 1 and 8"):
                DictationConfig.from_environment()

    def test_accepts_model_override(self):
        with patch.dict(
            os.environ,
            {"DICTATION_MODEL_DIR": "/tmp/dictation-model"},
            clear=True,
        ):
            config = DictationConfig.from_environment()
        self.assertEqual(config.model_dir, Path("/tmp/dictation-model"))


if __name__ == "__main__":
    unittest.main()