mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Reworked request builder
This commit is contained in:
parent
6570d0bab1
commit
8a56258824
175 changed files with 582 additions and 1504 deletions
|
|
@ -5,7 +5,7 @@ from aiogram import Bot
|
|||
from aiogram.client.session.base import BaseSession
|
||||
from aiogram.methods import TelegramMethod
|
||||
from aiogram.methods.base import Request, Response, TelegramType
|
||||
from aiogram.types import UNSET, ResponseParameters, User
|
||||
from aiogram.types import UNSET_PARSE_MODE, ResponseParameters, User
|
||||
|
||||
|
||||
class MockedSession(BaseSession):
|
||||
|
|
@ -26,7 +26,10 @@ class MockedSession(BaseSession):
|
|||
self.closed = True
|
||||
|
||||
async def make_request(
|
||||
self, bot: Bot, method: TelegramMethod[TelegramType], timeout: Optional[int] = UNSET
|
||||
self,
|
||||
bot: Bot,
|
||||
method: TelegramMethod[TelegramType],
|
||||
timeout: Optional[int] = UNSET_PARSE_MODE,
|
||||
) -> TelegramType:
|
||||
self.closed = False
|
||||
self.requests.append(method.build_request(bot))
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ from aiogram.client.session import aiohttp
|
|||
from aiogram.client.session.aiohttp import AiohttpSession
|
||||
from aiogram.exceptions import TelegramNetworkError
|
||||
from aiogram.methods import Request, TelegramMethod
|
||||
from aiogram.types import UNSET, InputFile
|
||||
from aiogram.types import UNSET_PARSE_MODE, InputFile
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ class TestAiohttpSession:
|
|||
"str": "value",
|
||||
"int": 42,
|
||||
"bool": True,
|
||||
"unset": UNSET,
|
||||
"unset": UNSET_PARSE_MODE,
|
||||
"null": None,
|
||||
"list": ["foo"],
|
||||
"dict": {"bar": "baz"},
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ from aiogram.exceptions import (
|
|||
TelegramUnauthorizedError,
|
||||
)
|
||||
from aiogram.methods import DeleteMessage, GetMe, TelegramMethod
|
||||
from aiogram.types import UNSET, User
|
||||
from aiogram.types import UNSET_PARSE_MODE, User
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
|
|
@ -33,7 +33,10 @@ class CustomSession(BaseSession):
|
|||
pass
|
||||
|
||||
async def make_request(
|
||||
self, token: str, method: TelegramMethod[TelegramType], timeout: Optional[int] = UNSET
|
||||
self,
|
||||
token: str,
|
||||
method: TelegramMethod[TelegramType],
|
||||
timeout: Optional[int] = UNSET_PARSE_MODE,
|
||||
) -> None: # type: ignore
|
||||
assert isinstance(token, str)
|
||||
assert isinstance(method, TelegramMethod)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue