From 9938d27e27960de9ac931cf5fc080bb1ab561412 Mon Sep 17 00:00:00 2001 From: teknium1 Date: Sat, 14 Mar 2026 21:53:28 -0700 Subject: [PATCH] test(telegram): cover disconnect with inactive updater --- tests/gateway/test_telegram_conflict.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/gateway/test_telegram_conflict.py b/tests/gateway/test_telegram_conflict.py index f2e21281..86dc509d 100644 --- a/tests/gateway/test_telegram_conflict.py +++ b/tests/gateway/test_telegram_conflict.py @@ -98,3 +98,27 @@ async def test_polling_conflict_stops_polling_and_notifies_handler(monkeypatch): assert adapter.has_fatal_error is True updater.stop.assert_awaited() fatal_handler.assert_awaited_once() + + +@pytest.mark.asyncio +async def test_disconnect_skips_inactive_updater_and_app(monkeypatch): + adapter = TelegramAdapter(PlatformConfig(enabled=True, token="***")) + + updater = SimpleNamespace(running=False, stop=AsyncMock()) + app = SimpleNamespace( + updater=updater, + running=False, + stop=AsyncMock(), + shutdown=AsyncMock(), + ) + adapter._app = app + + warning = MagicMock() + monkeypatch.setattr("gateway.platforms.telegram.logger.warning", warning) + + await adapter.disconnect() + + updater.stop.assert_not_awaited() + app.stop.assert_not_awaited() + app.shutdown.assert_awaited_once() + warning.assert_not_called()