mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Significant perfomance improve about x10 more times. Replace pydantic to msgspec.
This commit is contained in:
parent
cf269e15f4
commit
b1ba862539
141 changed files with 695 additions and 617 deletions
|
|
@ -4,7 +4,7 @@ from tests.mocked_bot import MockedBot
|
|||
|
||||
class TestApproveChatJoinRequest:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(ApproveChatJoinRequest, ok=True, result=None)
|
||||
prepare_result = bot.add_result_for(ApproveChatJoinRequest, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.approve_chat_join_request(
|
||||
chat_id=-42,
|
||||
|
|
|
|||
|
|
@ -13,11 +13,18 @@ class TestTelegramMethodRemoveUnset:
|
|||
[
|
||||
[{}, set()],
|
||||
[{"foo": "bar"}, {"foo"}],
|
||||
[{"foo": "bar", "baz": sentinel.DEFAULT}, {"foo"}],
|
||||
[
|
||||
{
|
||||
"foo": "bar",
|
||||
},
|
||||
{"foo"},
|
||||
],
|
||||
],
|
||||
)
|
||||
def test_remove_unset(self, values, names):
|
||||
validated = TelegramMethod.remove_unset(values)
|
||||
import msgspec
|
||||
|
||||
validated = msgspec.to_builtins(values)
|
||||
assert set(validated.keys()) == names
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from tests.mocked_bot import MockedBot
|
|||
|
||||
class TestGetMyCommands:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(GetMyCommands, ok=True, result=None)
|
||||
prepare_result = bot.add_result_for(GetMyCommands, ok=True, result=[])
|
||||
|
||||
response: List[BotCommand] = await bot.get_my_commands()
|
||||
request = bot.get_request()
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ from tests.mocked_bot import MockedBot
|
|||
|
||||
class TestReopenForumTopic:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(ReopenForumTopic, ok=True, result=None)
|
||||
prepare_result = bot.add_result_for(ReopenForumTopic, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.reopen_forum_topic(
|
||||
chat_id=42,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,20 @@
|
|||
from aiogram.methods import Request, SendDice
|
||||
from aiogram.types import Message
|
||||
from aiogram.types import Chat, Message
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestSendDice:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SendDice, ok=True, result=None)
|
||||
prepare_result = bot.add_result_for(
|
||||
SendDice,
|
||||
ok=True,
|
||||
result=Message(
|
||||
message_id=42,
|
||||
date=123,
|
||||
text="text",
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
)
|
||||
|
||||
response: Message = await bot.send_dice(chat_id=42)
|
||||
request = bot.get_request()
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from tests.mocked_bot import MockedBot
|
|||
|
||||
class TestSetMyCommands:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetMyCommands, ok=True, result=None)
|
||||
prepare_result = bot.add_result_for(SetMyCommands, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.set_my_commands(
|
||||
commands=[],
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ from tests.mocked_bot import MockedBot
|
|||
|
||||
class TestSetStickerSetThumbnail:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetStickerSetThumbnail, ok=True, result=None)
|
||||
prepare_result = bot.add_result_for(SetStickerSetThumbnail, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.set_sticker_set_thumbnail(name="test", user_id=42)
|
||||
request = bot.get_request()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue