mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-09 01:15:31 +00:00
Rework polling and start covering
This commit is contained in:
parent
38c725db46
commit
db397e3a05
6 changed files with 84 additions and 12 deletions
|
|
@ -48,10 +48,16 @@ class TestBaseBot:
|
|||
mocked_close.assert_awaited()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_context_manager(self):
|
||||
@pytest.mark.parametrize("close", [True, False])
|
||||
async def test_context_manager(self, close: bool):
|
||||
with patch(
|
||||
"aiogram.api.client.session.aiohttp.AiohttpSession.close", new_callable=CoroutineMock
|
||||
) as mocked_close:
|
||||
async with BaseBot("42:TEST", session=AiohttpSession()) as bot:
|
||||
async with BaseBot("42:TEST", session=AiohttpSession()).context(
|
||||
auto_close=close
|
||||
) as bot:
|
||||
assert isinstance(bot, BaseBot)
|
||||
mocked_close.assert_awaited()
|
||||
if close:
|
||||
mocked_close.assert_awaited()
|
||||
else:
|
||||
mocked_close.assert_not_awaited()
|
||||
|
|
|
|||
20
tests/test_api/test_types/test_user.py
Normal file
20
tests/test_api/test_types/test_user.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import pytest
|
||||
|
||||
from aiogram.api.types import User
|
||||
|
||||
|
||||
class TestUser:
|
||||
@pytest.mark.parametrize(
|
||||
"first,last,result",
|
||||
[
|
||||
["User", None, "User"],
|
||||
["", None, ""],
|
||||
[" ", None, " "],
|
||||
["User", "Name", "User Name"],
|
||||
["User", " ", "User "],
|
||||
[" ", " ", " "],
|
||||
],
|
||||
)
|
||||
def test_full_name(self, first: str, last: str, result: bool):
|
||||
user = User(id=42, is_bot=False, first_name=first, last_name=last)
|
||||
assert user.full_name == result
|
||||
Loading…
Add table
Add a link
Reference in a new issue