Remove legacy compatibility paths
This commit is contained in:
parent
5b38cc7dcd
commit
b42298b9b5
8 changed files with 23 additions and 323 deletions
|
|
@ -26,7 +26,6 @@ class ConfigTests(unittest.TestCase):
|
|||
self.assertFalse(cfg.injection.remove_transcription_from_clipboard)
|
||||
self.assertEqual(cfg.vocabulary.replacements, [])
|
||||
self.assertEqual(cfg.vocabulary.terms, [])
|
||||
self.assertTrue(cfg.domain_inference.enabled)
|
||||
|
||||
self.assertTrue(missing.exists())
|
||||
written = json.loads(missing.read_text(encoding="utf-8"))
|
||||
|
|
@ -48,7 +47,6 @@ class ConfigTests(unittest.TestCase):
|
|||
],
|
||||
"terms": ["Systemd", "Kubernetes"],
|
||||
},
|
||||
"domain_inference": {"enabled": True},
|
||||
}
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
path = Path(td) / "config.json"
|
||||
|
|
@ -66,7 +64,6 @@ class ConfigTests(unittest.TestCase):
|
|||
self.assertEqual(cfg.vocabulary.replacements[0].source, "Martha")
|
||||
self.assertEqual(cfg.vocabulary.replacements[0].target, "Marta")
|
||||
self.assertEqual(cfg.vocabulary.terms, ["Systemd", "Kubernetes"])
|
||||
self.assertTrue(cfg.domain_inference.enabled)
|
||||
|
||||
def test_super_modifier_hotkey_is_valid(self):
|
||||
payload = {"daemon": {"hotkey": "Super+m"}}
|
||||
|
|
@ -98,28 +95,6 @@ class ConfigTests(unittest.TestCase):
|
|||
):
|
||||
load(str(path))
|
||||
|
||||
def test_loads_legacy_keys(self):
|
||||
payload = {
|
||||
"hotkey": "Alt+m",
|
||||
"input": "Mic",
|
||||
"whisper_model": "tiny",
|
||||
"whisper_device": "cpu",
|
||||
"injection_backend": "clipboard",
|
||||
}
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
path = Path(td) / "config.json"
|
||||
path.write_text(json.dumps(payload), encoding="utf-8")
|
||||
|
||||
cfg = load(str(path))
|
||||
|
||||
self.assertEqual(cfg.daemon.hotkey, "Alt+m")
|
||||
self.assertEqual(cfg.recording.input, "Mic")
|
||||
self.assertEqual(cfg.stt.model, "tiny")
|
||||
self.assertEqual(cfg.stt.device, "cpu")
|
||||
self.assertEqual(cfg.injection.backend, "clipboard")
|
||||
self.assertFalse(cfg.injection.remove_transcription_from_clipboard)
|
||||
self.assertEqual(cfg.vocabulary.replacements, [])
|
||||
|
||||
def test_invalid_injection_backend_raises(self):
|
||||
payload = {"injection": {"backend": "invalid"}}
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
|
|
@ -138,41 +113,20 @@ class ConfigTests(unittest.TestCase):
|
|||
with self.assertRaisesRegex(ValueError, "injection.remove_transcription_from_clipboard"):
|
||||
load(str(path))
|
||||
|
||||
def test_removed_ai_section_raises(self):
|
||||
payload = {"ai": {"enabled": True}}
|
||||
def test_unknown_top_level_fields_are_ignored(self):
|
||||
payload = {
|
||||
"custom_a": {"enabled": True},
|
||||
"custom_b": {"nested": "value"},
|
||||
"custom_c": 123,
|
||||
}
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
path = Path(td) / "config.json"
|
||||
path.write_text(json.dumps(payload), encoding="utf-8")
|
||||
|
||||
with self.assertRaisesRegex(ValueError, "ai section is no longer supported"):
|
||||
load(str(path))
|
||||
cfg = load(str(path))
|
||||
|
||||
def test_removed_legacy_ai_enabled_raises(self):
|
||||
payload = {"ai_enabled": True}
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
path = Path(td) / "config.json"
|
||||
path.write_text(json.dumps(payload), encoding="utf-8")
|
||||
|
||||
with self.assertRaisesRegex(ValueError, "ai_enabled is no longer supported"):
|
||||
load(str(path))
|
||||
|
||||
def test_removed_logging_section_raises(self):
|
||||
payload = {"logging": {"log_transcript": True}}
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
path = Path(td) / "config.json"
|
||||
path.write_text(json.dumps(payload), encoding="utf-8")
|
||||
|
||||
with self.assertRaisesRegex(ValueError, "no longer supported"):
|
||||
load(str(path))
|
||||
|
||||
def test_removed_legacy_log_transcript_raises(self):
|
||||
payload = {"log_transcript": True}
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
path = Path(td) / "config.json"
|
||||
path.write_text(json.dumps(payload), encoding="utf-8")
|
||||
|
||||
with self.assertRaisesRegex(ValueError, "no longer supported"):
|
||||
load(str(path))
|
||||
self.assertEqual(cfg.daemon.hotkey, "Cmd+m")
|
||||
self.assertEqual(cfg.injection.backend, "clipboard")
|
||||
|
||||
def test_conflicting_replacements_raise(self):
|
||||
payload = {
|
||||
|
|
@ -224,32 +178,15 @@ class ConfigTests(unittest.TestCase):
|
|||
with self.assertRaisesRegex(ValueError, "wildcard"):
|
||||
load(str(path))
|
||||
|
||||
def test_removed_domain_mode_raises(self):
|
||||
payload = {"domain_inference": {"mode": "heuristic"}}
|
||||
def test_unknown_vocabulary_fields_are_ignored(self):
|
||||
payload = {"vocabulary": {"custom_limit": 100, "custom_extra": 200, "terms": ["Docker"]}}
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
path = Path(td) / "config.json"
|
||||
path.write_text(json.dumps(payload), encoding="utf-8")
|
||||
|
||||
with self.assertRaisesRegex(ValueError, "domain_inference.mode is no longer supported"):
|
||||
load(str(path))
|
||||
cfg = load(str(path))
|
||||
|
||||
def test_removed_vocabulary_max_rules_raises(self):
|
||||
payload = {"vocabulary": {"max_rules": 100}}
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
path = Path(td) / "config.json"
|
||||
path.write_text(json.dumps(payload), encoding="utf-8")
|
||||
|
||||
with self.assertRaisesRegex(ValueError, "vocabulary.max_rules is no longer supported"):
|
||||
load(str(path))
|
||||
|
||||
def test_removed_vocabulary_max_terms_raises(self):
|
||||
payload = {"vocabulary": {"max_terms": 100}}
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
path = Path(td) / "config.json"
|
||||
path.write_text(json.dumps(payload), encoding="utf-8")
|
||||
|
||||
with self.assertRaisesRegex(ValueError, "vocabulary.max_terms is no longer supported"):
|
||||
load(str(path))
|
||||
self.assertEqual(cfg.vocabulary.terms, ["Docker"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue