From f3bd511251f5be0b6fdce083809eaf3498dce3fe Mon Sep 17 00:00:00 2001 From: worldmozara Date: Wed, 21 Oct 2026 20:04:17 +0800 Subject: [PATCH] test: cover the notify install gate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `_setup_hooks` installs the wait hook only for an interactive run: a one-shot `plyngent "…"` never waits on a human, so `[notify]` must not arm a notifier that could never fire. The test asserts the hook is cleared again when the run is not interactive. --- tests/test_cli/test_limits.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_cli/test_limits.py b/tests/test_cli/test_limits.py index 8aed77a..e20eacc 100644 --- a/tests/test_cli/test_limits.py +++ b/tests/test_cli/test_limits.py @@ -99,6 +99,20 @@ def test_setup_hooks_installs_pty_hook_for_auto_continue(clean_auto_continue: No assert PtyManager._limit_continue is None +def test_setup_hooks_installs_the_notifier_only_for_an_interactive_run(clean_auto_continue: None) -> None: + """A one-shot run never waits on a human, so it installs no wait hook.""" + del clean_auto_continue + from plyngent.cli.app import _setup_hooks + from plyngent.config.models import NotifyConfig + + _setup_hooks(interactive=False, auto_continue=False, notify=NotifyConfig()) + assert get_prompt_wait_hook() is None + _setup_hooks(interactive=True, auto_continue=False, notify=NotifyConfig()) + assert get_prompt_wait_hook() is not None + _setup_hooks(interactive=False, auto_continue=False, notify=NotifyConfig()) + assert get_prompt_wait_hook() is None + + def test_pty_offer_raise_uses_auto_continue(clean_auto_continue: None) -> None: del clean_auto_continue PtyManager.set_limit_continue_hook(prompt_continue_limit)