mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Fix test "test_dispatcher.test_dispatcher.TestDispatcher::test_feed_raw_update"
This commit is contained in:
parent
2d6fc85dc0
commit
38c725db46
1 changed files with 21 additions and 18 deletions
|
|
@ -2,7 +2,6 @@ import datetime
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from asynctest import MagicMock, patch
|
|
||||||
|
|
||||||
from aiogram import Bot
|
from aiogram import Bot
|
||||||
from aiogram.api.types import Chat, Message, Update, User
|
from aiogram.api.types import Chat, Message, Update, User
|
||||||
|
|
@ -55,24 +54,28 @@ class TestDispatcher:
|
||||||
dp = Dispatcher()
|
dp = Dispatcher()
|
||||||
bot = Bot("42:TEST")
|
bot = Bot("42:TEST")
|
||||||
|
|
||||||
with patch(
|
@dp.message_handler()
|
||||||
"aiogram.dispatcher.dispatcher.Dispatcher.feed_update", new_callable=MagicMock
|
async def my_handler(message: Message):
|
||||||
) as patched_feed_update:
|
assert message.text == "test"
|
||||||
patched_feed_update.__aiter__.return_value = ["test"]
|
return message.text
|
||||||
async for result in dp.feed_raw_update(
|
|
||||||
bot=bot,
|
handled = False
|
||||||
update={
|
async for result in dp.feed_raw_update(
|
||||||
"update_id": 42,
|
bot=bot,
|
||||||
"message": {
|
update={
|
||||||
"message_id": 42,
|
"update_id": 42,
|
||||||
"date": int(time.time()),
|
"message": {
|
||||||
"text": "test",
|
"message_id": 42,
|
||||||
"chat": {"id": 42, "type": "private"},
|
"date": int(time.time()),
|
||||||
"user": {"id": 42, "is_bot": False, "first_name": "Test"},
|
"text": "test",
|
||||||
},
|
"chat": {"id": 42, "type": "private"},
|
||||||
|
"user": {"id": 42, "is_bot": False, "first_name": "Test"},
|
||||||
},
|
},
|
||||||
):
|
},
|
||||||
assert result == "test"
|
):
|
||||||
|
handled = True
|
||||||
|
assert result == "test"
|
||||||
|
assert handled
|
||||||
|
|
||||||
@pytest.mark.skip
|
@pytest.mark.skip
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue