From 2e63135745ba5c4e0303ff0e9fb45233a08dd3f9 Mon Sep 17 00:00:00 2001 From: James Mackay Date: Fri, 9 Oct 2026 06:11:28 +0100 Subject: [PATCH] =?UTF-8?q?test(media=5Fplayer):=20spied=20sleep=20proves?= =?UTF-8?q?=20a=20non-default=20digit=20delay=20(0.3=20s)=20reaches=20the?= =?UTF-8?q?=20channel=20sequence=20=E2=80=94=20option=20consumed=20per=20d?= =?UTF-8?q?igit=20(t26=20F3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_command_routing.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/test_command_routing.py b/tests/test_command_routing.py index b1b3b33..eece6a9 100644 --- a/tests/test_command_routing.py +++ b/tests/test_command_routing.py @@ -724,6 +724,37 @@ class TestAdbCommandService: assert not player.hass.services.has_service("nvidia_shield", "adb_command") +class TestChannelDigitDelayConsumed: + """t26 F3: a non-default digit delay reaches the sequence's sleep.""" + + async def test_non_default_delay_reaches_the_sequence_sleep(self, modules): + import asyncio + + player, _s = _ladder_player(modules) + player._entry.options["channel_digit_delay"] = 0.3 # non-default + + sleeps: list[float] = [] + real_sleep = asyncio.sleep + + mp_module = sys.modules["nsh.media_player"] + real_module_sleep = mp_module.asyncio.sleep + + async def spying_sleep(delay, *args): + sleeps.append(delay) + await real_sleep(0) + + mp_module.asyncio.sleep = spying_sleep + try: + await player.async_play_media("channel", "123") + if player._channel_task is not None: + await player._channel_task # the sequence runs to completion + finally: + mp_module.asyncio.sleep = real_module_sleep + + # three digits → three sleeps, each with the option's 0.3 s + assert sleeps == [0.3, 0.3, 0.3] + + class TestTextEntry: """P5-2: text entry — protocol IME first, ADB input-text fallback."""