mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-09 01:15:31 +00:00
Cover Dispatcher._run_polling
This commit is contained in:
parent
dcbf9b2760
commit
90a035ed29
1 changed files with 24 additions and 4 deletions
|
|
@ -1,4 +1,3 @@
|
||||||
import asyncio
|
|
||||||
import datetime
|
import datetime
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
@ -164,10 +163,31 @@ class TestDispatcher:
|
||||||
await dispatcher._polling(bot=bot)
|
await dispatcher._polling(bot=bot)
|
||||||
mocked_process_update.assert_awaited()
|
mocked_process_update.assert_awaited()
|
||||||
|
|
||||||
@pytest.mark.skip
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_run_polling(self):
|
async def test_run_polling(self, bot: MockedBot):
|
||||||
pass
|
dispatcher = Dispatcher()
|
||||||
|
bot.add_result_for(
|
||||||
|
GetMe, ok=True, result=User(id=42, is_bot=True, first_name="The bot", username="tbot")
|
||||||
|
)
|
||||||
|
|
||||||
|
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.router.Router.emit_startup", new_callable=CoroutineMock
|
||||||
|
) as mocked_emit_startup, patch(
|
||||||
|
"aiogram.dispatcher.router.Router.emit_shutdown", new_callable=CoroutineMock
|
||||||
|
) as mocked_emit_shutdown, patch(
|
||||||
|
"aiogram.dispatcher.dispatcher.Dispatcher._listen_updates"
|
||||||
|
) as patched_listen_updates:
|
||||||
|
patched_listen_updates.return_value = _mock_updates()
|
||||||
|
await dispatcher._run_polling(bot)
|
||||||
|
|
||||||
|
mocked_emit_startup.assert_awaited()
|
||||||
|
mocked_process_update.assert_awaited()
|
||||||
|
mocked_emit_shutdown.assert_awaited()
|
||||||
|
|
||||||
@pytest.mark.skip
|
@pytest.mark.skip
|
||||||
def test_run(self):
|
def test_run(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue