diff --git a/tests/test_api/test_methods/test_get_chat_gifts.py b/tests/test_api/test_methods/test_get_chat_gifts.py new file mode 100644 index 00000000..26c83b47 --- /dev/null +++ b/tests/test_api/test_methods/test_get_chat_gifts.py @@ -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 diff --git a/tests/test_api/test_methods/test_get_user_gifts.py b/tests/test_api/test_methods/test_get_user_gifts.py new file mode 100644 index 00000000..38430c0e --- /dev/null +++ b/tests/test_api/test_methods/test_get_user_gifts.py @@ -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 diff --git a/tests/test_api/test_methods/test_repost_story.py b/tests/test_api/test_methods/test_repost_story.py new file mode 100644 index 00000000..f00b9f11 --- /dev/null +++ b/tests/test_api/test_methods/test_repost_story.py @@ -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 diff --git a/tests/test_api/test_methods/test_send_message_draft.py b/tests/test_api/test_methods/test_send_message_draft.py new file mode 100644 index 00000000..cdb775fd --- /dev/null +++ b/tests/test_api/test_methods/test_send_message_draft.py @@ -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