mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Added full support for the Bot API 9.0 (#1671)
* Added full support for the Bot API 9.0 * Bump version
This commit is contained in:
parent
25e9127db9
commit
2c2bd61551
231 changed files with 9565 additions and 389 deletions
13
tests/test_api/test_methods/test_convert_gift_to_stars.py
Normal file
13
tests/test_api/test_methods/test_convert_gift_to_stars.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
from aiogram.methods import ConvertGiftToStars
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestConvertGiftToStars:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(ConvertGiftToStars, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.convert_gift_to_stars(
|
||||
business_connection_id="test_connection_id", owned_gift_id="test_gift_id"
|
||||
)
|
||||
request = bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
13
tests/test_api/test_methods/test_delete_business_messages.py
Normal file
13
tests/test_api/test_methods/test_delete_business_messages.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
from aiogram.methods import DeleteBusinessMessages
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestDeleteBusinessMessages:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(DeleteBusinessMessages, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.delete_business_messages(
|
||||
business_connection_id="test_connection_id", message_ids=[1, 2, 3]
|
||||
)
|
||||
request = bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
13
tests/test_api/test_methods/test_delete_story.py
Normal file
13
tests/test_api/test_methods/test_delete_story.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
from aiogram.methods import DeleteStory
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestDeleteStory:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(DeleteStory, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.delete_story(
|
||||
business_connection_id="test_connection_id", story_id=42
|
||||
)
|
||||
request = bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
26
tests/test_api/test_methods/test_edit_story.py
Normal file
26
tests/test_api/test_methods/test_edit_story.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import datetime
|
||||
|
||||
from aiogram.methods import EditStory
|
||||
from aiogram.types import Chat, InputStoryContentPhoto, Story
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestEditStory:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(
|
||||
EditStory,
|
||||
ok=True,
|
||||
result=Story(
|
||||
id=42,
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
)
|
||||
|
||||
response: Story = await bot.edit_story(
|
||||
business_connection_id="test_connection_id",
|
||||
story_id=42,
|
||||
content=InputStoryContentPhoto(type="photo", photo="test_photo"),
|
||||
caption="Test caption",
|
||||
)
|
||||
request = bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
import datetime
|
||||
|
||||
from aiogram.methods import GetBusinessAccountGifts
|
||||
from aiogram.types import Gift, OwnedGiftRegular, OwnedGifts, Sticker
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestGetBusinessAccountGifts:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(
|
||||
GetBusinessAccountGifts,
|
||||
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_business_account_gifts(
|
||||
business_connection_id="test_connection_id",
|
||||
limit=10,
|
||||
)
|
||||
request = bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
from aiogram.methods import GetBusinessAccountStarBalance
|
||||
from aiogram.types import StarAmount
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestGetBusinessAccountStarBalance:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(
|
||||
GetBusinessAccountStarBalance,
|
||||
ok=True,
|
||||
result=StarAmount(
|
||||
amount=100,
|
||||
nanostar_amount=500000000,
|
||||
),
|
||||
)
|
||||
|
||||
response: StarAmount = await bot.get_business_account_star_balance(
|
||||
business_connection_id="test_connection_id",
|
||||
)
|
||||
request = bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
from aiogram.methods import GetChat
|
||||
from aiogram.types import ChatFullInfo
|
||||
from aiogram.types import AcceptedGiftTypes, ChatFullInfo
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
|
|
@ -14,6 +14,12 @@ class TestGetChat:
|
|||
title="chat",
|
||||
accent_color_id=0,
|
||||
max_reaction_count=0,
|
||||
accepted_gift_types=AcceptedGiftTypes(
|
||||
unlimited_gifts=True,
|
||||
limited_gifts=True,
|
||||
unique_gifts=True,
|
||||
premium_subscription=True,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
from datetime import datetime
|
||||
|
||||
from aiogram.enums import TransactionPartnerUserTransactionTypeEnum
|
||||
from aiogram.methods import GetStarTransactions
|
||||
from aiogram.types import (
|
||||
File,
|
||||
|
|
@ -26,6 +27,7 @@ class TestGetStarTransactions:
|
|||
date=datetime.now(),
|
||||
source=TransactionPartnerUser(
|
||||
user=user,
|
||||
transaction_type=TransactionPartnerUserTransactionTypeEnum.GIFT_PURCHASE,
|
||||
),
|
||||
),
|
||||
StarTransaction(
|
||||
|
|
@ -35,12 +37,13 @@ class TestGetStarTransactions:
|
|||
date=datetime.now(),
|
||||
receiver=TransactionPartnerUser(
|
||||
user=user,
|
||||
transaction_type=TransactionPartnerUserTransactionTypeEnum.GIFT_PURCHASE,
|
||||
),
|
||||
),
|
||||
]
|
||||
),
|
||||
)
|
||||
|
||||
response: File = await bot.get_star_transactions(limit=10, offset=0)
|
||||
response: StarTransactions = await bot.get_star_transactions(limit=10, offset=0)
|
||||
request = bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
from aiogram.methods import GiftPremiumSubscription
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestGiftPremiumSubscription:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(GiftPremiumSubscription, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.gift_premium_subscription(
|
||||
user_id=123456789,
|
||||
month_count=3,
|
||||
star_count=1000,
|
||||
text="Enjoy your premium subscription!",
|
||||
)
|
||||
request = bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
26
tests/test_api/test_methods/test_post_story.py
Normal file
26
tests/test_api/test_methods/test_post_story.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import datetime
|
||||
|
||||
from aiogram.methods import PostStory
|
||||
from aiogram.types import Chat, InputStoryContentPhoto, Story
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestPostStory:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(
|
||||
PostStory,
|
||||
ok=True,
|
||||
result=Story(
|
||||
id=42,
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
)
|
||||
|
||||
response: Story = await bot.post_story(
|
||||
business_connection_id="test_connection_id",
|
||||
content=InputStoryContentPhoto(type="photo", photo="test_photo"),
|
||||
active_period=6 * 3600, # 6 hours
|
||||
caption="Test story caption",
|
||||
)
|
||||
request = bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
13
tests/test_api/test_methods/test_read_business_message.py
Normal file
13
tests/test_api/test_methods/test_read_business_message.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
from aiogram.methods import ReadBusinessMessage
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestReadBusinessMessage:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(ReadBusinessMessage, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.read_business_message(
|
||||
business_connection_id="test_connection_id", chat_id=123456789, message_id=42
|
||||
)
|
||||
request = bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
from aiogram.methods import RemoveBusinessAccountProfilePhoto
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestRemoveBusinessAccountProfilePhoto:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(
|
||||
RemoveBusinessAccountProfilePhoto, ok=True, result=True
|
||||
)
|
||||
|
||||
response: bool = await bot.remove_business_account_profile_photo(
|
||||
business_connection_id="test_connection_id", is_public=True
|
||||
)
|
||||
request = bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
14
tests/test_api/test_methods/test_set_business_account_bio.py
Normal file
14
tests/test_api/test_methods/test_set_business_account_bio.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
from aiogram.methods import SetBusinessAccountBio
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestSetBusinessAccountBio:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetBusinessAccountBio, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.set_business_account_bio(
|
||||
business_connection_id="test_connection_id",
|
||||
bio="This is a test bio for the business account",
|
||||
)
|
||||
request = bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
from aiogram.methods import SetBusinessAccountGiftSettings
|
||||
from aiogram.types import AcceptedGiftTypes
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestSetBusinessAccountGiftSettings:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetBusinessAccountGiftSettings, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.set_business_account_gift_settings(
|
||||
business_connection_id="test_connection_id",
|
||||
show_gift_button=True,
|
||||
accepted_gift_types=AcceptedGiftTypes(
|
||||
unlimited_gifts=True,
|
||||
limited_gifts=True,
|
||||
unique_gifts=True,
|
||||
premium_subscription=True,
|
||||
),
|
||||
)
|
||||
request = bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
from aiogram.methods import SetBusinessAccountName
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestSetBusinessAccountName:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetBusinessAccountName, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.set_business_account_name(
|
||||
business_connection_id="test_connection_id",
|
||||
first_name="Test Business",
|
||||
last_name="Account Name",
|
||||
)
|
||||
request = bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
from aiogram.methods import SetBusinessAccountProfilePhoto
|
||||
from aiogram.types import InputProfilePhotoStatic
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestSetBusinessAccountProfilePhoto:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetBusinessAccountProfilePhoto, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.set_business_account_profile_photo(
|
||||
business_connection_id="test_connection_id",
|
||||
photo=InputProfilePhotoStatic(photo="test_photo_file_id"),
|
||||
is_public=True,
|
||||
)
|
||||
request = bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
from aiogram.methods import SetBusinessAccountUsername
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestSetBusinessAccountUsername:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetBusinessAccountUsername, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.set_business_account_username(
|
||||
business_connection_id="test_connection_id", username="test_business_username"
|
||||
)
|
||||
request = bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
from aiogram.methods import TransferBusinessAccountStars
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestTransferBusinessAccountStars:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(TransferBusinessAccountStars, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.transfer_business_account_stars(
|
||||
business_connection_id="test_connection_id", star_count=100
|
||||
)
|
||||
request = bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
16
tests/test_api/test_methods/test_transfer_gift.py
Normal file
16
tests/test_api/test_methods/test_transfer_gift.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
from aiogram.methods import TransferGift
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestTransferGift:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(TransferGift, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.transfer_gift(
|
||||
business_connection_id="test_connection_id",
|
||||
owned_gift_id="test_gift_id",
|
||||
new_owner_chat_id=123456789,
|
||||
star_count=50,
|
||||
)
|
||||
request = bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
16
tests/test_api/test_methods/test_upgrade_gift.py
Normal file
16
tests/test_api/test_methods/test_upgrade_gift.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
from aiogram.methods import UpgradeGift
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestUpgradeGift:
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(UpgradeGift, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.upgrade_gift(
|
||||
business_connection_id="test_connection_id",
|
||||
owned_gift_id="test_gift_id",
|
||||
keep_original_details=True,
|
||||
star_count=100,
|
||||
)
|
||||
request = bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
Loading…
Add table
Add a link
Reference in a new issue