Add ux profiles and advanced config block
This commit is contained in:
parent
c8739b6804
commit
77ae21d0f6
4 changed files with 68 additions and 3 deletions
|
|
@ -87,7 +87,11 @@ class FakeHintModel:
|
|||
|
||||
|
||||
class FakeAIProcessor:
|
||||
def __init__(self):
|
||||
self.last_kwargs = {}
|
||||
|
||||
def process(self, text, lang="en", **_kwargs):
|
||||
self.last_kwargs = {"lang": lang, **_kwargs}
|
||||
return text
|
||||
|
||||
|
||||
|
|
@ -120,10 +124,12 @@ class DaemonTests(unittest.TestCase):
|
|||
*,
|
||||
cfg: Config | None = None,
|
||||
verbose: bool = False,
|
||||
ai_processor: FakeAIProcessor | None = None,
|
||||
) -> aman.Daemon:
|
||||
active_cfg = cfg if cfg is not None else self._config()
|
||||
active_ai_processor = ai_processor or FakeAIProcessor()
|
||||
with patch("aman._build_whisper_model", return_value=model), patch(
|
||||
"aman.LlamaProcessor", return_value=FakeAIProcessor()
|
||||
"aman.LlamaProcessor", return_value=active_ai_processor
|
||||
):
|
||||
return aman.Daemon(active_cfg, desktop, verbose=verbose)
|
||||
|
||||
|
|
@ -302,6 +308,31 @@ class DaemonTests(unittest.TestCase):
|
|||
self.assertEqual(stream.stop_calls, 1)
|
||||
self.assertEqual(stream.close_calls, 1)
|
||||
|
||||
@patch("aman.stop_audio_recording", return_value=FakeAudio(8))
|
||||
@patch("aman.start_audio_recording", return_value=(object(), object()))
|
||||
def test_ai_processor_receives_active_profile(self, _start_mock, _stop_mock):
|
||||
desktop = FakeDesktop()
|
||||
cfg = self._config()
|
||||
cfg.ux.profile = "fast"
|
||||
ai_processor = FakeAIProcessor()
|
||||
daemon = self._build_daemon(
|
||||
desktop,
|
||||
FakeModel(text="hello world"),
|
||||
cfg=cfg,
|
||||
verbose=False,
|
||||
ai_processor=ai_processor,
|
||||
)
|
||||
daemon._start_stop_worker = (
|
||||
lambda stream, record, trigger, process_audio: daemon._stop_and_process(
|
||||
stream, record, trigger, process_audio
|
||||
)
|
||||
)
|
||||
|
||||
daemon.toggle()
|
||||
daemon.toggle()
|
||||
|
||||
self.assertEqual(ai_processor.last_kwargs.get("profile"), "fast")
|
||||
|
||||
|
||||
class LockTests(unittest.TestCase):
|
||||
def test_lock_rejects_second_instance(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue