mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-09 01:15:31 +00:00
Add tests for BaseBot
This commit is contained in:
parent
a46cd6d001
commit
3a43ffc570
2 changed files with 27 additions and 1 deletions
25
tests/test_api/test_client/test_base_bot.py
Normal file
25
tests/test_api/test_client/test_base_bot.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import pytest
|
||||
from asynctest import CoroutineMock, patch
|
||||
|
||||
from aiogram.api.client.base import BaseBot
|
||||
from aiogram.api.client.session.aiohttp import AiohttpSession
|
||||
from aiogram.api.methods import GetMe
|
||||
|
||||
|
||||
class TestBaseBot:
|
||||
def test_init(self):
|
||||
base_bot = BaseBot("TOKEN")
|
||||
assert isinstance(base_bot.session, AiohttpSession)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_emit(self):
|
||||
base_bot = BaseBot("TOKEN")
|
||||
|
||||
method = GetMe()
|
||||
|
||||
with patch(
|
||||
"aiogram.api.client.session.aiohttp.AiohttpSession.make_request",
|
||||
new_callable=CoroutineMock,
|
||||
) as mocked_make_request:
|
||||
await base_bot.emit(method)
|
||||
mocked_make_request.assert_awaited_with("TOKEN", method)
|
||||
|
|
@ -2,11 +2,12 @@ import datetime
|
|||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
from asynctest import CoroutineMock
|
||||
|
||||
from aiogram.api.client.session.base import BaseSession
|
||||
from aiogram.api.client.telegram import PRODUCTION, TelegramAPIServer
|
||||
from aiogram.api.methods import GetMe, Response
|
||||
from aiogram.utils.mixins import DataMixin
|
||||
from asynctest import CoroutineMock
|
||||
|
||||
|
||||
class TestBaseSession(DataMixin):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue