From efc37409aa26e7b8038d1dbdc133b3064489ae7f Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Mon, 18 May 2026 22:34:43 -0700 Subject: [PATCH] test+release: fix test fixture for forum_commands; map @chromalinx --- scripts/release.py | 1 + tests/gateway/test_telegram_forum_commands.py | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/scripts/release.py b/scripts/release.py index 738a5ed6369..9254a52e025 100755 --- a/scripts/release.py +++ b/scripts/release.py @@ -177,6 +177,7 @@ AUTHOR_MAP = { "gonzes7@gmail.com": "aqilaziz", # PR #26406 salvage (preserve native audio outside Telegram) "karthikeyann@users.noreply.github.com": "karthikeyann", # PR #26609 salvage (DM-topic routing pin) "rino.alpin@gmail.com": "kunci115", # PR #27098 salvage (thread-not-found retry) + "237601532+chromalinx@users.noreply.github.com": "chromalinx", # PR #27014 salvage (commands for groups+DM) "282919977+eliteworkstation94-ai@users.noreply.github.com": "eliteworkstation94-ai", # PR #28157 salvage (group reply session splits) "androidhtml@yandex.com": "hllqkb", "25840394+Bongulielmi@users.noreply.github.com": "Bongulielmi", diff --git a/tests/gateway/test_telegram_forum_commands.py b/tests/gateway/test_telegram_forum_commands.py index a08f88b1123..0e2ce6d286a 100644 --- a/tests/gateway/test_telegram_forum_commands.py +++ b/tests/gateway/test_telegram_forum_commands.py @@ -16,8 +16,9 @@ def _make_test_adapter(): adapter = object.__new__(TelegramAdapter) adapter.platform = Platform.TELEGRAM adapter.config = PlatformConfig(enabled=True, token="***", extra={}) - adapter.name = "test-telegram" - adapter._bot = AsyncMock(spec=["set_my_commands"]) + # ``name`` is a property derived from platform.value.title() + adapter._bot = MagicMock() + adapter._bot.set_my_commands = AsyncMock() adapter._forum_command_registered = set() adapter._forum_lock = asyncio.Lock() return adapter @@ -51,7 +52,7 @@ async def test_ensure_forum_commands_registers_once(): adapter = _make_test_adapter() msg = _forum_message(chat_id=-123, is_forum=True) - with patch("gateway.platforms.telegram.telegram_menu_commands") as mock_menu: + with patch("hermes_cli.commands.telegram_menu_commands") as mock_menu: mock_menu.return_value = ([("new", "Start new session"), ("help", "Show help")], 0) with patch("telegram.BotCommand") as MockBotCommand: instances = [] @@ -65,6 +66,13 @@ async def test_ensure_forum_commands_registers_once(): MockBotCommand.side_effect = _make_cmd with patch("telegram.BotCommandScopeChat") as MockScope: + # Track the chat_id passed to the BotCommandScopeChat constructor + # so the assertions below see an int instead of a bare MagicMock. + def _make_scope(chat_id): + s = MagicMock() + s.chat_id = chat_id + return s + MockScope.side_effect = _make_scope await adapter._ensure_forum_commands(msg) assert -123 in adapter._forum_command_registered @@ -82,7 +90,7 @@ async def test_ensure_forum_commands_handles_set_failure(): msg = _forum_message(chat_id=-456, is_forum=True) adapter._bot.set_my_commands.side_effect = Exception("Telegram API error") - with patch("gateway.platforms.telegram.telegram_menu_commands") as mock_menu: + with patch("hermes_cli.commands.telegram_menu_commands") as mock_menu: mock_menu.return_value = ([("new", "Start new session")], 0) # Should NOT raise despite the API error await adapter._ensure_forum_commands(msg) @@ -98,7 +106,7 @@ async def test_ensure_forum_commands_race_safety(): adapter = _make_test_adapter() msg = _forum_message(chat_id=-789, is_forum=True) - with patch("gateway.platforms.telegram.telegram_menu_commands") as mock_menu: + with patch("hermes_cli.commands.telegram_menu_commands") as mock_menu: mock_menu.return_value = ([("new", "Start new session")], 0) with patch("telegram.BotCommand"): with patch("telegram.BotCommandScopeChat"):