-
-
Notifications
You must be signed in to change notification settings - Fork 805
/
test_message.py
35 lines (26 loc) · 913 Bytes
/
test_message.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import pytest
import pytest_asyncio
from aiogram import Bot, types
from . import FakeTelegram
@pytest_asyncio.fixture(name="message")
async def message_fixture(bot: Bot):
"""
Message fixture
:param bot: Telegram bot fixture
:type bot: Bot
"""
from .types.dataset import MESSAGE
msg = types.Message(**MESSAGE)
async with FakeTelegram(message_data=MESSAGE):
_message = await bot.send_message(chat_id=msg.chat.id, text=msg.text)
yield _message
class TestMiscCases:
async def test_calling_bot_not_from_context(self, message):
"""
Calling any helper method without bot instance in context.
:param message: message fixture
:type message: types.Message
:return: RuntimeError with reason and help
"""
with pytest.raises(RuntimeError):
await message.edit_text('test_calling_bot_not_from_context')