mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-09 01:15:31 +00:00
Update tests
This commit is contained in:
parent
ffb0cdf88f
commit
d2d4f337fb
16 changed files with 170 additions and 40 deletions
|
|
@ -8,7 +8,9 @@ from tests.mocked_bot import MockedBot
|
|||
class TestGetFile:
|
||||
@pytest.mark.asyncio
|
||||
async def test_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(GetFile, ok=True, result=File(file_id="file id"))
|
||||
prepare_result = bot.add_result_for(
|
||||
GetFile, ok=True, result=File(file_id="file id", file_unique_id="file id")
|
||||
)
|
||||
|
||||
response: File = await GetFile(file_id="file id")
|
||||
request: Request = bot.get_request()
|
||||
|
|
@ -17,7 +19,9 @@ class TestGetFile:
|
|||
|
||||
@pytest.mark.asyncio
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(GetFile, ok=True, result=File(file_id="file id"))
|
||||
prepare_result = bot.add_result_for(
|
||||
GetFile, ok=True, result=File(file_id="file id", file_unique_id="file id")
|
||||
)
|
||||
|
||||
response: File = await bot.get_file(file_id="file id")
|
||||
request: Request = bot.get_request()
|
||||
|
|
|
|||
|
|
@ -16,7 +16,15 @@ class TestGetStickerSet:
|
|||
title="test",
|
||||
is_animated=False,
|
||||
contains_masks=False,
|
||||
stickers=[Sticker(file_id="file if", width=42, height=42, is_animated=False)],
|
||||
stickers=[
|
||||
Sticker(
|
||||
file_id="file if",
|
||||
width=42,
|
||||
height=42,
|
||||
is_animated=False,
|
||||
file_unique_id="file id",
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -35,7 +43,15 @@ class TestGetStickerSet:
|
|||
title="test",
|
||||
is_animated=False,
|
||||
contains_masks=False,
|
||||
stickers=[Sticker(file_id="file if", width=42, height=42, is_animated=False)],
|
||||
stickers=[
|
||||
Sticker(
|
||||
file_id="file if",
|
||||
width=42,
|
||||
height=42,
|
||||
is_animated=False,
|
||||
file_unique_id="file id",
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,10 @@ class TestGetUserProfilePhotos:
|
|||
GetUserProfilePhotos,
|
||||
ok=True,
|
||||
result=UserProfilePhotos(
|
||||
total_count=1, photos=[[PhotoSize(file_id="file_id", width=42, height=42)]]
|
||||
total_count=1,
|
||||
photos=[
|
||||
[PhotoSize(file_id="file_id", width=42, height=42, file_unique_id="file id")]
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -27,7 +30,10 @@ class TestGetUserProfilePhotos:
|
|||
GetUserProfilePhotos,
|
||||
ok=True,
|
||||
result=UserProfilePhotos(
|
||||
total_count=1, photos=[[PhotoSize(file_id="file_id", width=42, height=42)]]
|
||||
total_count=1,
|
||||
photos=[
|
||||
[PhotoSize(file_id="file_id", width=42, height=42, file_unique_id="file id")]
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,9 @@ class TestSendAnimation:
|
|||
result=Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
animation=Animation(file_id="file id", width=42, height=42, duration=0),
|
||||
animation=Animation(
|
||||
file_id="file id", width=42, height=42, duration=0, file_unique_id="file id"
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
)
|
||||
|
|
@ -34,7 +36,9 @@ class TestSendAnimation:
|
|||
result=Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
animation=Animation(file_id="file id", width=42, height=42, duration=0),
|
||||
animation=Animation(
|
||||
file_id="file id", width=42, height=42, duration=0, file_unique_id="file id"
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class TestSendAudio:
|
|||
result=Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
audio=Audio(file_id="file id", duration=42),
|
||||
audio=Audio(file_id="file id", duration=42, file_unique_id="file id"),
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
)
|
||||
|
|
@ -34,7 +34,7 @@ class TestSendAudio:
|
|||
result=Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
audio=Audio(file_id="file id", duration=42),
|
||||
audio=Audio(file_id="file id", duration=42, file_unique_id="file id"),
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class TestSendDocument:
|
|||
result=Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
document=Document(file_id="file id"),
|
||||
document=Document(file_id="file id", file_unique_id="file id"),
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
)
|
||||
|
|
@ -34,7 +34,7 @@ class TestSendDocument:
|
|||
result=Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
document=Document(file_id="file id"),
|
||||
document=Document(file_id="file id", file_unique_id="file id"),
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,9 @@ class TestSendGame:
|
|||
game=Game(
|
||||
title="title",
|
||||
description="description",
|
||||
photo=[PhotoSize(file_id="file id", width=42, height=42)],
|
||||
photo=[
|
||||
PhotoSize(file_id="file id", width=42, height=42, file_unique_id="file id")
|
||||
],
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
|
|
@ -41,7 +43,9 @@ class TestSendGame:
|
|||
game=Game(
|
||||
title="title",
|
||||
description="description",
|
||||
photo=[PhotoSize(file_id="file id", width=42, height=42)],
|
||||
photo=[
|
||||
PhotoSize(file_id="file id", width=42, height=42, file_unique_id="file id")
|
||||
],
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -26,14 +26,22 @@ class TestSendMediaGroup:
|
|||
Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
photo=[PhotoSize(file_id="file id", width=42, height=42)],
|
||||
photo=[
|
||||
PhotoSize(file_id="file id", width=42, height=42, file_unique_id="file id")
|
||||
],
|
||||
media_group_id="media group",
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
Message(
|
||||
message_id=43,
|
||||
date=datetime.datetime.now(),
|
||||
video=Video(file_id="file id", width=42, height=42, duration=0),
|
||||
video=Video(
|
||||
file_id="file id",
|
||||
width=42,
|
||||
height=42,
|
||||
duration=0,
|
||||
file_unique_id="file id",
|
||||
),
|
||||
media_group_id="media group",
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
|
|
@ -60,14 +68,22 @@ class TestSendMediaGroup:
|
|||
Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
photo=[PhotoSize(file_id="file id", width=42, height=42)],
|
||||
photo=[
|
||||
PhotoSize(file_id="file id", width=42, height=42, file_unique_id="file id")
|
||||
],
|
||||
media_group_id="media group",
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
Message(
|
||||
message_id=43,
|
||||
date=datetime.datetime.now(),
|
||||
video=Video(file_id="file id", width=42, height=42, duration=0),
|
||||
video=Video(
|
||||
file_id="file id",
|
||||
width=42,
|
||||
height=42,
|
||||
duration=0,
|
||||
file_unique_id="file id",
|
||||
),
|
||||
media_group_id="media group",
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -16,7 +16,9 @@ class TestSendPhoto:
|
|||
result=Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
photo=[PhotoSize(file_id="file id", width=42, height=42)],
|
||||
photo=[
|
||||
PhotoSize(file_id="file id", width=42, height=42, file_unique_id="file id")
|
||||
],
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
)
|
||||
|
|
@ -34,7 +36,9 @@ class TestSendPhoto:
|
|||
result=Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
photo=[PhotoSize(file_id="file id", width=42, height=42)],
|
||||
photo=[
|
||||
PhotoSize(file_id="file id", width=42, height=42, file_unique_id="file id")
|
||||
],
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,13 @@ class TestSendSticker:
|
|||
result=Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
sticker=Sticker(file_id="file id", width=42, height=42, is_animated=False),
|
||||
sticker=Sticker(
|
||||
file_id="file id",
|
||||
width=42,
|
||||
height=42,
|
||||
is_animated=False,
|
||||
file_unique_id="file id",
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
)
|
||||
|
|
@ -34,7 +40,13 @@ class TestSendSticker:
|
|||
result=Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
sticker=Sticker(file_id="file id", width=42, height=42, is_animated=False),
|
||||
sticker=Sticker(
|
||||
file_id="file id",
|
||||
width=42,
|
||||
height=42,
|
||||
is_animated=False,
|
||||
file_unique_id="file id",
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,9 @@ class TestSendVideo:
|
|||
result=Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
video=Video(file_id="file id", width=42, height=42, duration=0),
|
||||
video=Video(
|
||||
file_id="file id", width=42, height=42, duration=0, file_unique_id="file id"
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
)
|
||||
|
|
@ -34,7 +36,9 @@ class TestSendVideo:
|
|||
result=Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
video=Video(file_id="file id", width=42, height=42, duration=0),
|
||||
video=Video(
|
||||
file_id="file id", width=42, height=42, duration=0, file_unique_id="file id"
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,9 @@ class TestSendVideoNote:
|
|||
result=Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
video_note=VideoNote(file_id="file id", length=0, duration=0),
|
||||
video_note=VideoNote(
|
||||
file_id="file id", length=0, duration=0, file_unique_id="file id"
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
)
|
||||
|
|
@ -36,7 +38,9 @@ class TestSendVideoNote:
|
|||
result=Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
video_note=VideoNote(file_id="file id", length=0, duration=0),
|
||||
video_note=VideoNote(
|
||||
file_id="file id", length=0, duration=0, file_unique_id="file id"
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class TestSendVoice:
|
|||
result=Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
voice=Voice(file_id="file id", duration=0),
|
||||
voice=Voice(file_id="file id", duration=0, file_unique_id="file id"),
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
)
|
||||
|
|
@ -34,7 +34,7 @@ class TestSendVoice:
|
|||
result=Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
voice=Voice(file_id="file id", duration=0),
|
||||
voice=Voice(file_id="file id", duration=0, file_unique_id="file id"),
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
import pytest
|
||||
|
||||
from aiogram.api.methods import Request, SetChatAdministratorCustomTitle, SetChatTitle
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestSetChatTitle:
|
||||
@pytest.mark.asyncio
|
||||
async def test_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetChatAdministratorCustomTitle, ok=True, result=True)
|
||||
|
||||
response: bool = await SetChatAdministratorCustomTitle(
|
||||
chat_id=-42, user_id=42, custom_title="test chat"
|
||||
)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "setChatAdministratorCustomTitle"
|
||||
assert response == prepare_result.result
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetChatAdministratorCustomTitle, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.set_chat_administrator_custom_title(
|
||||
chat_id=-42, user_id=42, custom_title="test chat"
|
||||
)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "setChatAdministratorCustomTitle"
|
||||
assert response == prepare_result.result
|
||||
|
|
@ -9,7 +9,7 @@ class TestUploadStickerFile:
|
|||
@pytest.mark.asyncio
|
||||
async def test_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(
|
||||
UploadStickerFile, ok=True, result=File(file_id="file id")
|
||||
UploadStickerFile, ok=True, result=File(file_id="file id", file_unique_id="file id")
|
||||
)
|
||||
|
||||
response: File = await UploadStickerFile(
|
||||
|
|
@ -22,7 +22,7 @@ class TestUploadStickerFile:
|
|||
@pytest.mark.asyncio
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(
|
||||
UploadStickerFile, ok=True, result=File(file_id="file id")
|
||||
UploadStickerFile, ok=True, result=File(file_id="file id", file_unique_id="file id")
|
||||
)
|
||||
|
||||
response: File = await bot.upload_sticker_file(
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class TestMessage:
|
|||
Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
audio=Audio(file_id="file id", duration=42),
|
||||
audio=Audio(file_id="file id", file_unique_id="file id", duration=42),
|
||||
chat=Chat(id=42, type="private"),
|
||||
from_user=User(id=42, is_bot=False, first_name="Test"),
|
||||
),
|
||||
|
|
@ -55,7 +55,13 @@ class TestMessage:
|
|||
Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
animation=Animation(file_id="file id", width=42, height=42, duration=0),
|
||||
animation=Animation(
|
||||
file_id="file id",
|
||||
file_unique_id="file id",
|
||||
width=42,
|
||||
height=42,
|
||||
duration=0,
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
from_user=User(id=42, is_bot=False, first_name="Test"),
|
||||
),
|
||||
|
|
@ -65,7 +71,7 @@ class TestMessage:
|
|||
Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
document=Document(file_id="file id"),
|
||||
document=Document(file_id="file id", file_unique_id="file id"),
|
||||
chat=Chat(id=42, type="private"),
|
||||
from_user=User(id=42, is_bot=False, first_name="Test"),
|
||||
),
|
||||
|
|
@ -78,7 +84,11 @@ class TestMessage:
|
|||
game=Game(
|
||||
title="title",
|
||||
description="description",
|
||||
photo=[PhotoSize(file_id="file id", width=42, height=42)],
|
||||
photo=[
|
||||
PhotoSize(
|
||||
file_id="file id", file_unique_id="file id", width=42, height=42
|
||||
)
|
||||
],
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
from_user=User(id=42, is_bot=False, first_name="Test"),
|
||||
|
|
@ -89,7 +99,9 @@ class TestMessage:
|
|||
Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
photo=[PhotoSize(file_id="file id", width=42, height=42)],
|
||||
photo=[
|
||||
PhotoSize(file_id="file id", file_unique_id="file id", width=42, height=42)
|
||||
],
|
||||
chat=Chat(id=42, type="private"),
|
||||
from_user=User(id=42, is_bot=False, first_name="Test"),
|
||||
),
|
||||
|
|
@ -99,7 +111,13 @@ class TestMessage:
|
|||
Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
sticker=Sticker(file_id="file id", width=42, height=42, is_animated=False),
|
||||
sticker=Sticker(
|
||||
file_id="file id",
|
||||
file_unique_id="file id",
|
||||
width=42,
|
||||
height=42,
|
||||
is_animated=False,
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
from_user=User(id=42, is_bot=False, first_name="Test"),
|
||||
),
|
||||
|
|
@ -109,7 +127,13 @@ class TestMessage:
|
|||
Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
video=Video(file_id="file id", width=42, height=42, duration=0),
|
||||
video=Video(
|
||||
file_id="file id",
|
||||
file_unique_id="file id",
|
||||
width=42,
|
||||
height=42,
|
||||
duration=0,
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
from_user=User(id=42, is_bot=False, first_name="Test"),
|
||||
),
|
||||
|
|
@ -119,7 +143,9 @@ class TestMessage:
|
|||
Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
video_note=VideoNote(file_id="file id", length=0, duration=0),
|
||||
video_note=VideoNote(
|
||||
file_id="file id", file_unique_id="file id", length=0, duration=0
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
from_user=User(id=42, is_bot=False, first_name="Test"),
|
||||
),
|
||||
|
|
@ -129,7 +155,7 @@ class TestMessage:
|
|||
Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
voice=Voice(file_id="file id", duration=0),
|
||||
voice=Voice(file_id="file id", file_unique_id="file id", duration=0),
|
||||
chat=Chat(id=42, type="private"),
|
||||
from_user=User(id=42, is_bot=False, first_name="Test"),
|
||||
),
|
||||
|
|
@ -282,7 +308,9 @@ class TestMessage:
|
|||
Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
new_chat_photo=[PhotoSize(file_id="file id", width=42, height=42)],
|
||||
new_chat_photo=[
|
||||
PhotoSize(file_id="file id", file_unique_id="file id", width=42, height=42)
|
||||
],
|
||||
chat=Chat(id=42, type="private"),
|
||||
from_user=User(id=42, is_bot=False, first_name="Test"),
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue