mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-08 17:13:56 +00:00
Check bot instance on Dispatcher __init__
This commit is contained in:
parent
dd899c9ca0
commit
3a38125619
2 changed files with 39 additions and 1 deletions
35
tests/test_dispatcher.py
Normal file
35
tests/test_dispatcher.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
from aiogram import Dispatcher, Bot
|
||||
|
||||
import pytest
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
|
||||
@pytest.yield_fixture()
|
||||
async def bot(event_loop):
|
||||
""" Bot fixture """
|
||||
_bot = Bot(token='123456789:AABBCCDDEEFFaabbccddeeff-1234567890',
|
||||
loop=event_loop)
|
||||
yield _bot
|
||||
await _bot.close()
|
||||
|
||||
|
||||
class TestDispatcherInit:
|
||||
async def test_successful_init(self, bot):
|
||||
"""
|
||||
Success __init__ case
|
||||
|
||||
:param bot: bot instance
|
||||
:type bot: Bot
|
||||
"""
|
||||
dp = Dispatcher(bot=bot)
|
||||
assert isinstance(dp, Dispatcher)
|
||||
|
||||
@pytest.mark.parametrize("bot_instance", [None, Bot, 123, 'abc'])
|
||||
async def test_wrong_bot_instance(self, bot_instance):
|
||||
"""
|
||||
User provides wrong data to 'bot' argument.
|
||||
:return: TypeError with reason
|
||||
"""
|
||||
with pytest.raises(TypeError):
|
||||
_ = Dispatcher(bot=bot_instance)
|
||||
Loading…
Add table
Add a link
Reference in a new issue