Reworked request builder

This commit is contained in:
Alex Root Junior 2023-03-11 04:09:57 +02:00
parent 6570d0bab1
commit 8a56258824
No known key found for this signature in database
GPG key ID: 074C1D455EBEA4AC
175 changed files with 582 additions and 1504 deletions

View file

@ -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))

View file

@ -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"},

View file

@ -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)