From 35b22dab6094cb2be1418e74dc70d2f761db0bcd Mon Sep 17 00:00:00 2001 From: Teknium Date: Fri, 27 Mar 2026 03:59:01 -0700 Subject: [PATCH] fix: add telegram.request mock and discovery fixture to remaining test files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The original PR missed test_dm_topics.py and test_telegram_network_reconnect.py — both need the telegram.request mock module. The reconnect test also needs _no_auto_discovery since _handle_polling_network_error calls connect() which now invokes discover_fallback_ips(). --- tests/gateway/test_dm_topics.py | 2 +- tests/gateway/test_telegram_network_reconnect.py | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/gateway/test_dm_topics.py b/tests/gateway/test_dm_topics.py index 98c6d4c063..168f1e817c 100644 --- a/tests/gateway/test_dm_topics.py +++ b/tests/gateway/test_dm_topics.py @@ -32,7 +32,7 @@ def _ensure_telegram_mock(): telegram_mod.constants.ChatType.CHANNEL = "channel" telegram_mod.constants.ChatType.PRIVATE = "private" - for name in ("telegram", "telegram.ext", "telegram.constants"): + for name in ("telegram", "telegram.ext", "telegram.constants", "telegram.request"): sys.modules.setdefault(name, telegram_mod) diff --git a/tests/gateway/test_telegram_network_reconnect.py b/tests/gateway/test_telegram_network_reconnect.py index 8223823578..f78a7f2080 100644 --- a/tests/gateway/test_telegram_network_reconnect.py +++ b/tests/gateway/test_telegram_network_reconnect.py @@ -27,7 +27,7 @@ def _ensure_telegram_mock(): telegram_mod.constants.ChatType.CHANNEL = "channel" telegram_mod.constants.ChatType.PRIVATE = "private" - for name in ("telegram", "telegram.ext", "telegram.constants"): + for name in ("telegram", "telegram.ext", "telegram.constants", "telegram.request"): sys.modules.setdefault(name, telegram_mod) @@ -36,6 +36,14 @@ _ensure_telegram_mock() from gateway.platforms.telegram import TelegramAdapter # noqa: E402 +@pytest.fixture(autouse=True) +def _no_auto_discovery(monkeypatch): + """Disable DoH auto-discovery so connect() uses the plain builder chain.""" + async def _noop(): + return [] + monkeypatch.setattr("gateway.platforms.telegram.discover_fallback_ips", _noop) + + def _make_adapter() -> TelegramAdapter: return TelegramAdapter(PlatformConfig(enabled=True, token="test-token"))