aiogram/tests/test_api/test_methods/test_upload_sticker_file.py

33 lines
1.1 KiB
Python
Raw Normal View History

2019-11-18 22:22:46 +02:00
import pytest
from aiogram.api.methods import Request, UploadStickerFile
2019-11-19 22:44:12 +02:00
from aiogram.api.types import BufferedInputFile, File
2019-11-18 22:22:46 +02:00
from tests.mocked_bot import MockedBot
class TestUploadStickerFile:
@pytest.mark.asyncio
async def test_method(self, bot: MockedBot):
2019-11-19 22:44:12 +02:00
prepare_result = bot.add_result_for(
UploadStickerFile, ok=True, result=File(file_id="file id")
)
2019-11-18 22:22:46 +02:00
2019-11-19 22:44:12 +02:00
response: File = await UploadStickerFile(
user_id=42, png_sticker=BufferedInputFile(b"", "file.png")
)
2019-11-18 22:22:46 +02:00
request: Request = bot.get_request()
assert request.method == "uploadStickerFile"
assert response == prepare_result.result
@pytest.mark.asyncio
async def test_bot_method(self, bot: MockedBot):
2019-11-19 22:44:12 +02:00
prepare_result = bot.add_result_for(
UploadStickerFile, ok=True, result=File(file_id="file id")
)
2019-11-18 22:22:46 +02:00
2019-11-19 22:44:12 +02:00
response: File = await bot.upload_sticker_file(
user_id=42, png_sticker=BufferedInputFile(b"", "file.png")
)
2019-11-18 22:22:46 +02:00
request: Request = bot.get_request()
assert request.method == "uploadStickerFile"
assert response == prepare_result.result