mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 10:11:52 +00:00
Update tests for all methods
This commit is contained in:
parent
33c661d732
commit
23abe35212
27 changed files with 428 additions and 189 deletions
|
|
@ -1,31 +1,85 @@
|
|||
import datetime
|
||||
from typing import List
|
||||
|
||||
import pytest
|
||||
|
||||
from aiogram.api.methods import Request, SendMediaGroup
|
||||
from aiogram.api.types import Message, InputMediaPhoto
|
||||
from aiogram.api.types import (
|
||||
BufferedInputFile,
|
||||
Chat,
|
||||
InputMediaPhoto,
|
||||
InputMediaVideo,
|
||||
Message,
|
||||
PhotoSize,
|
||||
Video,
|
||||
)
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
@pytest.mark.skip
|
||||
class TestSendMediaGroup:
|
||||
@pytest.mark.asyncio
|
||||
async def test_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SendMediaGroup, ok=True, result=...)
|
||||
prepare_result = bot.add_result_for(
|
||||
SendMediaGroup,
|
||||
ok=True,
|
||||
result=[
|
||||
Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
photo=[PhotoSize(file_id="file id", width=42, height=42)],
|
||||
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),
|
||||
media_group_id="media group",
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
response: List[Message] = await SendMediaGroup(
|
||||
chat_id=42, media=[InputMediaPhoto(media="file id")]
|
||||
chat_id=42,
|
||||
media=[
|
||||
InputMediaPhoto(media="file id"),
|
||||
InputMediaVideo(media=BufferedInputFile(b"", "video.mp4")),
|
||||
],
|
||||
)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "sendMediaGroup"
|
||||
assert response == prepare_result.result
|
||||
|
||||
#
|
||||
# @pytest.mark.asyncio
|
||||
# async def test_bot_method(self, bot: MockedBot):
|
||||
# prepare_result = bot.add_result_for(SendMediaGroup, ok=True, result=None)
|
||||
#
|
||||
# response: List[Message] = await bot.send_media_group(chat_id=..., media=...)
|
||||
# request: Request = bot.get_request()
|
||||
# assert request.method == "sendMediaGroup"
|
||||
# assert response == prepare_result.result
|
||||
@pytest.mark.asyncio
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(
|
||||
SendMediaGroup,
|
||||
ok=True,
|
||||
result=[
|
||||
Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
photo=[PhotoSize(file_id="file id", width=42, height=42)],
|
||||
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),
|
||||
media_group_id="media group",
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
response: List[Message] = await bot.send_media_group(
|
||||
chat_id=42,
|
||||
media=[
|
||||
InputMediaPhoto(media="file id"),
|
||||
InputMediaVideo(media=BufferedInputFile(b"", "video.mp4")),
|
||||
],
|
||||
)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "sendMediaGroup"
|
||||
assert response == prepare_result.result
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue