aiogram/tests/test_api/test_methods/test_send_audio.py
Alex Root Junior 83d6ab48c5
Backport and improvements (#601)
* Backport RedisStorage, deep-linking
* Allow prereleases for aioredis
* Bump dependencies
* Correctly skip Redis tests on Windows
* Reformat tests code and bump Makefile
2021-06-15 01:45:31 +03:00

45 lines
1.4 KiB
Python

import datetime
import pytest
from aiogram.methods import Request, SendAudio
from aiogram.types import Audio, Chat, Message
from tests.mocked_bot import MockedBot
class TestSendAudio:
@pytest.mark.asyncio
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendAudio,
ok=True,
result=Message(
message_id=42,
date=datetime.datetime.now(),
audio=Audio(file_id="file id", duration=42, file_unique_id="file id"),
chat=Chat(id=42, type="private"),
),
)
response: Message = await SendAudio(chat_id=42, audio="file id")
request: Request = bot.get_request()
assert request.method == "sendAudio"
assert response == prepare_result.result
@pytest.mark.asyncio
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendAudio,
ok=True,
result=Message(
message_id=42,
date=datetime.datetime.now(),
audio=Audio(file_id="file id", duration=42, file_unique_id="file id"),
chat=Chat(id=42, type="private"),
),
)
response: Message = await bot.send_audio(chat_id=42, audio="file id")
request: Request = bot.get_request()
assert request.method == "sendAudio"
assert response == prepare_result.result