mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Added full support of Telegram Bot API 9.3 (#1747)
* Added full support of Telegram Bot API 9.3 * Fixed tests that fails * Add tests for `GetChatGifts`, `GetUserGifts`, `RepostStory`, and `SendMessageDraft` methods * Added changelog record
This commit is contained in:
parent
ce4ddb77f4
commit
dcff0f99c7
132 changed files with 2993 additions and 457 deletions
|
|
@ -19,6 +19,7 @@ class TestGetChat:
|
|||
limited_gifts=True,
|
||||
unique_gifts=True,
|
||||
premium_subscription=True,
|
||||
gifts_from_channels=True,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
|
|
|||
41
tests/test_api/test_methods/test_get_chat_gifts.py
Normal file
41
tests/test_api/test_methods/test_get_chat_gifts.py
Normal 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
|
||||
41
tests/test_api/test_methods/test_get_user_gifts.py
Normal file
41
tests/test_api/test_methods/test_get_user_gifts.py
Normal 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
|
||||
24
tests/test_api/test_methods/test_repost_story.py
Normal file
24
tests/test_api/test_methods/test_repost_story.py
Normal 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
|
||||
19
tests/test_api/test_methods/test_send_message_draft.py
Normal file
19
tests/test_api/test_methods/test_send_message_draft.py
Normal 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
|
||||
|
|
@ -11,6 +11,7 @@ class TestSetBusinessAccountGiftSettings:
|
|||
business_connection_id="test_connection_id",
|
||||
show_gift_button=True,
|
||||
accepted_gift_types=AcceptedGiftTypes(
|
||||
gifts_from_channels=True,
|
||||
unlimited_gifts=True,
|
||||
limited_gifts=True,
|
||||
unique_gifts=True,
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ from aiogram.methods import (
|
|||
PinChatMessage,
|
||||
SendAnimation,
|
||||
SendAudio,
|
||||
SendChecklist,
|
||||
SendContact,
|
||||
SendDice,
|
||||
SendDocument,
|
||||
|
|
@ -661,6 +660,7 @@ TEST_MESSAGE_UNIQUE_GIFT = Message(
|
|||
from_user=User(id=42, is_bot=False, first_name="Test"),
|
||||
unique_gift=UniqueGiftInfo(
|
||||
gift=UniqueGift(
|
||||
gift_id="test_gift_id",
|
||||
base_name="test_gift",
|
||||
name="test_unique_gift",
|
||||
number=1,
|
||||
|
|
@ -704,6 +704,33 @@ TEST_MESSAGE_UNIQUE_GIFT = Message(
|
|||
origin="upgrade",
|
||||
),
|
||||
)
|
||||
TEST_MESSAGE_GIFT_UPGRADE_SENT = Message(
|
||||
message_id=42,
|
||||
chat=Chat(id=42, type="private"),
|
||||
from_user=User(id=42, is_bot=False, first_name="Test"),
|
||||
date=datetime.datetime.now(),
|
||||
gift_upgrade_sent=GiftInfo(
|
||||
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,
|
||||
),
|
||||
owned_gift_id="test_owned_gift_id",
|
||||
convert_star_count=50,
|
||||
prepaid_upgrade_star_count=25,
|
||||
can_be_upgraded=True,
|
||||
text="Test gift message",
|
||||
is_private=False,
|
||||
),
|
||||
)
|
||||
TEST_MESSAGE_CHECKLIST = Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
|
|
@ -874,6 +901,7 @@ MESSAGES_AND_CONTENT_TYPES = [
|
|||
[TEST_REFUND_PAYMENT, ContentType.REFUNDED_PAYMENT],
|
||||
[TEST_MESSAGE_GIFT, ContentType.GIFT],
|
||||
[TEST_MESSAGE_UNIQUE_GIFT, ContentType.UNIQUE_GIFT],
|
||||
[TEST_MESSAGE_GIFT_UPGRADE_SENT, ContentType.GIFT_UPGRADE_SENT],
|
||||
[TEST_MESSAGE_PAID_MESSAGE_PRICE_CHANGED, ContentType.PAID_MESSAGE_PRICE_CHANGED],
|
||||
[TEST_MESSAGE_SUGGESTED_POST_APPROVED, ContentType.SUGGESTED_POST_APPROVED],
|
||||
[TEST_MESSAGE_SUGGESTED_POST_APPROVAL_FAILED, ContentType.SUGGESTED_POST_APPROVAL_FAILED],
|
||||
|
|
@ -947,6 +975,7 @@ MESSAGES_AND_COPY_METHODS = [
|
|||
[TEST_REFUND_PAYMENT, None],
|
||||
[TEST_MESSAGE_GIFT, None],
|
||||
[TEST_MESSAGE_UNIQUE_GIFT, None],
|
||||
[TEST_MESSAGE_GIFT_UPGRADE_SENT, None],
|
||||
[TEST_MESSAGE_PAID_MESSAGE_PRICE_CHANGED, None],
|
||||
[TEST_MESSAGE_SUGGESTED_POST_APPROVED, None],
|
||||
[TEST_MESSAGE_SUGGESTED_POST_APPROVAL_FAILED, None],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue