mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Added tests
This commit is contained in:
parent
86e4ab235d
commit
624ba40ab0
12 changed files with 184 additions and 36 deletions
|
|
@ -0,0 +1,17 @@
|
|||
from aiogram.enums import StickerFormat
|
||||
from aiogram.methods import EditUserStarSubscription, Request, UploadStickerFile
|
||||
from aiogram.types import BufferedInputFile, File
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestEditUserStarSubscription:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(EditUserStarSubscription, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.edit_user_star_subscription(
|
||||
user_id=42,
|
||||
telegram_payment_charge_id="telegram_payment_charge_id",
|
||||
is_canceled=False,
|
||||
)
|
||||
request = bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
33
tests/test_api/test_methods/test_get_available_gifts.py
Normal file
33
tests/test_api/test_methods/test_get_available_gifts.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
from aiogram.enums import StickerFormat
|
||||
from aiogram.methods import GetAvailableGifts, Request, UploadStickerFile
|
||||
from aiogram.types import BufferedInputFile, File, Gift, Gifts, Sticker
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestGetAvailableGifts:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(
|
||||
GetAvailableGifts,
|
||||
ok=True,
|
||||
result=Gifts(
|
||||
gifts=[
|
||||
Gift(
|
||||
id="gift_id",
|
||||
sticker=Sticker(
|
||||
file_id="file_id",
|
||||
file_unique_id="file_id",
|
||||
type="regular",
|
||||
width=512,
|
||||
height=512,
|
||||
is_animated=False,
|
||||
is_video=False,
|
||||
),
|
||||
star_count=1,
|
||||
)
|
||||
]
|
||||
),
|
||||
)
|
||||
|
||||
response: Gifts = await bot.get_available_gifts()
|
||||
request = bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
from datetime import datetime, timedelta
|
||||
|
||||
from aiogram.methods import (
|
||||
SavePreparedInlineMessage,
|
||||
)
|
||||
from aiogram.types import (
|
||||
InlineQueryResultArticle,
|
||||
InputTextMessageContent,
|
||||
PreparedInlineMessage,
|
||||
)
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestSavePreparedInlineMessage:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(
|
||||
SavePreparedInlineMessage,
|
||||
ok=True,
|
||||
result=PreparedInlineMessage(
|
||||
id="id",
|
||||
expiration_date=datetime.now() + timedelta(days=1),
|
||||
),
|
||||
)
|
||||
|
||||
response: PreparedInlineMessage = await bot.save_prepared_inline_message(
|
||||
user_id=42,
|
||||
result=InlineQueryResultArticle(
|
||||
id="id",
|
||||
title="title",
|
||||
input_message_content=InputTextMessageContent(
|
||||
message_text="message_text",
|
||||
),
|
||||
),
|
||||
)
|
||||
request = bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
13
tests/test_api/test_methods/test_send_gift.py
Normal file
13
tests/test_api/test_methods/test_send_gift.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
from aiogram.enums import StickerFormat
|
||||
from aiogram.methods import GetAvailableGifts, Request, SendGift, UploadStickerFile
|
||||
from aiogram.types import BufferedInputFile, File, Gift, Gifts, Sticker
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestSendGift:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SendGift, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.send_gift(user_id=42, gift_id="gift_id")
|
||||
request = bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
17
tests/test_api/test_methods/test_set_user_emoji_status.py
Normal file
17
tests/test_api/test_methods/test_set_user_emoji_status.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
from datetime import datetime, timedelta
|
||||
|
||||
from aiogram.methods import SetUserEmojiStatus
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestSetUserEmojiStatus:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetUserEmojiStatus, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.set_user_emoji_status(
|
||||
user_id=42,
|
||||
emoji_status_custom_emoji_id="emoji_status_custom_emoji_id",
|
||||
emoji_status_expiration_date=datetime.now() + timedelta(days=1),
|
||||
)
|
||||
request = bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
Loading…
Add table
Add a link
Reference in a new issue