comparison dictation/config_test.py @ 275:78699f810817

Add Qwen3-VL and WebRTC dictation services Add Bazel targets for the CUDA-backed Qwen3-VL server and a local WebRTC faster-whisper dictation service. Co-authored-by: Copilot <[email protected]> Copilot-Session: e3d8cb06-6c95-4ae0-9757-651d3796ab00
author MrJuneJune <me@mrjunejune.com>
date Mon, 17 Aug 2026 10:58:47 -0700
parents
children 49e9e591c9bb
comparison
equal deleted inserted replaced
274:c9be578316a6 275:78699f810817
1 import os
2 from pathlib import Path
3 import unittest
4 from unittest.mock import patch
5
6 from dictation.config import DictationConfig
7
8
9 class DictationConfigTest(unittest.TestCase):
10 def test_defaults_are_local_and_bounded(self):
11 with patch.dict(os.environ, {}, clear=True):
12 config = DictationConfig.from_environment()
13 self.assertEqual(config.host, "127.0.0.1")
14 self.assertEqual(config.port, 8090)
15 self.assertEqual(config.max_sessions, 1)
16 self.assertEqual(config.compute_type, "int8_float16")
17 self.assertTrue(str(config.model_dir).endswith("faster-whisper-small"))
18
19 def test_rejects_invalid_session_limit(self):
20 with patch.dict(
21 os.environ,
22 {"DICTATION_MAX_SESSIONS": "0"},
23 clear=True,
24 ):
25 with self.assertRaisesRegex(ValueError, "between 1 and 8"):
26 DictationConfig.from_environment()
27
28 def test_accepts_model_override(self):
29 with patch.dict(
30 os.environ,
31 {"DICTATION_MODEL_DIR": "/tmp/dictation-model"},
32 clear=True,
33 ):
34 config = DictationConfig.from_environment()
35 self.assertEqual(config.model_dir, Path("/tmp/dictation-model"))
36
37
38 if __name__ == "__main__":
39 unittest.main()