mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-09 09:22:03 +00:00
Merge BaseBot to Bot class
This commit is contained in:
parent
fac69e52b7
commit
a823e275a7
6 changed files with 111 additions and 120 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import pytest
|
||||
|
||||
from aiogram.api.client.base import BaseBot
|
||||
from aiogram import Bot
|
||||
from aiogram.api.client.session.aiohttp import AiohttpSession
|
||||
from aiogram.api.methods import GetMe
|
||||
|
||||
|
|
@ -12,22 +12,22 @@ except ImportError:
|
|||
|
||||
class TestBaseBot:
|
||||
def test_init(self):
|
||||
base_bot = BaseBot("42:TEST")
|
||||
base_bot = Bot("42:TEST")
|
||||
assert isinstance(base_bot.session, AiohttpSession)
|
||||
assert base_bot.id == 42
|
||||
|
||||
def test_hashable(self):
|
||||
base_bot = BaseBot("42:TEST")
|
||||
base_bot = Bot("42:TEST")
|
||||
assert hash(base_bot) == hash("42:TEST")
|
||||
|
||||
def test_equals(self):
|
||||
base_bot = BaseBot("42:TEST")
|
||||
assert base_bot == BaseBot("42:TEST")
|
||||
base_bot = Bot("42:TEST")
|
||||
assert base_bot == Bot("42:TEST")
|
||||
assert base_bot != "42:TEST"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_emit(self):
|
||||
base_bot = BaseBot("42:TEST")
|
||||
base_bot = Bot("42:TEST")
|
||||
|
||||
method = GetMe()
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ class TestBaseBot:
|
|||
|
||||
@pytest.mark.asyncio
|
||||
async def test_close(self):
|
||||
base_bot = BaseBot("42:TEST", session=AiohttpSession())
|
||||
base_bot = Bot("42:TEST", session=AiohttpSession())
|
||||
await base_bot.session.create_session()
|
||||
|
||||
with patch(
|
||||
|
|
@ -55,10 +55,10 @@ class TestBaseBot:
|
|||
with patch(
|
||||
"aiogram.api.client.session.aiohttp.AiohttpSession.close", new_callable=CoroutineMock
|
||||
) as mocked_close:
|
||||
async with BaseBot("42:TEST", session=AiohttpSession()).context(
|
||||
async with Bot("42:TEST", session=AiohttpSession()).context(
|
||||
auto_close=close
|
||||
) as bot:
|
||||
assert isinstance(bot, BaseBot)
|
||||
assert isinstance(bot, Bot)
|
||||
if close:
|
||||
mocked_close.assert_awaited()
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue