mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 18:19:34 +00:00
Added test that prove previous fix
This commit is contained in:
parent
74e00a30b1
commit
afeb659b82
2 changed files with 27 additions and 0 deletions
27
tests/test_issues/test_bot_context_is_usable.py
Normal file
27
tests/test_issues/test_bot_context_is_usable.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
from datetime import datetime
|
||||
|
||||
from aiogram import Dispatcher, Router
|
||||
from aiogram.enums import ChatType
|
||||
from aiogram.filters import Command
|
||||
from aiogram.methods import SendMessage
|
||||
from aiogram.types import Chat, Message, Update, User
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
issue_router = Router()
|
||||
|
||||
|
||||
@issue_router.message(Command("test"))
|
||||
async def my_handler(message: Message):
|
||||
await message.answer("PASS")
|
||||
return True
|
||||
|
||||
|
||||
async def test_something(bot: MockedBot):
|
||||
dp = Dispatcher()
|
||||
dp.include_router(issue_router)
|
||||
bot.add_result_for(method=SendMessage, ok=True)
|
||||
chat = Chat(id=666, type=ChatType.PRIVATE)
|
||||
user = User(id=666, is_bot=False, first_name="User")
|
||||
msg = Message(message_id=1, date=datetime.now(), from_user=user, chat=chat, text="/test")
|
||||
result = await dp.feed_update(bot, Update(message=msg, update_id=1))
|
||||
assert result is True
|
||||
Loading…
Add table
Add a link
Reference in a new issue