mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Update API
This commit is contained in:
parent
5aeab63384
commit
915c84c742
363 changed files with 1510 additions and 2262 deletions
|
|
@ -9,7 +9,9 @@ import aiogram
|
|||
|
||||
@contextmanager
|
||||
def check_deprecated(
|
||||
max_version: str, exception: Type[Exception], warning: Type[Warning] = DeprecationWarning,
|
||||
max_version: str,
|
||||
exception: Type[Exception],
|
||||
warning: Type[Warning] = DeprecationWarning,
|
||||
) -> None:
|
||||
"""
|
||||
Should be used for modules that are being deprecated or already removed from aiogram
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@ from tests.mocked_bot import MockedBot
|
|||
try:
|
||||
from asynctest import CoroutineMock, patch
|
||||
except ImportError:
|
||||
from unittest.mock import AsyncMock as CoroutineMock, patch # type: ignore
|
||||
from unittest.mock import AsyncMock as CoroutineMock # type: ignore
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
class TestBot:
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ from tests.mocked_bot import MockedBot
|
|||
try:
|
||||
from asynctest import CoroutineMock, patch
|
||||
except ImportError:
|
||||
from unittest.mock import AsyncMock as CoroutineMock, patch # type: ignore
|
||||
from unittest.mock import AsyncMock as CoroutineMock # type: ignore
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
class BareInputFile(InputFile):
|
||||
|
|
@ -212,5 +213,5 @@ class TestAiohttpSession:
|
|||
) as mocked_close:
|
||||
async with session as ctx:
|
||||
assert session == ctx
|
||||
mocked_close.awaited_once()
|
||||
mocked_create_session.awaited_once()
|
||||
mocked_close.assert_awaited_once()
|
||||
mocked_create_session.assert_awaited_once()
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ from aiogram.types import UNSET
|
|||
try:
|
||||
from asynctest import CoroutineMock, patch
|
||||
except ImportError:
|
||||
from unittest.mock import AsyncMock as CoroutineMock, patch # type: ignore
|
||||
from unittest.mock import AsyncMock as CoroutineMock # type: ignore
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
class CustomSession(BaseSession):
|
||||
|
|
@ -169,4 +170,4 @@ class TestBaseSession:
|
|||
) as mocked_close:
|
||||
async with session as ctx:
|
||||
assert session == ctx
|
||||
mocked_close.awaited_once()
|
||||
mocked_close.assert_awaited_once()
|
||||
|
|
|
|||
|
|
@ -21,7 +21,9 @@ class TestSetMyCommands:
|
|||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetMyCommands, ok=True, result=None)
|
||||
|
||||
response: bool = await bot.set_my_commands(commands=[],)
|
||||
response: bool = await bot.set_my_commands(
|
||||
commands=[],
|
||||
)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "setMyCommands"
|
||||
# assert request.data == {}
|
||||
|
|
|
|||
|
|
@ -448,7 +448,12 @@ class TestMessage:
|
|||
["sticker", dict(sticker="sticker"), SendSticker],
|
||||
[
|
||||
"venue",
|
||||
dict(latitude=0.42, longitude=0.42, title="title", address="address",),
|
||||
dict(
|
||||
latitude=0.42,
|
||||
longitude=0.42,
|
||||
title="title",
|
||||
address="address",
|
||||
),
|
||||
SendVenue,
|
||||
],
|
||||
["video", dict(video="video"), SendVideo],
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ from tests.mocked_bot import MockedBot
|
|||
try:
|
||||
from asynctest import CoroutineMock, patch
|
||||
except ImportError:
|
||||
from unittest.mock import AsyncMock as CoroutineMock, patch # type: ignore
|
||||
from unittest.mock import AsyncMock as CoroutineMock # type: ignore
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
async def simple_message_handler(message: Message):
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ from aiogram.dispatcher.event.handler import HandlerObject
|
|||
try:
|
||||
from asynctest import CoroutineMock, patch
|
||||
except ImportError:
|
||||
from unittest.mock import AsyncMock as CoroutineMock, patch # type: ignore
|
||||
from unittest.mock import AsyncMock as CoroutineMock # type: ignore
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
async def my_handler(value: str, index: int = 0) -> Any:
|
||||
|
|
@ -51,7 +52,8 @@ class TestEventObserver:
|
|||
assert observer.handlers[2].awaitable
|
||||
|
||||
with patch(
|
||||
"aiogram.dispatcher.event.handler.CallableMixin.call", new_callable=CoroutineMock,
|
||||
"aiogram.dispatcher.event.handler.CallableMixin.call",
|
||||
new_callable=CoroutineMock,
|
||||
) as mocked_my_handler:
|
||||
results = await observer.trigger("test")
|
||||
assert results is None
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ from aiogram.dispatcher.filters.base import BaseFilter
|
|||
try:
|
||||
from asynctest import CoroutineMock, patch
|
||||
except ImportError:
|
||||
from unittest.mock import AsyncMock as CoroutineMock, patch # type: ignore
|
||||
from unittest.mock import AsyncMock as CoroutineMock # type: ignore
|
||||
from unittest.mock import patch
|
||||
|
||||
|
||||
class MyFilter(BaseFilter):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue