mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 10:11:52 +00:00
Add Dispatcher.feed_raw_update for processing raw updates
This commit is contained in:
parent
57f6d7d9a5
commit
6fadb8feb2
2 changed files with 37 additions and 4 deletions
|
|
@ -1,11 +1,12 @@
|
|||
import datetime
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
from aiogram import Bot
|
||||
from aiogram.api.types import Chat, Message, Update, User
|
||||
from aiogram.dispatcher.dispatcher import Dispatcher
|
||||
from aiogram.dispatcher.router import Router
|
||||
from asynctest import MagicMock, patch
|
||||
|
||||
|
||||
class TestDispatcher:
|
||||
|
|
@ -48,6 +49,30 @@ class TestDispatcher:
|
|||
|
||||
assert results_count == 1
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_feed_raw_update(self):
|
||||
dp = Dispatcher()
|
||||
bot = Bot("42:TEST")
|
||||
|
||||
with patch(
|
||||
"aiogram.dispatcher.dispatcher.Dispatcher.feed_update", new_callable=MagicMock
|
||||
) as patched_feed_update:
|
||||
patched_feed_update.__aiter__.return_value = ["test"]
|
||||
async for result in dp.feed_raw_update(
|
||||
bot=bot,
|
||||
update={
|
||||
"update_id": 42,
|
||||
"message": {
|
||||
"message_id": 42,
|
||||
"date": int(time.time()),
|
||||
"text": "test",
|
||||
"chat": {"id": 42, "type": "private"},
|
||||
"user": {"id": 42, "is_bot": False, "first_name": "Test"},
|
||||
},
|
||||
},
|
||||
):
|
||||
assert result == "test"
|
||||
|
||||
@pytest.mark.skip
|
||||
@pytest.mark.asyncio
|
||||
async def test_listen_updates(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue