Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
test(telegram): cover rich message fallback latch
Xubin Ren85036bacb637
diff --git a/tests/channels/test_telegram_channel.py b/tests/channels/test_telegram_channel.pyindex da3341474..90b1e7e45 100644--- a/tests/channels/test_telegram_channel.py+++ b/tests/channels/test_telegram_channel.py@@ -466,6 +466,45 @@ async def test_send_text_gives_up_after_max_retries() -> None:assert channel._app.bot.sent_messages == []+async def test_send_rich_capability_error_latches_and_falls_back() -> None:+ from telegram.error import BadRequest++ channel = TelegramChannel(+ TelegramConfig(enabled=True, token="123:abc", allow_from=["*"]),+ MessageBus(),+ )+ channel._app = _FakeApp(lambda: None)+ channel._app.bot.do_api_request = AsyncMock(side_effect=BadRequest("Method not found"))++ await channel.send(OutboundMessage(channel="telegram", chat_id="123", content="**hello**"))++ assert channel._rich_send_disabled is True+ channel._app.bot.do_api_request.assert_awaited_once()+ assert len(channel._app.bot.sent_messages) == 1+ assert channel._app.bot.sent_messages[0]["text"]+++async def test_send_rich_bad_request_does_not_latch_capability() -> None:+ from telegram.error import BadRequest++ channel = TelegramChannel(+ TelegramConfig(enabled=True, token="123:abc", allow_from=["*"]),+ MessageBus(),+ )+ channel._app = _FakeApp(lambda: None)+ channel._app.bot.do_api_request = AsyncMock(+ side_effect=BadRequest("Bad Request: message to reply not found")+ )++ await channel.send(OutboundMessage(channel="telegram", chat_id="123", content="**hello**"))++ assert channel._rich_send_disabled is False+ channel._app.bot.do_api_request.assert_awaited_once()+ assert len(channel._app.bot.sent_messages) == 1++@pytest.mark.asyncioasync def test_on_error_logs_network_issues_as_warning(monkeypatch) -> None:from telegram.error import NetworkError