mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 02:03:04 +00:00
Bot API 6.6 (#1139)
* Added basic support of Bot API 6.6 * Update descriptions * Added StickerFormat enum * Bump version * Refresh from docs * Fixed CommandStart * Fixed files uploading * Cover new functionality * Added changelog * Update texts
This commit is contained in:
parent
5adaf7a567
commit
6570d0bab1
218 changed files with 7687 additions and 1741 deletions
|
|
@ -1,4 +1,5 @@
|
|||
from aiogram.methods import AddStickerToSet, Request
|
||||
from aiogram.types import InputSticker
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
|
|
@ -7,7 +8,9 @@ class TestAddStickerToSet:
|
|||
prepare_result = bot.add_result_for(AddStickerToSet, ok=True, result=True)
|
||||
|
||||
response: bool = await AddStickerToSet(
|
||||
user_id=42, name="test stickers pack", png_sticker="file id", emojis=":)"
|
||||
user_id=42,
|
||||
name="test stickers pack",
|
||||
sticker=InputSticker(sticker="file id", emoji_list=[":)"]),
|
||||
)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "addStickerToSet"
|
||||
|
|
@ -17,7 +20,9 @@ class TestAddStickerToSet:
|
|||
prepare_result = bot.add_result_for(AddStickerToSet, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.add_sticker_to_set(
|
||||
user_id=42, name="test stickers pack", png_sticker="file id", emojis=":)"
|
||||
user_id=42,
|
||||
name="test stickers pack",
|
||||
sticker=InputSticker(sticker="file id", emoji_list=[":)"]),
|
||||
)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "addStickerToSet"
|
||||
|
|
|
|||
|
|
@ -32,7 +32,9 @@ class TestAnswerInlineQuery:
|
|||
def test_parse_mode(self, bot: MockedBot):
|
||||
query = AnswerInlineQuery(
|
||||
inline_query_id="query id",
|
||||
results=[InlineQueryResultPhoto(id="result id", photo_url="photo", thumb_url="thumb")],
|
||||
results=[
|
||||
InlineQueryResultPhoto(id="result id", photo_url="photo", thumbnail_url="thumb")
|
||||
],
|
||||
)
|
||||
request = query.build_request(bot)
|
||||
assert request.data["results"][0]["parse_mode"] is None
|
||||
|
|
@ -48,7 +50,7 @@ class TestAnswerInlineQuery:
|
|||
InlineQueryResultPhoto(
|
||||
id="result id",
|
||||
photo_url="photo",
|
||||
thumb_url="thumb",
|
||||
thumbnail_url="thumb",
|
||||
input_message_content=InputTextMessageContent(message_text="test"),
|
||||
)
|
||||
],
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
from aiogram.enums import StickerFormat
|
||||
from aiogram.methods import CreateNewStickerSet, Request
|
||||
from aiogram.types import FSInputFile, InputSticker
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
|
|
@ -7,7 +9,14 @@ class TestCreateNewStickerSet:
|
|||
prepare_result = bot.add_result_for(CreateNewStickerSet, ok=True, result=True)
|
||||
|
||||
response: bool = await CreateNewStickerSet(
|
||||
user_id=42, name="name", title="title", png_sticker="file id", emojis=":)"
|
||||
user_id=42,
|
||||
name="name",
|
||||
title="title",
|
||||
stickers=[
|
||||
InputSticker(sticker="file id", emoji_list=[":)"]),
|
||||
InputSticker(sticker=FSInputFile("file.png"), emoji_list=["=("]),
|
||||
],
|
||||
sticker_format=StickerFormat.STATIC,
|
||||
)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "createNewStickerSet"
|
||||
|
|
@ -17,7 +26,14 @@ class TestCreateNewStickerSet:
|
|||
prepare_result = bot.add_result_for(CreateNewStickerSet, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.create_new_sticker_set(
|
||||
user_id=42, name="name", title="title", png_sticker="file id", emojis=":)"
|
||||
user_id=42,
|
||||
name="name",
|
||||
title="title",
|
||||
stickers=[
|
||||
InputSticker(sticker="file id", emoji_list=[":)"]),
|
||||
InputSticker(sticker=FSInputFile("file.png"), emoji_list=["=("]),
|
||||
],
|
||||
sticker_format=StickerFormat.STATIC,
|
||||
)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "createNewStickerSet"
|
||||
|
|
|
|||
20
tests/test_api/test_methods/test_delete_sticker_set.py
Normal file
20
tests/test_api/test_methods/test_delete_sticker_set.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
from aiogram.methods import DeleteStickerSet, Request
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestDeleteStickerSet:
|
||||
async def test_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(DeleteStickerSet, ok=True, result=True)
|
||||
|
||||
response: bool = await DeleteStickerSet(name="test")
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "deleteStickerSet"
|
||||
assert response == prepare_result.result
|
||||
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(DeleteStickerSet, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.delete_sticker_set(name="test")
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "deleteStickerSet"
|
||||
assert response == prepare_result.result
|
||||
25
tests/test_api/test_methods/test_get_my_description.py
Normal file
25
tests/test_api/test_methods/test_get_my_description.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
from aiogram.methods import GetMyDescription, Request
|
||||
from aiogram.types import BotDescription
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestGetMyDescription:
|
||||
async def test_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(
|
||||
GetMyDescription, ok=True, result=BotDescription(description="Test")
|
||||
)
|
||||
|
||||
response: BotDescription = await GetMyDescription()
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "getMyDescription"
|
||||
assert response == prepare_result.result
|
||||
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(
|
||||
GetMyDescription, ok=True, result=BotDescription(description="Test")
|
||||
)
|
||||
|
||||
response: BotDescription = await bot.get_my_description()
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "getMyDescription"
|
||||
assert response == prepare_result.result
|
||||
25
tests/test_api/test_methods/test_get_my_short_description.py
Normal file
25
tests/test_api/test_methods/test_get_my_short_description.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
from aiogram.methods import GetMyShortDescription, Request
|
||||
from aiogram.types import BotShortDescription
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestGetMyShortDescription:
|
||||
async def test_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(
|
||||
GetMyShortDescription, ok=True, result=BotShortDescription(short_description="Test")
|
||||
)
|
||||
|
||||
response: BotShortDescription = await GetMyShortDescription()
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "getMyShortDescription"
|
||||
assert response == prepare_result.result
|
||||
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(
|
||||
GetMyShortDescription, ok=True, result=BotShortDescription(short_description="Test")
|
||||
)
|
||||
|
||||
response: BotShortDescription = await bot.get_my_short_description()
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "getMyShortDescription"
|
||||
assert response == prepare_result.result
|
||||
|
|
@ -21,7 +21,9 @@ class TestSendVideoNote:
|
|||
)
|
||||
|
||||
response: Message = await SendVideoNote(
|
||||
chat_id=42, video_note="file id", thumb=BufferedInputFile(b"", "file.png")
|
||||
chat_id=42,
|
||||
video_note="file id",
|
||||
thumbnail=BufferedInputFile(b"", "file.png"),
|
||||
)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "sendVideoNote"
|
||||
|
|
@ -42,7 +44,9 @@ class TestSendVideoNote:
|
|||
)
|
||||
|
||||
response: Message = await bot.send_video_note(
|
||||
chat_id=42, video_note="file id", thumb=BufferedInputFile(b"", "file.png")
|
||||
chat_id=42,
|
||||
video_note="file id",
|
||||
thumbnail=BufferedInputFile(b"", "file.png"),
|
||||
)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "sendVideoNote"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
from aiogram.methods import Request, SetCustomEmojiStickerSetThumbnail
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestSetCustomEmojiStickerSetThumbnail:
|
||||
async def test_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(
|
||||
SetCustomEmojiStickerSetThumbnail, ok=True, result=True
|
||||
)
|
||||
|
||||
response: bool = await SetCustomEmojiStickerSetThumbnail(
|
||||
name="test", custom_emoji_id="custom id"
|
||||
)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "setCustomEmojiStickerSetThumbnail"
|
||||
assert response == prepare_result.result
|
||||
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(
|
||||
SetCustomEmojiStickerSetThumbnail, ok=True, result=True
|
||||
)
|
||||
|
||||
response: bool = await bot.set_custom_emoji_sticker_set_thumbnail(
|
||||
name="test", custom_emoji_id="custom id"
|
||||
)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "setCustomEmojiStickerSetThumbnail"
|
||||
assert response == prepare_result.result
|
||||
20
tests/test_api/test_methods/test_set_my_description.py
Normal file
20
tests/test_api/test_methods/test_set_my_description.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
from aiogram.methods import Request, SetMyDescription
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestSetMyDescription:
|
||||
async def test_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetMyDescription, ok=True, result=True)
|
||||
|
||||
response: bool = await SetMyDescription(description="Test")
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "setMyDescription"
|
||||
assert response == prepare_result.result
|
||||
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetMyDescription, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.set_my_description(description="Test")
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "setMyDescription"
|
||||
assert response == prepare_result.result
|
||||
20
tests/test_api/test_methods/test_set_my_short_description.py
Normal file
20
tests/test_api/test_methods/test_set_my_short_description.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
from aiogram.methods import Request, SetMyDescription, SetMyShortDescription
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestSetMyShortDescription:
|
||||
async def test_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetMyShortDescription, ok=True, result=True)
|
||||
|
||||
response: bool = await SetMyShortDescription(short_description="Test")
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "setMyShortDescription"
|
||||
assert response == prepare_result.result
|
||||
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetMyShortDescription, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.set_my_short_description(short_description="Test")
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "setMyShortDescription"
|
||||
assert response == prepare_result.result
|
||||
20
tests/test_api/test_methods/test_set_sticker_emoji_list.py
Normal file
20
tests/test_api/test_methods/test_set_sticker_emoji_list.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
from aiogram.methods import Request, SetStickerEmojiList
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestSetStickerEmojiList:
|
||||
async def test_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetStickerEmojiList, ok=True, result=True)
|
||||
|
||||
response: bool = await SetStickerEmojiList(sticker="sticker id", emoji_list=["X"])
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "setStickerEmojiList"
|
||||
assert response == prepare_result.result
|
||||
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetStickerEmojiList, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.set_sticker_emoji_list(sticker="sticker id", emoji_list=["X"])
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "setStickerEmojiList"
|
||||
assert response == prepare_result.result
|
||||
20
tests/test_api/test_methods/test_set_sticker_keywords.py
Normal file
20
tests/test_api/test_methods/test_set_sticker_keywords.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
from aiogram.methods import Request, SetStickerKeywords
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestSetStickerKeywords:
|
||||
async def test_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetStickerKeywords, ok=True, result=True)
|
||||
|
||||
response: bool = await SetStickerKeywords(sticker="sticker id", keywords=["X"])
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "setStickerKeywords"
|
||||
assert response == prepare_result.result
|
||||
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetStickerKeywords, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.set_sticker_keywords(sticker="sticker id", keywords=["X"])
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "setStickerKeywords"
|
||||
assert response == prepare_result.result
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
from aiogram.methods import Request, SetStickerEmojiList, SetStickerMaskPosition
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestSetStickerEmojiList:
|
||||
async def test_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetStickerMaskPosition, ok=True, result=True)
|
||||
|
||||
response: bool = await SetStickerMaskPosition(sticker="sticker id")
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "setStickerMaskPosition"
|
||||
assert response == prepare_result.result
|
||||
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetStickerMaskPosition, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.set_sticker_mask_position(sticker="sticker id")
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "setStickerMaskPosition"
|
||||
assert response == prepare_result.result
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
from aiogram.methods import Request, SetStickerSetThumb
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestSetStickerSetThumb:
|
||||
async def test_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetStickerSetThumb, ok=True, result=None)
|
||||
|
||||
response: bool = await SetStickerSetThumb(name="test", user_id=42)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "setStickerSetThumb"
|
||||
# assert request.data == {}
|
||||
assert response == prepare_result.result
|
||||
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetStickerSetThumb, ok=True, result=None)
|
||||
|
||||
response: bool = await bot.set_sticker_set_thumb(name="test", user_id=42)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "setStickerSetThumb"
|
||||
# assert request.data == {}
|
||||
assert response == prepare_result.result
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
from aiogram.methods import Request, SetStickerSetThumbnail
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestSetStickerSetThumbnail:
|
||||
async def test_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetStickerSetThumbnail, ok=True, result=None)
|
||||
|
||||
response: bool = await SetStickerSetThumbnail(name="test", user_id=42)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "setStickerSetThumbnail"
|
||||
# assert request.data == {}
|
||||
assert response == prepare_result.result
|
||||
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetStickerSetThumbnail, ok=True, result=None)
|
||||
|
||||
response: bool = await bot.set_sticker_set_thumbnail(name="test", user_id=42)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "setStickerSetThumbnail"
|
||||
# assert request.data == {}
|
||||
assert response == prepare_result.result
|
||||
20
tests/test_api/test_methods/test_set_sticker_set_title.py
Normal file
20
tests/test_api/test_methods/test_set_sticker_set_title.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
from aiogram.methods import Request, SetStickerEmojiList, SetStickerSetTitle
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestSetStickerSetTitle:
|
||||
async def test_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetStickerSetTitle, ok=True, result=True)
|
||||
|
||||
response: bool = await SetStickerSetTitle(name="test", title="Test")
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "setStickerSetTitle"
|
||||
assert response == prepare_result.result
|
||||
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetStickerSetTitle, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.set_sticker_set_title(name="test", title="Test")
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "setStickerSetTitle"
|
||||
assert response == prepare_result.result
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
from aiogram.enums import StickerFormat
|
||||
from aiogram.methods import Request, UploadStickerFile
|
||||
from aiogram.types import BufferedInputFile, File
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
|
@ -10,7 +11,9 @@ class TestUploadStickerFile:
|
|||
)
|
||||
|
||||
response: File = await UploadStickerFile(
|
||||
user_id=42, png_sticker=BufferedInputFile(b"", "file.png")
|
||||
user_id=42,
|
||||
sticker=BufferedInputFile(b"", "file.png"),
|
||||
sticker_format=StickerFormat.STATIC,
|
||||
)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "uploadStickerFile"
|
||||
|
|
@ -22,7 +25,9 @@ class TestUploadStickerFile:
|
|||
)
|
||||
|
||||
response: File = await bot.upload_sticker_file(
|
||||
user_id=42, png_sticker=BufferedInputFile(b"", "file.png")
|
||||
user_id=42,
|
||||
sticker=BufferedInputFile(b"", "file.png"),
|
||||
sticker_format=StickerFormat.STATIC,
|
||||
)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "uploadStickerFile"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue