Add tests for GetChatGifts, GetUserGifts, RepostStory, and SendMessageDraft methods

This commit is contained in:
JRoot Junior 2026-01-02 01:39:49 +02:00
parent f7574296b0
commit 8ffd714834
No known key found for this signature in database
GPG key ID: 738964250D5FF6E2
4 changed files with 125 additions and 0 deletions

View file

@ -0,0 +1,41 @@
import datetime
from aiogram.methods import GetChatGifts
from aiogram.types import Gift, OwnedGiftRegular, OwnedGifts, Sticker
from tests.mocked_bot import MockedBot
class TestGetChatGifts:
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
GetChatGifts,
ok=True,
result=OwnedGifts(
total_count=1,
gifts=[
OwnedGiftRegular(
gift=Gift(
id="test_gift_id",
sticker=Sticker(
file_id="test_file_id",
file_unique_id="test_file_unique_id",
type="regular",
width=512,
height=512,
is_animated=False,
is_video=False,
),
star_count=100,
),
send_date=int(datetime.datetime.now().timestamp()),
)
],
),
)
response: OwnedGifts = await bot.get_chat_gifts(
chat_id=42,
limit=10,
)
request = bot.get_request()
assert response == prepare_result.result

View file

@ -0,0 +1,41 @@
import datetime
from aiogram.methods import GetUserGifts
from aiogram.types import Gift, OwnedGiftRegular, OwnedGifts, Sticker
from tests.mocked_bot import MockedBot
class TestGetUserGifts:
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
GetUserGifts,
ok=True,
result=OwnedGifts(
total_count=1,
gifts=[
OwnedGiftRegular(
gift=Gift(
id="test_gift_id",
sticker=Sticker(
file_id="test_file_id",
file_unique_id="test_file_unique_id",
type="regular",
width=512,
height=512,
is_animated=False,
is_video=False,
),
star_count=100,
),
send_date=int(datetime.datetime.now().timestamp()),
)
],
),
)
response: OwnedGifts = await bot.get_user_gifts(
user_id=42,
limit=10,
)
request = bot.get_request()
assert response == prepare_result.result

View file

@ -0,0 +1,24 @@
from aiogram.methods import RepostStory
from aiogram.types import Chat, Story
from tests.mocked_bot import MockedBot
class TestRepostStory:
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
RepostStory,
ok=True,
result=Story(
id=42,
chat=Chat(id=42, type="private"),
),
)
response: Story = await bot.repost_story(
business_connection_id="test_connection_id",
from_chat_id=123,
from_story_id=456,
active_period=6 * 3600,
)
request = bot.get_request()
assert response == prepare_result.result

View file

@ -0,0 +1,19 @@
from aiogram.methods import SendMessageDraft
from tests.mocked_bot import MockedBot
class TestSendMessageDraft:
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendMessageDraft,
ok=True,
result=True,
)
response: bool = await bot.send_message_draft(
chat_id=42,
draft_id=1,
text="test draft",
)
request = bot.get_request()
assert response == prepare_result.result