Handle empty external reply story in updates (#1587)

This commit is contained in:
latand 2026-02-10 22:28:59 +02:00
parent 1708980ceb
commit 58993e0e5e
4 changed files with 84 additions and 1 deletions

View file

@ -26,7 +26,7 @@ from aiogram.exceptions import (
TelegramServerError,
TelegramUnauthorizedError,
)
from aiogram.methods import DeleteMessage, GetMe, TelegramMethod
from aiogram.methods import DeleteMessage, GetMe, GetUpdates, TelegramMethod
from aiogram.types import UNSET_PARSE_MODE, LinkPreviewOptions, User
from aiogram.types.base import UNSET_DISABLE_WEB_PAGE_PREVIEW, UNSET_PROTECT_CONTENT
from tests.mocked_bot import MockedBot
@ -227,6 +227,52 @@ class TestBaseSession:
content='{"ok": "test"}',
)
def test_check_response_get_updates_with_empty_external_reply_story(self):
session = CustomSession()
bot = MockedBot()
method = GetUpdates()
response = session.check_response(
bot=bot,
method=method,
status_code=200,
content=json.dumps(
{
"ok": True,
"result": [
{
"update_id": 1,
"message": {
"message_id": 42,
"date": int(datetime.datetime.now().timestamp()),
"chat": {"id": 42, "type": "private"},
"from": {"id": 42, "is_bot": False, "first_name": "Test"},
"text": "test",
"external_reply": {
"origin": {
"type": "user",
"sender_user": {
"id": 43,
"is_bot": False,
"first_name": "Sender",
},
"date": int(datetime.datetime.now().timestamp()),
},
"story": {},
},
},
}
],
}
),
)
assert len(response.result) == 1
update = response.result[0]
assert update.message is not None
assert update.message.external_reply is not None
assert update.message.external_reply.story is None
async def test_make_request(self):
session = CustomSession()