Refactor aiogram client and update tests

Refactored base.py to improve code readability by separating response_type operation from model_validate(). Also, adjusted the parameters in URLInputFile() within test_input_file.py for better test coverage. Updated input_file.py to streamline read method and avoid unnecessary instantiation of Bot class. Lastly, adjusted typing in methods/base.py to enhance code clarity.
This commit is contained in:
Alex Root Junior 2023-07-11 23:12:01 +03:00
parent 7c314754a7
commit a9d8b7bd3d
No known key found for this signature in database
GPG key ID: 074C1D455EBEA4AC
4 changed files with 30 additions and 24 deletions

View file

@ -4,6 +4,7 @@ from aresponses import ResponsesMockServer
from aiogram import Bot
from aiogram.types import BufferedInputFile, FSInputFile, InputFile, URLInputFile
from tests.mocked_bot import MockedBot
class TestInputFile:
@ -72,10 +73,8 @@ class TestInputFile:
aresponses.add(
aresponses.ANY, aresponses.ANY, "get", aresponses.Response(status=200, body=b"\f" * 10)
)
Bot.set_current(Bot("42:TEST"))
file = URLInputFile("https://test.org/", chunk_size=1)
bot = Bot(token="42:TEST")
file = URLInputFile("https://test.org/", bot, chunk_size=1)
size = 0
async for chunk in file: