From df6158ec18918f9d4d08f651a3acf14007dbb687 Mon Sep 17 00:00:00 2001 From: Xubin Ren <52506698+Re-bin@users.noreply.github.com> Date: Sun, 18 Oct 2026 13:36:21 +0800 Subject: [PATCH] test(telegram): cover plain and fragment media URLs --- .../channels/telegram/tests/test_telegram_channel.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/nanobot/channels/telegram/tests/test_telegram_channel.py b/nanobot/channels/telegram/tests/test_telegram_channel.py index dd618464c..680690451 100644 --- a/nanobot/channels/telegram/tests/test_telegram_channel.py +++ b/nanobot/channels/telegram/tests/test_telegram_channel.py @@ -1907,7 +1907,12 @@ async def test_send_reply_infers_topic_from_message_id_cache() -> None: @pytest.mark.asyncio -async def test_send_remote_media_url_after_security_validation(monkeypatch) -> None: +@pytest.mark.parametrize("media_url", [ + "https://example.com/cat.jpg", + "https://example.com/cat.jpg?width=672", + "https://example.com/cat.jpg#preview", +]) +async def test_send_remote_media_url_after_security_validation(monkeypatch, media_url) -> None: channel = TelegramChannel( TelegramConfig(enabled=True, token="123:abc", allow_from=["*"]), MessageBus(), @@ -1920,7 +1925,7 @@ async def test_send_remote_media_url_after_security_validation(monkeypatch) -> N channel="telegram", chat_id="123", content="", - media=["https://example.com/cat.jpg?width=672"], + media=[media_url], ) ) @@ -1928,7 +1933,7 @@ async def test_send_remote_media_url_after_security_validation(monkeypatch) -> N { "kind": "photo", "chat_id": 123, - "photo": "https://example.com/cat.jpg?width=672", + "photo": media_url, "reply_parameters": None, } ]