mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-08 17:13:56 +00:00
Mock Dispatcher._polling
This commit is contained in:
parent
2451b88ff5
commit
dcbf9b2760
1 changed files with 15 additions and 3 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import asyncio
|
||||
import datetime
|
||||
import time
|
||||
|
||||
|
|
@ -147,10 +148,21 @@ class TestDispatcher:
|
|||
assert len(log_records) == 1
|
||||
assert "Cause exception while process update" in log_records[0]
|
||||
|
||||
@pytest.mark.skip
|
||||
@pytest.mark.asyncio
|
||||
async def test_polling(self):
|
||||
pass
|
||||
async def test_polling(self, bot: MockedBot):
|
||||
dispatcher = Dispatcher()
|
||||
|
||||
async def _mock_updates(*_):
|
||||
yield Update(update_id=42)
|
||||
|
||||
with patch(
|
||||
"aiogram.dispatcher.dispatcher.Dispatcher.process_update", new_callable=CoroutineMock
|
||||
) as mocked_process_update, patch(
|
||||
"aiogram.dispatcher.dispatcher.Dispatcher._listen_updates"
|
||||
) as patched_listen_updates:
|
||||
patched_listen_updates.return_value = _mock_updates()
|
||||
await dispatcher._polling(bot=bot)
|
||||
mocked_process_update.assert_awaited()
|
||||
|
||||
@pytest.mark.skip
|
||||
@pytest.mark.asyncio
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue