diff --git a/tests/test_api/test_methods/test_send_document.py b/tests/test_api/test_methods/test_send_document.py index c91ebfa2..aebccc1f 100644 --- a/tests/test_api/test_methods/test_send_document.py +++ b/tests/test_api/test_methods/test_send_document.py @@ -1,27 +1,45 @@ +import datetime + import pytest from aiogram.api.methods import Request, SendDocument +from aiogram.api.types import Chat, Document, Message from tests.mocked_bot import MockedBot -@pytest.mark.skip class TestSendDocument: @pytest.mark.asyncio async def test_method(self, bot: MockedBot): - prepare_result = bot.add_result_for(SendDocument, ok=True, result=None) + prepare_result = bot.add_result_for( + SendDocument, + ok=True, + result=Message( + message_id=42, + date=datetime.datetime.now(), + document=Document(file_id="file id"), + chat=Chat(id=42, type="private"), + ), + ) - response: Message = await SendDocument(chat_id=..., document=...) + response: Message = await SendDocument(chat_id=42, document="file id") request: Request = bot.get_request() assert request.method == "sendDocument" - # assert request.data == {} assert response == prepare_result.result @pytest.mark.asyncio async def test_bot_method(self, bot: MockedBot): - prepare_result = bot.add_result_for(SendDocument, ok=True, result=None) + prepare_result = bot.add_result_for( + SendDocument, + ok=True, + result=Message( + message_id=42, + date=datetime.datetime.now(), + document=Document(file_id="file id"), + chat=Chat(id=42, type="private"), + ), + ) - response: Message = await bot.send_document(chat_id=..., document=...) + response: Message = await bot.send_document(chat_id=42, document="file id") request: Request = bot.get_request() assert request.method == "sendDocument" - # assert request.data == {} assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_send_game.py b/tests/test_api/test_methods/test_send_game.py index b2a6b114..a26a1cc1 100644 --- a/tests/test_api/test_methods/test_send_game.py +++ b/tests/test_api/test_methods/test_send_game.py @@ -1,27 +1,53 @@ +import datetime + import pytest from aiogram.api.methods import Request, SendGame +from aiogram.api.types import Chat, Game, Message, PhotoSize from tests.mocked_bot import MockedBot -@pytest.mark.skip class TestSendGame: @pytest.mark.asyncio async def test_method(self, bot: MockedBot): - prepare_result = bot.add_result_for(SendGame, ok=True, result=None) + prepare_result = bot.add_result_for( + SendGame, + ok=True, + result=Message( + message_id=42, + date=datetime.datetime.now(), + game=Game( + title="title", + description="description", + photo=[PhotoSize(file_id="file id", width=42, height=42)], + ), + chat=Chat(id=42, type="private"), + ), + ) - response: Message = await SendGame(chat_id=..., game_short_name=...) + response: Message = await SendGame(chat_id=42, game_short_name="game") request: Request = bot.get_request() assert request.method == "sendGame" - # assert request.data == {} assert response == prepare_result.result @pytest.mark.asyncio async def test_bot_method(self, bot: MockedBot): - prepare_result = bot.add_result_for(SendGame, ok=True, result=None) + prepare_result = bot.add_result_for( + SendGame, + ok=True, + result=Message( + message_id=42, + date=datetime.datetime.now(), + game=Game( + title="title", + description="description", + photo=[PhotoSize(file_id="file id", width=42, height=42)], + ), + chat=Chat(id=42, type="private"), + ), + ) - response: Message = await bot.send_game(chat_id=..., game_short_name=...) + response: Message = await bot.send_game(chat_id=42, game_short_name="game") request: Request = bot.get_request() assert request.method == "sendGame" - # assert request.data == {} assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_send_invoice.py b/tests/test_api/test_methods/test_send_invoice.py index b69272bc..eb6c83b6 100644 --- a/tests/test_api/test_methods/test_send_invoice.py +++ b/tests/test_api/test_methods/test_send_invoice.py @@ -1,45 +1,75 @@ +import datetime + import pytest from aiogram.api.methods import Request, SendInvoice +from aiogram.api.types import Chat, Invoice, LabeledPrice, Message from tests.mocked_bot import MockedBot -@pytest.mark.skip class TestSendInvoice: @pytest.mark.asyncio async def test_method(self, bot: MockedBot): - prepare_result = bot.add_result_for(SendInvoice, ok=True, result=None) + prepare_result = bot.add_result_for( + SendInvoice, + ok=True, + result=Message( + message_id=42, + date=datetime.datetime.now(), + invoice=Invoice( + title="test", + description="test", + start_parameter="brilliant", + currency="BTC", + total_amount=1, + ), + chat=Chat(id=42, type="private"), + ), + ) response: Message = await SendInvoice( - chat_id=..., - title=..., - description=..., - payload=..., - provider_token=..., - start_parameter=..., - currency=..., - prices=..., + chat_id=42, + title="test", + description="test", + payload="payload", + provider_token="TEST:token", + start_parameter="brilliant", + currency="BTC", + prices=[LabeledPrice(amount=1, label="test")], ) request: Request = bot.get_request() assert request.method == "sendInvoice" - # assert request.data == {} assert response == prepare_result.result @pytest.mark.asyncio async def test_bot_method(self, bot: MockedBot): - prepare_result = bot.add_result_for(SendInvoice, ok=True, result=None) + prepare_result = bot.add_result_for( + SendInvoice, + ok=True, + result=Message( + message_id=42, + date=datetime.datetime.now(), + invoice=Invoice( + title="test", + description="test", + start_parameter="brilliant", + currency="BTC", + total_amount=1, + ), + chat=Chat(id=42, type="private"), + ), + ) response: Message = await bot.send_invoice( - chat_id=..., - title=..., - description=..., - payload=..., - provider_token=..., - start_parameter=..., - currency=..., - prices=..., + chat_id=42, + title="test", + description="test", + payload="payload", + provider_token="TEST:token", + start_parameter="brilliant", + currency="BTC", + prices=[LabeledPrice(amount=1, label="test")], ) request: Request = bot.get_request() assert request.method == "sendInvoice" - # assert request.data == {} assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_send_location.py b/tests/test_api/test_methods/test_send_location.py index 33a2fda6..d833733c 100644 --- a/tests/test_api/test_methods/test_send_location.py +++ b/tests/test_api/test_methods/test_send_location.py @@ -1,27 +1,45 @@ +import datetime + import pytest from aiogram.api.methods import Request, SendLocation +from aiogram.api.types import Chat, Location, Message from tests.mocked_bot import MockedBot -@pytest.mark.skip class TestSendLocation: @pytest.mark.asyncio async def test_method(self, bot: MockedBot): - prepare_result = bot.add_result_for(SendLocation, ok=True, result=None) + prepare_result = bot.add_result_for( + SendLocation, + ok=True, + result=Message( + message_id=42, + date=datetime.datetime.now(), + location=Location(longitude=3.14, latitude=3.14), + chat=Chat(id=42, type="private"), + ), + ) - response: Message = await SendLocation(chat_id=..., latitude=..., longitude=...) + response: Message = await SendLocation(chat_id=42, latitude=3.14, longitude=3.14) request: Request = bot.get_request() assert request.method == "sendLocation" - # assert request.data == {} assert response == prepare_result.result @pytest.mark.asyncio async def test_bot_method(self, bot: MockedBot): - prepare_result = bot.add_result_for(SendLocation, ok=True, result=None) + prepare_result = bot.add_result_for( + SendLocation, + ok=True, + result=Message( + message_id=42, + date=datetime.datetime.now(), + location=Location(longitude=3.14, latitude=3.14), + chat=Chat(id=42, type="private"), + ), + ) - response: Message = await bot.send_location(chat_id=..., latitude=..., longitude=...) + response: Message = await bot.send_location(chat_id=42, latitude=3.14, longitude=3.14) request: Request = bot.get_request() assert request.method == "sendLocation" - # assert request.data == {} assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_send_media_group.py b/tests/test_api/test_methods/test_send_media_group.py index 7983260a..93d58b36 100644 --- a/tests/test_api/test_methods/test_send_media_group.py +++ b/tests/test_api/test_methods/test_send_media_group.py @@ -1,6 +1,9 @@ +from typing import List + import pytest from aiogram.api.methods import Request, SendMediaGroup +from aiogram.api.types import Message, InputMediaPhoto from tests.mocked_bot import MockedBot @@ -8,20 +11,21 @@ from tests.mocked_bot import MockedBot class TestSendMediaGroup: @pytest.mark.asyncio async def test_method(self, bot: MockedBot): - prepare_result = bot.add_result_for(SendMediaGroup, ok=True, result=None) + prepare_result = bot.add_result_for(SendMediaGroup, ok=True, result=...) - response: List[Message] = await SendMediaGroup(chat_id=..., media=...) + response: List[Message] = await SendMediaGroup( + chat_id=42, media=[InputMediaPhoto(media="file id")] + ) request: Request = bot.get_request() assert request.method == "sendMediaGroup" - # assert request.data == {} 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 request.data == {} - 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