mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 18:19:34 +00:00
Added detection of API Errors and fixed coverage
This commit is contained in:
parent
4f2cc75951
commit
c3844bb18f
17 changed files with 179 additions and 216 deletions
|
|
@ -49,6 +49,10 @@ async def invalid_message_handler(message: Message):
|
|||
raise Exception(42)
|
||||
|
||||
|
||||
async def anext(ait):
|
||||
return await ait.__anext__()
|
||||
|
||||
|
||||
RAW_UPDATE = {
|
||||
"update_id": 42,
|
||||
"message": {
|
||||
|
|
@ -147,6 +151,21 @@ class TestDispatcher:
|
|||
break
|
||||
assert index == 42
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_listen_update_with_error(self, bot: MockedBot):
|
||||
dispatcher = Dispatcher()
|
||||
listen = dispatcher._listen_updates(bot=bot)
|
||||
bot.add_result_for(
|
||||
GetUpdates, ok=True, result=[Update(update_id=update_id) for update_id in range(42)]
|
||||
)
|
||||
bot.add_result_for(GetUpdates, ok=False, error_code=500, description="restarting")
|
||||
with patch(
|
||||
"aiogram.utils.backoff.Backoff.asleep",
|
||||
new_callable=CoroutineMock,
|
||||
) as mocked_asleep:
|
||||
assert isinstance(await anext(listen), Update)
|
||||
assert mocked_asleep.awaited
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_silent_call_request(self, bot: MockedBot, caplog):
|
||||
dispatcher = Dispatcher()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import pytest
|
||||
|
||||
from aiogram.dispatcher.event.bases import SkipHandler, skip, UNHANDLED
|
||||
from aiogram.dispatcher.event.bases import UNHANDLED, SkipHandler, skip
|
||||
from aiogram.dispatcher.router import Router
|
||||
from aiogram.utils.warnings import CodeHasNoEffect
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue