diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 2b9341bf..53117cca 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -19,34 +19,29 @@ jobs: - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install poetry + python -m pip install --upgrade pip poetry poetry install - mkdir -p reports/tests + mkdir -p reports - name: Lint code run: | - poetry run flake8 --format=html --htmldir=reports/flake8 aiogram test - poetry run mypy aiogram tests --html-report reports/typechecking + make flake8-report + make mypy-report - name: Run tests run: | - poetry run pytest --cov=aiogram --cov-config .coveragerc --html=reports/tests/index.html tests/ - poetry run coverage html -d reports/coverage + make test-coverage - name: Build docs run: | - poetry run mkdocs build + make docs + make docs-copy-reports - name: Build package run: | poetry build - mkdir -p site/simple/aiogram - mv dist/* site/simple/aiogram - - - name: Move coverage report - run: | - mv reports site + mkdir -p site/simple + mv dist site/simple/aiogram - name: FTP-Deploy-2038 uses: SamKirkland/FTP-Deploy-Action@2.0.0 diff --git a/aiogram/api/methods/base.py b/aiogram/api/methods/base.py index 28186724..ee475913 100644 --- a/aiogram/api/methods/base.py +++ b/aiogram/api/methods/base.py @@ -54,6 +54,8 @@ class TelegramMethod(abc.ABC, BaseModel, Generic[T]): return Response[self.__returning__](**data) # type: ignore def prepare_file(self, name: str, value: Any, data: Dict[str, Any], files: Dict[str, Any]): + if not value: + return if name == "thumb": tag = secrets.token_urlsafe(10) files[tag] = value diff --git a/tests/mocked_bot.py b/tests/mocked_bot.py index 9a1a1609..77da88bc 100644 --- a/tests/mocked_bot.py +++ b/tests/mocked_bot.py @@ -41,7 +41,7 @@ class MockedBot(Bot): self, method: Type[TelegramMethod[T]], ok: bool, - result: Optional[T] = None, + result: T = None, description: Optional[str] = None, error_code: Optional[int] = None, migrate_to_chat_id: Optional[int] = None, diff --git a/tests/test_api/test_methods/test_add_sticker_to_set.py b/tests/test_api/test_methods/test_add_sticker_to_set.py new file mode 100644 index 00000000..8c91423e --- /dev/null +++ b/tests/test_api/test_methods/test_add_sticker_to_set.py @@ -0,0 +1,28 @@ +import pytest + +from aiogram.api.methods import AddStickerToSet, Request +from tests.mocked_bot import MockedBot + + +class TestAddStickerToSet: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(AddStickerToSet, ok=True, result=True) + + response: bool = await AddStickerToSet( + user_id=42, name="test stickers pack", png_sticker="file id", emojis=":)" + ) + request: Request = bot.get_request() + assert request.method == "addStickerToSet" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(AddStickerToSet, ok=True, result=True) + + response: bool = await bot.add_sticker_to_set( + user_id=42, name="test stickers pack", png_sticker="file id", emojis=":)" + ) + request: Request = bot.get_request() + assert request.method == "addStickerToSet" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_answer_callback_query.py b/tests/test_api/test_methods/test_answer_callback_query.py new file mode 100644 index 00000000..d2617b38 --- /dev/null +++ b/tests/test_api/test_methods/test_answer_callback_query.py @@ -0,0 +1,24 @@ +import pytest + +from aiogram.api.methods import AnswerCallbackQuery, Request +from tests.mocked_bot import MockedBot + + +class TestAnswerCallbackQuery: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(AnswerCallbackQuery, ok=True, result=True) + + response: bool = await AnswerCallbackQuery(callback_query_id="cq id", text="OK") + request: Request = bot.get_request() + assert request.method == "answerCallbackQuery" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(AnswerCallbackQuery, ok=True, result=True) + + response: bool = await bot.answer_callback_query(callback_query_id="cq id", text="OK") + request: Request = bot.get_request() + assert request.method == "answerCallbackQuery" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_answer_inline_query.py b/tests/test_api/test_methods/test_answer_inline_query.py new file mode 100644 index 00000000..e802a2a8 --- /dev/null +++ b/tests/test_api/test_methods/test_answer_inline_query.py @@ -0,0 +1,29 @@ +import pytest + +from aiogram.api.methods import AnswerInlineQuery, Request +from aiogram.api.types import InlineQueryResult +from tests.mocked_bot import MockedBot + + +class TestAnswerInlineQuery: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(AnswerInlineQuery, ok=True, result=True) + + response: bool = await AnswerInlineQuery( + inline_query_id="query id", results=[InlineQueryResult()] + ) + request: Request = bot.get_request() + assert request.method == "answerInlineQuery" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(AnswerInlineQuery, ok=True, result=True) + + response: bool = await bot.answer_inline_query( + inline_query_id="query id", results=[InlineQueryResult()] + ) + request: Request = bot.get_request() + assert request.method == "answerInlineQuery" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_answer_pre_checkout_query.py b/tests/test_api/test_methods/test_answer_pre_checkout_query.py new file mode 100644 index 00000000..0d49e8e5 --- /dev/null +++ b/tests/test_api/test_methods/test_answer_pre_checkout_query.py @@ -0,0 +1,26 @@ +import pytest + +from aiogram.api.methods import AnswerPreCheckoutQuery, Request +from tests.mocked_bot import MockedBot + + +class TestAnswerPreCheckoutQuery: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(AnswerPreCheckoutQuery, ok=True, result=True) + + response: bool = await AnswerPreCheckoutQuery(pre_checkout_query_id="query id", ok=True) + request: Request = bot.get_request() + assert request.method == "answerPreCheckoutQuery" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(AnswerPreCheckoutQuery, ok=True, result=True) + + response: bool = await bot.answer_pre_checkout_query( + pre_checkout_query_id="query id", ok=True + ) + request: Request = bot.get_request() + assert request.method == "answerPreCheckoutQuery" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_answer_shipping_query.py b/tests/test_api/test_methods/test_answer_shipping_query.py new file mode 100644 index 00000000..9a0f1a9e --- /dev/null +++ b/tests/test_api/test_methods/test_answer_shipping_query.py @@ -0,0 +1,24 @@ +import pytest + +from aiogram.api.methods import AnswerShippingQuery, Request +from tests.mocked_bot import MockedBot + + +class TestAnswerShippingQuery: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(AnswerShippingQuery, ok=True, result=True) + + response: bool = await AnswerShippingQuery(shipping_query_id="query id", ok=True) + request: Request = bot.get_request() + assert request.method == "answerShippingQuery" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(AnswerShippingQuery, ok=True, result=True) + + response: bool = await bot.answer_shipping_query(shipping_query_id="query id", ok=True) + request: Request = bot.get_request() + assert request.method == "answerShippingQuery" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_create_new_sticker_set.py b/tests/test_api/test_methods/test_create_new_sticker_set.py new file mode 100644 index 00000000..17b8b049 --- /dev/null +++ b/tests/test_api/test_methods/test_create_new_sticker_set.py @@ -0,0 +1,28 @@ +import pytest + +from aiogram.api.methods import CreateNewStickerSet, Request +from tests.mocked_bot import MockedBot + + +class TestCreateNewStickerSet: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(CreateNewStickerSet, ok=True, result=True) + + response: bool = await CreateNewStickerSet( + user_id=42, name="name", title="title", png_sticker="file id", emojis=":)" + ) + request: Request = bot.get_request() + assert request.method == "createNewStickerSet" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(CreateNewStickerSet, ok=True, result=True) + + response: bool = await bot.create_new_sticker_set( + user_id=42, name="name", title="title", png_sticker="file id", emojis=":)" + ) + request: Request = bot.get_request() + assert request.method == "createNewStickerSet" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_delete_chat_photo.py b/tests/test_api/test_methods/test_delete_chat_photo.py new file mode 100644 index 00000000..293a7b0e --- /dev/null +++ b/tests/test_api/test_methods/test_delete_chat_photo.py @@ -0,0 +1,24 @@ +import pytest + +from aiogram.api.methods import DeleteChatPhoto, Request +from tests.mocked_bot import MockedBot + + +class TestDeleteChatPhoto: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(DeleteChatPhoto, ok=True, result=True) + + response: bool = await DeleteChatPhoto(chat_id=42) + request: Request = bot.get_request() + assert request.method == "deleteChatPhoto" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(DeleteChatPhoto, ok=True, result=True) + + response: bool = await bot.delete_chat_photo(chat_id=42) + request: Request = bot.get_request() + assert request.method == "deleteChatPhoto" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_delete_chat_sticker_set.py b/tests/test_api/test_methods/test_delete_chat_sticker_set.py new file mode 100644 index 00000000..618903ec --- /dev/null +++ b/tests/test_api/test_methods/test_delete_chat_sticker_set.py @@ -0,0 +1,24 @@ +import pytest + +from aiogram.api.methods import DeleteChatStickerSet, Request +from tests.mocked_bot import MockedBot + + +class TestDeleteChatStickerSet: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(DeleteChatStickerSet, ok=True, result=True) + + response: bool = await DeleteChatStickerSet(chat_id=42) + request: Request = bot.get_request() + assert request.method == "deleteChatStickerSet" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(DeleteChatStickerSet, ok=True, result=True) + + response: bool = await bot.delete_chat_sticker_set(chat_id=42) + request: Request = bot.get_request() + assert request.method == "deleteChatStickerSet" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_delete_message.py b/tests/test_api/test_methods/test_delete_message.py new file mode 100644 index 00000000..0b510abd --- /dev/null +++ b/tests/test_api/test_methods/test_delete_message.py @@ -0,0 +1,24 @@ +import pytest + +from aiogram.api.methods import DeleteMessage, Request +from tests.mocked_bot import MockedBot + + +class TestDeleteMessage: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(DeleteMessage, ok=True, result=True) + + response: bool = await DeleteMessage(chat_id=42, message_id=42) + request: Request = bot.get_request() + assert request.method == "deleteMessage" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(DeleteMessage, ok=True, result=True) + + response: bool = await bot.delete_message(chat_id=42, message_id=42) + request: Request = bot.get_request() + assert request.method == "deleteMessage" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_delete_sticker_from_set.py b/tests/test_api/test_methods/test_delete_sticker_from_set.py new file mode 100644 index 00000000..8b344225 --- /dev/null +++ b/tests/test_api/test_methods/test_delete_sticker_from_set.py @@ -0,0 +1,24 @@ +import pytest + +from aiogram.api.methods import DeleteStickerFromSet, Request +from tests.mocked_bot import MockedBot + + +class TestDeleteStickerFromSet: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(DeleteStickerFromSet, ok=True, result=True) + + response: bool = await DeleteStickerFromSet(sticker="sticker id") + request: Request = bot.get_request() + assert request.method == "deleteStickerFromSet" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(DeleteStickerFromSet, ok=True, result=True) + + response: bool = await bot.delete_sticker_from_set(sticker="sticker id") + request: Request = bot.get_request() + assert request.method == "deleteStickerFromSet" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_delete_webhook.py b/tests/test_api/test_methods/test_delete_webhook.py new file mode 100644 index 00000000..22c4d5c9 --- /dev/null +++ b/tests/test_api/test_methods/test_delete_webhook.py @@ -0,0 +1,24 @@ +import pytest + +from aiogram.api.methods import DeleteWebhook, Request +from tests.mocked_bot import MockedBot + + +class TestDeleteWebhook: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(DeleteWebhook, ok=True, result=True) + + response: bool = await DeleteWebhook() + request: Request = bot.get_request() + assert request.method == "deleteWebhook" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(DeleteWebhook, ok=True, result=True) + + response: bool = await bot.delete_webhook() + request: Request = bot.get_request() + assert request.method == "deleteWebhook" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_edit_message_caption.py b/tests/test_api/test_methods/test_edit_message_caption.py new file mode 100644 index 00000000..50fcf838 --- /dev/null +++ b/tests/test_api/test_methods/test_edit_message_caption.py @@ -0,0 +1,46 @@ +import datetime +from typing import Union + +import pytest + +from aiogram.api.methods import EditMessageCaption, Request +from aiogram.api.types import Chat, Message +from tests.mocked_bot import MockedBot + + +class TestEditMessageCaption: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for( + EditMessageCaption, + ok=True, + result=Message( + message_id=42, + date=datetime.datetime.now(), + text="text", + chat=Chat(id=42, type="private"), + ), + ) + + response: Union[Message, bool] = await EditMessageCaption() + request: Request = bot.get_request() + assert request.method == "editMessageCaption" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for( + EditMessageCaption, + ok=True, + result=Message( + message_id=42, + date=datetime.datetime.now(), + text="text", + chat=Chat(id=42, type="private"), + ), + ) + + response: Union[Message, bool] = await bot.edit_message_caption() + request: Request = bot.get_request() + assert request.method == "editMessageCaption" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_edit_message_live_location.py b/tests/test_api/test_methods/test_edit_message_live_location.py new file mode 100644 index 00000000..96e566ac --- /dev/null +++ b/tests/test_api/test_methods/test_edit_message_live_location.py @@ -0,0 +1,31 @@ +from typing import Union + +import pytest + +from aiogram.api.methods import EditMessageLiveLocation, Request +from aiogram.api.types import Message +from tests.mocked_bot import MockedBot + + +class TestEditMessageLiveLocation: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(EditMessageLiveLocation, ok=True, result=True) + + response: Union[Message, bool] = await EditMessageLiveLocation( + latitude=3.141592, longitude=3.141592 + ) + request: Request = bot.get_request() + assert request.method == "editMessageLiveLocation" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(EditMessageLiveLocation, ok=True, result=True) + + response: Union[Message, bool] = await bot.edit_message_live_location( + latitude=3.141592, longitude=3.141592 + ) + request: Request = bot.get_request() + assert request.method == "editMessageLiveLocation" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_edit_message_media.py b/tests/test_api/test_methods/test_edit_message_media.py new file mode 100644 index 00000000..11f94be4 --- /dev/null +++ b/tests/test_api/test_methods/test_edit_message_media.py @@ -0,0 +1,27 @@ +from typing import Union + +import pytest + +from aiogram.api.methods import EditMessageMedia, Request +from aiogram.api.types import InputMedia, Message +from tests.mocked_bot import MockedBot + + +class TestEditMessageMedia: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(EditMessageMedia, ok=True, result=True) + + response: Union[Message, bool] = await EditMessageMedia(media=InputMedia()) + request: Request = bot.get_request() + assert request.method == "editMessageMedia" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(EditMessageMedia, ok=True, result=True) + + response: Union[Message, bool] = await bot.edit_message_media(media=InputMedia()) + request: Request = bot.get_request() + assert request.method == "editMessageMedia" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_edit_message_reply_markup.py b/tests/test_api/test_methods/test_edit_message_reply_markup.py new file mode 100644 index 00000000..48f69e2a --- /dev/null +++ b/tests/test_api/test_methods/test_edit_message_reply_markup.py @@ -0,0 +1,43 @@ +from typing import Union + +import pytest + +from aiogram.api.methods import EditMessageReplyMarkup, Request +from aiogram.api.types import InlineKeyboardButton, InlineKeyboardMarkup, Message +from tests.mocked_bot import MockedBot + + +class TestEditMessageReplyMarkup: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(EditMessageReplyMarkup, ok=True, result=True) + + response: Union[Message, bool] = await EditMessageReplyMarkup( + chat_id=42, + inline_message_id="inline message id", + reply_markup=InlineKeyboardMarkup( + inline_keyboard=[ + [InlineKeyboardButton(text="button", callback_data="placeholder")] + ] + ), + ) + request: Request = bot.get_request() + assert request.method == "editMessageReplyMarkup" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(EditMessageReplyMarkup, ok=True, result=True) + + response: Union[Message, bool] = await bot.edit_message_reply_markup( + chat_id=42, + inline_message_id="inline message id", + reply_markup=InlineKeyboardMarkup( + inline_keyboard=[ + [InlineKeyboardButton(text="button", callback_data="placeholder")] + ] + ), + ) + request: Request = bot.get_request() + assert request.method == "editMessageReplyMarkup" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_edit_message_text.py b/tests/test_api/test_methods/test_edit_message_text.py new file mode 100644 index 00000000..0e349a03 --- /dev/null +++ b/tests/test_api/test_methods/test_edit_message_text.py @@ -0,0 +1,31 @@ +from typing import Union + +import pytest + +from aiogram.api.methods import EditMessageText, Request +from aiogram.api.types import Message +from tests.mocked_bot import MockedBot + + +class TestEditMessageText: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(EditMessageText, ok=True, result=True) + + response: Union[Message, bool] = await EditMessageText( + chat_id=42, inline_message_id="inline message id", text="text" + ) + request: Request = bot.get_request() + assert request.method == "editMessageText" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(EditMessageText, ok=True, result=True) + + response: Union[Message, bool] = await bot.edit_message_text( + chat_id=42, inline_message_id="inline message id", text="text" + ) + request: Request = bot.get_request() + assert request.method == "editMessageText" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_export_chat_invite_link.py b/tests/test_api/test_methods/test_export_chat_invite_link.py new file mode 100644 index 00000000..8e76e907 --- /dev/null +++ b/tests/test_api/test_methods/test_export_chat_invite_link.py @@ -0,0 +1,28 @@ +import pytest + +from aiogram.api.methods import ExportChatInviteLink, Request +from tests.mocked_bot import MockedBot + + +class TestExportChatInviteLink: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for( + ExportChatInviteLink, ok=True, result="http://example.com" + ) + + response: str = await ExportChatInviteLink(chat_id=42) + request: Request = bot.get_request() + assert request.method == "exportChatInviteLink" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for( + ExportChatInviteLink, ok=True, result="http://example.com" + ) + + response: str = await bot.export_chat_invite_link(chat_id=42) + request: Request = bot.get_request() + assert request.method == "exportChatInviteLink" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_forward_message.py b/tests/test_api/test_methods/test_forward_message.py new file mode 100644 index 00000000..3e2ae0d9 --- /dev/null +++ b/tests/test_api/test_methods/test_forward_message.py @@ -0,0 +1,47 @@ +import datetime + +import pytest + +from aiogram.api.methods import ForwardMessage, Request +from aiogram.api.types import Chat, Message +from tests.mocked_bot import MockedBot + + +class TestForwardMessage: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for( + ForwardMessage, + ok=True, + result=Message( + message_id=42, + date=datetime.datetime.now(), + chat=Chat(id=42, title="chat", type="private"), + text="text", + ), + ) + + response: Message = await ForwardMessage(chat_id=42, from_chat_id=42, message_id=42) + request: Request = bot.get_request() + assert request.method == "forwardMessage" + # 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( + ForwardMessage, + ok=True, + result=Message( + message_id=42, + date=datetime.datetime.now(), + chat=Chat(id=42, title="chat", type="private"), + text="text", + ), + ) + + response: Message = await bot.forward_message(chat_id=42, from_chat_id=42, message_id=42) + request: Request = bot.get_request() + assert request.method == "forwardMessage" + # assert request.data == {} + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_get_chat.py b/tests/test_api/test_methods/test_get_chat.py new file mode 100644 index 00000000..d88b5261 --- /dev/null +++ b/tests/test_api/test_methods/test_get_chat.py @@ -0,0 +1,29 @@ +import pytest + +from aiogram.api.methods import GetChat, Request +from aiogram.api.types import Chat +from tests.mocked_bot import MockedBot + + +class TestGetChat: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for( + GetChat, ok=True, result=Chat(id=-42, type="channel", title="chat") + ) + + response: Chat = await GetChat(chat_id=-42) + request: Request = bot.get_request() + assert request.method == "getChat" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for( + GetChat, ok=True, result=Chat(id=-42, type="channel", title="chat") + ) + + response: Chat = await bot.get_chat(chat_id=-42) + request: Request = bot.get_request() + assert request.method == "getChat" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_get_chat_administrators.py b/tests/test_api/test_methods/test_get_chat_administrators.py new file mode 100644 index 00000000..f5e76c2e --- /dev/null +++ b/tests/test_api/test_methods/test_get_chat_administrators.py @@ -0,0 +1,38 @@ +from typing import List + +import pytest + +from aiogram.api.methods import GetChatAdministrators, Request +from aiogram.api.types import ChatMember, User +from tests.mocked_bot import MockedBot + + +class TestGetChatAdministrators: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for( + GetChatAdministrators, + ok=True, + result=[ + ChatMember(user=User(id=42, is_bot=False, first_name="User"), status="creator") + ], + ) + + response: List[ChatMember] = await GetChatAdministrators(chat_id=-42) + request: Request = bot.get_request() + assert request.method == "getChatAdministrators" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for( + GetChatAdministrators, + ok=True, + result=[ + ChatMember(user=User(id=42, is_bot=False, first_name="User"), status="creator") + ], + ) + response: List[ChatMember] = await bot.get_chat_administrators(chat_id=-42) + request: Request = bot.get_request() + assert request.method == "getChatAdministrators" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_get_chat_member.py b/tests/test_api/test_methods/test_get_chat_member.py new file mode 100644 index 00000000..d63bdbd0 --- /dev/null +++ b/tests/test_api/test_methods/test_get_chat_member.py @@ -0,0 +1,33 @@ +import pytest + +from aiogram.api.methods import GetChatMember, Request +from aiogram.api.types import ChatMember, User +from tests.mocked_bot import MockedBot + + +class TestGetChatMember: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for( + GetChatMember, + ok=True, + result=ChatMember(user=User(id=42, is_bot=False, first_name="User"), status="creator"), + ) + + response: ChatMember = await GetChatMember(chat_id=-42, user_id=42) + request: Request = bot.get_request() + assert request.method == "getChatMember" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for( + GetChatMember, + ok=True, + result=ChatMember(user=User(id=42, is_bot=False, first_name="User"), status="creator"), + ) + + response: ChatMember = await bot.get_chat_member(chat_id=-42, user_id=42) + request: Request = bot.get_request() + assert request.method == "getChatMember" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_get_chat_members_count.py b/tests/test_api/test_methods/test_get_chat_members_count.py new file mode 100644 index 00000000..1ae1a6e7 --- /dev/null +++ b/tests/test_api/test_methods/test_get_chat_members_count.py @@ -0,0 +1,24 @@ +import pytest + +from aiogram.api.methods import GetChatMembersCount, Request +from tests.mocked_bot import MockedBot + + +class TestGetChatMembersCount: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(GetChatMembersCount, ok=True, result=42) + + response: int = await GetChatMembersCount(chat_id=-42) + request: Request = bot.get_request() + assert request.method == "getChatMembersCount" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(GetChatMembersCount, ok=True, result=42) + + response: int = await bot.get_chat_members_count(chat_id=-42) + request: Request = bot.get_request() + assert request.method == "getChatMembersCount" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_get_file.py b/tests/test_api/test_methods/test_get_file.py new file mode 100644 index 00000000..6b8e2ff0 --- /dev/null +++ b/tests/test_api/test_methods/test_get_file.py @@ -0,0 +1,25 @@ +import pytest + +from aiogram.api.methods import GetFile, Request +from aiogram.api.types import File +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")) + + response: File = await GetFile(file_id="file id") + request: Request = bot.get_request() + assert request.method == "getFile" + assert response == prepare_result.result + + @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")) + + response: File = await bot.get_file(file_id="file id") + request: Request = bot.get_request() + assert request.method == "getFile" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_get_game_high_scores.py b/tests/test_api/test_methods/test_get_game_high_scores.py new file mode 100644 index 00000000..efeac5cb --- /dev/null +++ b/tests/test_api/test_methods/test_get_game_high_scores.py @@ -0,0 +1,43 @@ +from typing import List + +import pytest + +from aiogram.api.methods import GetGameHighScores, Request +from aiogram.api.types import GameHighScore, User +from tests.mocked_bot import MockedBot + + +class TestGetGameHighScores: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for( + GetGameHighScores, + ok=True, + result=[ + GameHighScore( + position=1, user=User(id=42, is_bot=False, first_name="User"), score=42 + ) + ], + ) + + response: List[GameHighScore] = await GetGameHighScores(user_id=42) + request: Request = bot.get_request() + assert request.method == "getGameHighScores" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for( + GetGameHighScores, + ok=True, + result=[ + GameHighScore( + position=1, user=User(id=42, is_bot=False, first_name="User"), score=42 + ) + ], + ) + + response: List[GameHighScore] = await bot.get_game_high_scores(user_id=42) + request: Request = bot.get_request() + assert request.method == "getGameHighScores" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_get_sticker_set.py b/tests/test_api/test_methods/test_get_sticker_set.py new file mode 100644 index 00000000..236116ce --- /dev/null +++ b/tests/test_api/test_methods/test_get_sticker_set.py @@ -0,0 +1,45 @@ +import pytest + +from aiogram.api.methods import GetStickerSet, Request +from aiogram.api.types import Sticker, StickerSet +from tests.mocked_bot import MockedBot + + +class TestGetStickerSet: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for( + GetStickerSet, + ok=True, + result=StickerSet( + name="test", + title="test", + is_animated=False, + contains_masks=False, + stickers=[Sticker(file_id="file if", width=42, height=42, is_animated=False)], + ), + ) + + response: StickerSet = await GetStickerSet(name="test") + request: Request = bot.get_request() + assert request.method == "getStickerSet" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for( + GetStickerSet, + ok=True, + result=StickerSet( + name="test", + title="test", + is_animated=False, + contains_masks=False, + stickers=[Sticker(file_id="file if", width=42, height=42, is_animated=False)], + ), + ) + + response: StickerSet = await bot.get_sticker_set(name="test") + request: Request = bot.get_request() + assert request.method == "getStickerSet" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_get_updates.py b/tests/test_api/test_methods/test_get_updates.py new file mode 100644 index 00000000..92081e7b --- /dev/null +++ b/tests/test_api/test_methods/test_get_updates.py @@ -0,0 +1,27 @@ +from typing import List + +import pytest + +from aiogram.api.methods import GetUpdates, Request +from aiogram.api.types import Update +from tests.mocked_bot import MockedBot + + +class TestGetUpdates: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(GetUpdates, ok=True, result=[Update(update_id=42)]) + + response: List[Update] = await GetUpdates() + request: Request = bot.get_request() + assert request.method == "getUpdates" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(GetUpdates, ok=True, result=[Update(update_id=42)]) + + response: List[Update] = await bot.get_updates() + request: Request = bot.get_request() + assert request.method == "getUpdates" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_get_user_profile_photos.py b/tests/test_api/test_methods/test_get_user_profile_photos.py new file mode 100644 index 00000000..9d277f98 --- /dev/null +++ b/tests/test_api/test_methods/test_get_user_profile_photos.py @@ -0,0 +1,38 @@ +import pytest + +from aiogram.api.methods import GetUserProfilePhotos, Request +from aiogram.api.types import PhotoSize, UserProfilePhotos +from tests.mocked_bot import MockedBot + + +@pytest.mark.skip +class TestGetUserProfilePhotos: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for( + GetUserProfilePhotos, + ok=True, + result=UserProfilePhotos( + total_count=1, photos=[[PhotoSize(file_id="file_id", width=42, height=42)]] + ), + ) + + response: UserProfilePhotos = await GetUserProfilePhotos(user_id=42) + request: Request = bot.get_request() + assert request.method == "getUserProfilePhotos" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for( + GetUserProfilePhotos, + ok=True, + result=UserProfilePhotos( + total_count=1, photos=[[PhotoSize(file_id="file_id", width=42, height=42)]] + ), + ) + + response: UserProfilePhotos = await bot.get_user_profile_photos(user_id=42) + request: Request = bot.get_request() + assert request.method == "getUserProfilePhotos" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_get_webhook_info.py b/tests/test_api/test_methods/test_get_webhook_info.py new file mode 100644 index 00000000..e3259125 --- /dev/null +++ b/tests/test_api/test_methods/test_get_webhook_info.py @@ -0,0 +1,37 @@ +import pytest + +from aiogram.api.methods import GetWebhookInfo, Request +from aiogram.api.types import WebhookInfo +from tests.mocked_bot import MockedBot + + +class TestGetWebhookInfo: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for( + GetWebhookInfo, + ok=True, + result=WebhookInfo( + url="https://example.com", has_custom_certificate=False, pending_update_count=0 + ), + ) + + response: WebhookInfo = await GetWebhookInfo() + request: Request = bot.get_request() + assert request.method == "getWebhookInfo" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for( + GetWebhookInfo, + ok=True, + result=WebhookInfo( + url="https://example.com", has_custom_certificate=False, pending_update_count=0 + ), + ) + + response: WebhookInfo = await bot.get_webhook_info() + request: Request = bot.get_request() + assert request.method == "getWebhookInfo" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_kick_chat_member.py b/tests/test_api/test_methods/test_kick_chat_member.py new file mode 100644 index 00000000..f142f649 --- /dev/null +++ b/tests/test_api/test_methods/test_kick_chat_member.py @@ -0,0 +1,24 @@ +import pytest + +from aiogram.api.methods import KickChatMember, Request +from tests.mocked_bot import MockedBot + + +class TestKickChatMember: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(KickChatMember, ok=True, result=True) + + response: bool = await KickChatMember(chat_id=-42, user_id=42) + request: Request = bot.get_request() + assert request.method == "kickChatMember" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(KickChatMember, ok=True, result=True) + + response: bool = await bot.kick_chat_member(chat_id=-42, user_id=42) + request: Request = bot.get_request() + assert request.method == "kickChatMember" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_leave_chat.py b/tests/test_api/test_methods/test_leave_chat.py new file mode 100644 index 00000000..f9f876e6 --- /dev/null +++ b/tests/test_api/test_methods/test_leave_chat.py @@ -0,0 +1,24 @@ +import pytest + +from aiogram.api.methods import LeaveChat, Request +from tests.mocked_bot import MockedBot + + +class TestLeaveChat: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(LeaveChat, ok=True, result=True) + + response: bool = await LeaveChat(chat_id=-42) + request: Request = bot.get_request() + assert request.method == "leaveChat" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(LeaveChat, ok=True, result=True) + + response: bool = await bot.leave_chat(chat_id=-42) + request: Request = bot.get_request() + assert request.method == "leaveChat" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_pin_chat_message.py b/tests/test_api/test_methods/test_pin_chat_message.py new file mode 100644 index 00000000..fa87d796 --- /dev/null +++ b/tests/test_api/test_methods/test_pin_chat_message.py @@ -0,0 +1,24 @@ +import pytest + +from aiogram.api.methods import PinChatMessage, Request +from tests.mocked_bot import MockedBot + + +class TestPinChatMessage: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(PinChatMessage, ok=True, result=True) + + response: bool = await PinChatMessage(chat_id=-42, message_id=42) + request: Request = bot.get_request() + assert request.method == "pinChatMessage" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(PinChatMessage, ok=True, result=True) + + response: bool = await bot.pin_chat_message(chat_id=-42, message_id=42) + request: Request = bot.get_request() + assert request.method == "pinChatMessage" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_promote_chat_member.py b/tests/test_api/test_methods/test_promote_chat_member.py new file mode 100644 index 00000000..3b8a7797 --- /dev/null +++ b/tests/test_api/test_methods/test_promote_chat_member.py @@ -0,0 +1,24 @@ +import pytest + +from aiogram.api.methods import PromoteChatMember, Request +from tests.mocked_bot import MockedBot + + +class TestPromoteChatMember: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(PromoteChatMember, ok=True, result=True) + + response: bool = await PromoteChatMember(chat_id=-42, user_id=42) + request: Request = bot.get_request() + assert request.method == "promoteChatMember" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(PromoteChatMember, ok=True, result=True) + + response: bool = await bot.promote_chat_member(chat_id=-42, user_id=42) + request: Request = bot.get_request() + assert request.method == "promoteChatMember" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_restrict_chat_member.py b/tests/test_api/test_methods/test_restrict_chat_member.py new file mode 100644 index 00000000..a48caeff --- /dev/null +++ b/tests/test_api/test_methods/test_restrict_chat_member.py @@ -0,0 +1,29 @@ +import pytest + +from aiogram.api.methods import Request, RestrictChatMember +from aiogram.api.types import ChatPermissions +from tests.mocked_bot import MockedBot + + +class TestRestrictChatMember: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(RestrictChatMember, ok=True, result=True) + + response: bool = await RestrictChatMember( + chat_id=-42, user_id=42, permissions=ChatPermissions() + ) + request: Request = bot.get_request() + assert request.method == "restrictChatMember" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(RestrictChatMember, ok=True, result=True) + + response: bool = await bot.restrict_chat_member( + chat_id=-42, user_id=42, permissions=ChatPermissions() + ) + request: Request = bot.get_request() + assert request.method == "restrictChatMember" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_send_animation.py b/tests/test_api/test_methods/test_send_animation.py new file mode 100644 index 00000000..06af5218 --- /dev/null +++ b/tests/test_api/test_methods/test_send_animation.py @@ -0,0 +1,45 @@ +import datetime + +import pytest + +from aiogram.api.methods import Request, SendAnimation +from aiogram.api.types import Animation, Chat, Message +from tests.mocked_bot import MockedBot + + +class TestSendAnimation: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for( + SendAnimation, + ok=True, + result=Message( + message_id=42, + date=datetime.datetime.now(), + animation=Animation(file_id="file id", width=42, height=42, duration=0), + chat=Chat(id=42, type="private"), + ), + ) + + response: Message = await SendAnimation(chat_id=42, animation="file id") + request: Request = bot.get_request() + assert request.method == "sendAnimation" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for( + SendAnimation, + ok=True, + result=Message( + message_id=42, + date=datetime.datetime.now(), + animation=Animation(file_id="file id", width=42, height=42, duration=0), + chat=Chat(id=42, type="private"), + ), + ) + + response: Message = await bot.send_animation(chat_id=42, animation="file id") + request: Request = bot.get_request() + assert request.method == "sendAnimation" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_send_audio.py b/tests/test_api/test_methods/test_send_audio.py new file mode 100644 index 00000000..c15d6728 --- /dev/null +++ b/tests/test_api/test_methods/test_send_audio.py @@ -0,0 +1,45 @@ +import datetime + +import pytest + +from aiogram.api.methods import Request, SendAudio +from aiogram.api.types import Audio, Chat, File, 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), + 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), + 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 diff --git a/tests/test_api/test_methods/test_send_chat_action.py b/tests/test_api/test_methods/test_send_chat_action.py new file mode 100644 index 00000000..1d98b482 --- /dev/null +++ b/tests/test_api/test_methods/test_send_chat_action.py @@ -0,0 +1,24 @@ +import pytest + +from aiogram.api.methods import Request, SendChatAction +from tests.mocked_bot import MockedBot + + +class TestSendChatAction: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(SendChatAction, ok=True, result=True) + + response: bool = await SendChatAction(chat_id=42, action="typing") + request: Request = bot.get_request() + assert request.method == "sendChatAction" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(SendChatAction, ok=True, result=True) + + response: bool = await bot.send_chat_action(chat_id=42, action="typing") + request: Request = bot.get_request() + assert request.method == "sendChatAction" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_send_contact.py b/tests/test_api/test_methods/test_send_contact.py new file mode 100644 index 00000000..44435d2d --- /dev/null +++ b/tests/test_api/test_methods/test_send_contact.py @@ -0,0 +1,47 @@ +import datetime + +import pytest + +from aiogram.api.methods import Request, SendContact +from aiogram.api.types import Chat, Contact, Message +from tests.mocked_bot import MockedBot + + +class TestSendContact: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for( + SendContact, + ok=True, + result=Message( + message_id=42, + date=datetime.datetime.now(), + contact=Contact(phone_number="911", first_name="911"), + chat=Chat(id=42, type="private"), + ), + ) + + response: Message = await SendContact(chat_id=42, phone_number="911", first_name="911") + request: Request = bot.get_request() + assert request.method == "sendContact" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for( + SendContact, + ok=True, + result=Message( + message_id=42, + date=datetime.datetime.now(), + contact=Contact(phone_number="911", first_name="911"), + chat=Chat(id=42, type="private"), + ), + ) + + response: Message = await bot.send_contact( + chat_id=42, phone_number="911", first_name="911" + ) + request: Request = bot.get_request() + assert request.method == "sendContact" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_send_document.py b/tests/test_api/test_methods/test_send_document.py new file mode 100644 index 00000000..c91ebfa2 --- /dev/null +++ b/tests/test_api/test_methods/test_send_document.py @@ -0,0 +1,27 @@ +import pytest + +from aiogram.api.methods import Request, SendDocument +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) + + response: Message = await SendDocument(chat_id=..., document=...) + 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) + + response: Message = await bot.send_document(chat_id=..., document=...) + 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 new file mode 100644 index 00000000..b2a6b114 --- /dev/null +++ b/tests/test_api/test_methods/test_send_game.py @@ -0,0 +1,27 @@ +import pytest + +from aiogram.api.methods import Request, SendGame +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) + + response: Message = await SendGame(chat_id=..., game_short_name=...) + 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) + + response: Message = await bot.send_game(chat_id=..., game_short_name=...) + 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 new file mode 100644 index 00000000..b69272bc --- /dev/null +++ b/tests/test_api/test_methods/test_send_invoice.py @@ -0,0 +1,45 @@ +import pytest + +from aiogram.api.methods import Request, SendInvoice +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) + + response: Message = await SendInvoice( + chat_id=..., + title=..., + description=..., + payload=..., + provider_token=..., + start_parameter=..., + currency=..., + prices=..., + ) + 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) + + response: Message = await bot.send_invoice( + chat_id=..., + title=..., + description=..., + payload=..., + provider_token=..., + start_parameter=..., + currency=..., + prices=..., + ) + 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 new file mode 100644 index 00000000..33a2fda6 --- /dev/null +++ b/tests/test_api/test_methods/test_send_location.py @@ -0,0 +1,27 @@ +import pytest + +from aiogram.api.methods import Request, SendLocation +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) + + response: Message = await SendLocation(chat_id=..., latitude=..., longitude=...) + 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) + + response: Message = await bot.send_location(chat_id=..., latitude=..., longitude=...) + 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 new file mode 100644 index 00000000..7983260a --- /dev/null +++ b/tests/test_api/test_methods/test_send_media_group.py @@ -0,0 +1,27 @@ +import pytest + +from aiogram.api.methods import Request, SendMediaGroup +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=None) + + response: List[Message] = await SendMediaGroup(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 request.data == {} + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_send_message.py b/tests/test_api/test_methods/test_send_message.py new file mode 100644 index 00000000..6fb8d34a --- /dev/null +++ b/tests/test_api/test_methods/test_send_message.py @@ -0,0 +1,27 @@ +import pytest + +from aiogram.api.methods import Request, SendMessage +from tests.mocked_bot import MockedBot + + +@pytest.mark.skip +class TestSendMessage: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(SendMessage, ok=True, result=None) + + response: Message = await SendMessage(chat_id=..., text=...) + request: Request = bot.get_request() + assert request.method == "sendMessage" + # 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(SendMessage, ok=True, result=None) + + response: Message = await bot.send_message(chat_id=..., text=...) + request: Request = bot.get_request() + assert request.method == "sendMessage" + # assert request.data == {} + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_send_photo.py b/tests/test_api/test_methods/test_send_photo.py new file mode 100644 index 00000000..08f02ead --- /dev/null +++ b/tests/test_api/test_methods/test_send_photo.py @@ -0,0 +1,27 @@ +import pytest + +from aiogram.api.methods import Request, SendPhoto +from tests.mocked_bot import MockedBot + + +@pytest.mark.skip +class TestSendPhoto: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(SendPhoto, ok=True, result=None) + + response: Message = await SendPhoto(chat_id=..., photo=...) + request: Request = bot.get_request() + assert request.method == "sendPhoto" + # 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(SendPhoto, ok=True, result=None) + + response: Message = await bot.send_photo(chat_id=..., photo=...) + request: Request = bot.get_request() + assert request.method == "sendPhoto" + # assert request.data == {} + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_send_poll.py b/tests/test_api/test_methods/test_send_poll.py new file mode 100644 index 00000000..d7a96ab1 --- /dev/null +++ b/tests/test_api/test_methods/test_send_poll.py @@ -0,0 +1,27 @@ +import pytest + +from aiogram.api.methods import Request, SendPoll +from tests.mocked_bot import MockedBot + + +@pytest.mark.skip +class TestSendPoll: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(SendPoll, ok=True, result=None) + + response: Message = await SendPoll(chat_id=..., question=..., options=...) + request: Request = bot.get_request() + assert request.method == "sendPoll" + # 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(SendPoll, ok=True, result=None) + + response: Message = await bot.send_poll(chat_id=..., question=..., options=...) + request: Request = bot.get_request() + assert request.method == "sendPoll" + # assert request.data == {} + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_send_sticker.py b/tests/test_api/test_methods/test_send_sticker.py new file mode 100644 index 00000000..81a4e345 --- /dev/null +++ b/tests/test_api/test_methods/test_send_sticker.py @@ -0,0 +1,27 @@ +import pytest + +from aiogram.api.methods import Request, SendSticker +from tests.mocked_bot import MockedBot + + +@pytest.mark.skip +class TestSendSticker: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(SendSticker, ok=True, result=None) + + response: Message = await SendSticker(chat_id=..., sticker=...) + request: Request = bot.get_request() + assert request.method == "sendSticker" + # 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(SendSticker, ok=True, result=None) + + response: Message = await bot.send_sticker(chat_id=..., sticker=...) + request: Request = bot.get_request() + assert request.method == "sendSticker" + # assert request.data == {} + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_send_venue.py b/tests/test_api/test_methods/test_send_venue.py new file mode 100644 index 00000000..f2d09cea --- /dev/null +++ b/tests/test_api/test_methods/test_send_venue.py @@ -0,0 +1,31 @@ +import pytest + +from aiogram.api.methods import Request, SendVenue +from tests.mocked_bot import MockedBot + + +@pytest.mark.skip +class TestSendVenue: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(SendVenue, ok=True, result=None) + + response: Message = await SendVenue( + chat_id=..., latitude=..., longitude=..., title=..., address=... + ) + request: Request = bot.get_request() + assert request.method == "sendVenue" + # 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(SendVenue, ok=True, result=None) + + response: Message = await bot.send_venue( + chat_id=..., latitude=..., longitude=..., title=..., address=... + ) + request: Request = bot.get_request() + assert request.method == "sendVenue" + # assert request.data == {} + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_send_video.py b/tests/test_api/test_methods/test_send_video.py new file mode 100644 index 00000000..ea3c9220 --- /dev/null +++ b/tests/test_api/test_methods/test_send_video.py @@ -0,0 +1,27 @@ +import pytest + +from aiogram.api.methods import Request, SendVideo +from tests.mocked_bot import MockedBot + + +@pytest.mark.skip +class TestSendVideo: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(SendVideo, ok=True, result=None) + + response: Message = await SendVideo(chat_id=..., video=...) + request: Request = bot.get_request() + assert request.method == "sendVideo" + # 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(SendVideo, ok=True, result=None) + + response: Message = await bot.send_video(chat_id=..., video=...) + request: Request = bot.get_request() + assert request.method == "sendVideo" + # assert request.data == {} + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_send_video_note.py b/tests/test_api/test_methods/test_send_video_note.py new file mode 100644 index 00000000..e5b27f68 --- /dev/null +++ b/tests/test_api/test_methods/test_send_video_note.py @@ -0,0 +1,27 @@ +import pytest + +from aiogram.api.methods import Request, SendVideoNote +from tests.mocked_bot import MockedBot + + +@pytest.mark.skip +class TestSendVideoNote: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(SendVideoNote, ok=True, result=None) + + response: Message = await SendVideoNote(chat_id=..., video_note=...) + request: Request = bot.get_request() + assert request.method == "sendVideoNote" + # 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(SendVideoNote, ok=True, result=None) + + response: Message = await bot.send_video_note(chat_id=..., video_note=...) + request: Request = bot.get_request() + assert request.method == "sendVideoNote" + # assert request.data == {} + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_send_voice.py b/tests/test_api/test_methods/test_send_voice.py new file mode 100644 index 00000000..2bed25b6 --- /dev/null +++ b/tests/test_api/test_methods/test_send_voice.py @@ -0,0 +1,27 @@ +import pytest + +from aiogram.api.methods import Request, SendVoice +from tests.mocked_bot import MockedBot + + +@pytest.mark.skip +class TestSendVoice: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(SendVoice, ok=True, result=None) + + response: Message = await SendVoice(chat_id=..., voice=...) + request: Request = bot.get_request() + assert request.method == "sendVoice" + # 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(SendVoice, ok=True, result=None) + + response: Message = await bot.send_voice(chat_id=..., voice=...) + request: Request = bot.get_request() + assert request.method == "sendVoice" + # assert request.data == {} + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_set_chat_description.py b/tests/test_api/test_methods/test_set_chat_description.py new file mode 100644 index 00000000..8ac46632 --- /dev/null +++ b/tests/test_api/test_methods/test_set_chat_description.py @@ -0,0 +1,27 @@ +import pytest + +from aiogram.api.methods import Request, SetChatDescription +from tests.mocked_bot import MockedBot + + +@pytest.mark.skip +class TestSetChatDescription: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(SetChatDescription, ok=True, result=None) + + response: bool = await SetChatDescription(chat_id=...) + request: Request = bot.get_request() + assert request.method == "setChatDescription" + # 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(SetChatDescription, ok=True, result=None) + + response: bool = await bot.set_chat_description(chat_id=...) + request: Request = bot.get_request() + assert request.method == "setChatDescription" + # assert request.data == {} + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_set_chat_permissions.py b/tests/test_api/test_methods/test_set_chat_permissions.py new file mode 100644 index 00000000..933ed677 --- /dev/null +++ b/tests/test_api/test_methods/test_set_chat_permissions.py @@ -0,0 +1,27 @@ +import pytest + +from aiogram.api.methods import Request, SetChatPermissions +from tests.mocked_bot import MockedBot + + +@pytest.mark.skip +class TestSetChatPermissions: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(SetChatPermissions, ok=True, result=None) + + response: bool = await SetChatPermissions(chat_id=..., permissions=...) + request: Request = bot.get_request() + assert request.method == "setChatPermissions" + # 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(SetChatPermissions, ok=True, result=None) + + response: bool = await bot.set_chat_permissions(chat_id=..., permissions=...) + request: Request = bot.get_request() + assert request.method == "setChatPermissions" + # assert request.data == {} + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_set_chat_photo.py b/tests/test_api/test_methods/test_set_chat_photo.py new file mode 100644 index 00000000..ce20f997 --- /dev/null +++ b/tests/test_api/test_methods/test_set_chat_photo.py @@ -0,0 +1,27 @@ +import pytest + +from aiogram.api.methods import Request, SetChatPhoto +from tests.mocked_bot import MockedBot + + +@pytest.mark.skip +class TestSetChatPhoto: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(SetChatPhoto, ok=True, result=None) + + response: bool = await SetChatPhoto(chat_id=..., photo=...) + request: Request = bot.get_request() + assert request.method == "setChatPhoto" + # 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(SetChatPhoto, ok=True, result=None) + + response: bool = await bot.set_chat_photo(chat_id=..., photo=...) + request: Request = bot.get_request() + assert request.method == "setChatPhoto" + # assert request.data == {} + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_set_chat_sticker_set.py b/tests/test_api/test_methods/test_set_chat_sticker_set.py new file mode 100644 index 00000000..c8b0108e --- /dev/null +++ b/tests/test_api/test_methods/test_set_chat_sticker_set.py @@ -0,0 +1,27 @@ +import pytest + +from aiogram.api.methods import Request, SetChatStickerSet +from tests.mocked_bot import MockedBot + + +@pytest.mark.skip +class TestSetChatStickerSet: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(SetChatStickerSet, ok=True, result=None) + + response: bool = await SetChatStickerSet(chat_id=..., sticker_set_name=...) + request: Request = bot.get_request() + assert request.method == "setChatStickerSet" + # 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(SetChatStickerSet, ok=True, result=None) + + response: bool = await bot.set_chat_sticker_set(chat_id=..., sticker_set_name=...) + request: Request = bot.get_request() + assert request.method == "setChatStickerSet" + # assert request.data == {} + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_set_chat_title.py b/tests/test_api/test_methods/test_set_chat_title.py new file mode 100644 index 00000000..cce2b768 --- /dev/null +++ b/tests/test_api/test_methods/test_set_chat_title.py @@ -0,0 +1,27 @@ +import pytest + +from aiogram.api.methods import Request, SetChatTitle +from tests.mocked_bot import MockedBot + + +@pytest.mark.skip +class TestSetChatTitle: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(SetChatTitle, ok=True, result=None) + + response: bool = await SetChatTitle(chat_id=..., title=...) + request: Request = bot.get_request() + assert request.method == "setChatTitle" + # 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(SetChatTitle, ok=True, result=None) + + response: bool = await bot.set_chat_title(chat_id=..., title=...) + request: Request = bot.get_request() + assert request.method == "setChatTitle" + # assert request.data == {} + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_set_game_score.py b/tests/test_api/test_methods/test_set_game_score.py new file mode 100644 index 00000000..27183a7d --- /dev/null +++ b/tests/test_api/test_methods/test_set_game_score.py @@ -0,0 +1,27 @@ +import pytest + +from aiogram.api.methods import Request, SetGameScore +from tests.mocked_bot import MockedBot + + +@pytest.mark.skip +class TestSetGameScore: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(SetGameScore, ok=True, result=None) + + response: Union[Message, bool] = await SetGameScore(user_id=..., score=...) + request: Request = bot.get_request() + assert request.method == "setGameScore" + # 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(SetGameScore, ok=True, result=None) + + response: Union[Message, bool] = await bot.set_game_score(user_id=..., score=...) + request: Request = bot.get_request() + assert request.method == "setGameScore" + # assert request.data == {} + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_set_passport_data_errors.py b/tests/test_api/test_methods/test_set_passport_data_errors.py new file mode 100644 index 00000000..fe74df09 --- /dev/null +++ b/tests/test_api/test_methods/test_set_passport_data_errors.py @@ -0,0 +1,27 @@ +import pytest + +from aiogram.api.methods import Request, SetPassportDataErrors +from tests.mocked_bot import MockedBot + + +@pytest.mark.skip +class TestSetPassportDataErrors: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(SetPassportDataErrors, ok=True, result=None) + + response: bool = await SetPassportDataErrors(user_id=..., errors=...) + request: Request = bot.get_request() + assert request.method == "setPassportDataErrors" + # 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(SetPassportDataErrors, ok=True, result=None) + + response: bool = await bot.set_passport_data_errors(user_id=..., errors=...) + request: Request = bot.get_request() + assert request.method == "setPassportDataErrors" + # assert request.data == {} + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_set_sticker_position_in_set.py b/tests/test_api/test_methods/test_set_sticker_position_in_set.py new file mode 100644 index 00000000..a31f7920 --- /dev/null +++ b/tests/test_api/test_methods/test_set_sticker_position_in_set.py @@ -0,0 +1,27 @@ +import pytest + +from aiogram.api.methods import Request, SetStickerPositionInSet +from tests.mocked_bot import MockedBot + + +@pytest.mark.skip +class TestSetStickerPositionInSet: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(SetStickerPositionInSet, ok=True, result=None) + + response: bool = await SetStickerPositionInSet(sticker=..., position=...) + request: Request = bot.get_request() + assert request.method == "setStickerPositionInSet" + # 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(SetStickerPositionInSet, ok=True, result=None) + + response: bool = await bot.set_sticker_position_in_set(sticker=..., position=...) + request: Request = bot.get_request() + assert request.method == "setStickerPositionInSet" + # assert request.data == {} + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_set_webhook.py b/tests/test_api/test_methods/test_set_webhook.py new file mode 100644 index 00000000..cccee5d3 --- /dev/null +++ b/tests/test_api/test_methods/test_set_webhook.py @@ -0,0 +1,27 @@ +import pytest + +from aiogram.api.methods import Request, SetWebhook +from tests.mocked_bot import MockedBot + + +@pytest.mark.skip +class TestSetWebhook: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(SetWebhook, ok=True, result=None) + + response: bool = await SetWebhook(url=...) + request: Request = bot.get_request() + assert request.method == "setWebhook" + # 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(SetWebhook, ok=True, result=None) + + response: bool = await bot.set_webhook(url=...) + request: Request = bot.get_request() + assert request.method == "setWebhook" + # assert request.data == {} + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_stop_message_live_location.py b/tests/test_api/test_methods/test_stop_message_live_location.py new file mode 100644 index 00000000..e7d927c2 --- /dev/null +++ b/tests/test_api/test_methods/test_stop_message_live_location.py @@ -0,0 +1,27 @@ +import pytest + +from aiogram.api.methods import Request, StopMessageLiveLocation +from tests.mocked_bot import MockedBot + + +@pytest.mark.skip +class TestStopMessageLiveLocation: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(StopMessageLiveLocation, ok=True, result=None) + + response: Union[Message, bool] = await StopMessageLiveLocation() + request: Request = bot.get_request() + assert request.method == "stopMessageLiveLocation" + # 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(StopMessageLiveLocation, ok=True, result=None) + + response: Union[Message, bool] = await bot.stop_message_live_location() + request: Request = bot.get_request() + assert request.method == "stopMessageLiveLocation" + # assert request.data == {} + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_stop_poll.py b/tests/test_api/test_methods/test_stop_poll.py new file mode 100644 index 00000000..5141d2c4 --- /dev/null +++ b/tests/test_api/test_methods/test_stop_poll.py @@ -0,0 +1,27 @@ +import pytest + +from aiogram.api.methods import Request, StopPoll +from tests.mocked_bot import MockedBot + + +@pytest.mark.skip +class TestStopPoll: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(StopPoll, ok=True, result=None) + + response: Poll = await StopPoll(chat_id=..., message_id=...) + request: Request = bot.get_request() + assert request.method == "stopPoll" + # 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(StopPoll, ok=True, result=None) + + response: Poll = await bot.stop_poll(chat_id=..., message_id=...) + request: Request = bot.get_request() + assert request.method == "stopPoll" + # assert request.data == {} + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_unban_chat_member.py b/tests/test_api/test_methods/test_unban_chat_member.py new file mode 100644 index 00000000..9ca14ad2 --- /dev/null +++ b/tests/test_api/test_methods/test_unban_chat_member.py @@ -0,0 +1,27 @@ +import pytest + +from aiogram.api.methods import Request, UnbanChatMember +from tests.mocked_bot import MockedBot + + +@pytest.mark.skip +class TestUnbanChatMember: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(UnbanChatMember, ok=True, result=None) + + response: bool = await UnbanChatMember(chat_id=..., user_id=...) + request: Request = bot.get_request() + assert request.method == "unbanChatMember" + # 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(UnbanChatMember, ok=True, result=None) + + response: bool = await bot.unban_chat_member(chat_id=..., user_id=...) + request: Request = bot.get_request() + assert request.method == "unbanChatMember" + # assert request.data == {} + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_unpin_chat_message.py b/tests/test_api/test_methods/test_unpin_chat_message.py new file mode 100644 index 00000000..a12efeab --- /dev/null +++ b/tests/test_api/test_methods/test_unpin_chat_message.py @@ -0,0 +1,27 @@ +import pytest + +from aiogram.api.methods import Request, UnpinChatMessage +from tests.mocked_bot import MockedBot + + +@pytest.mark.skip +class TestUnpinChatMessage: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(UnpinChatMessage, ok=True, result=None) + + response: bool = await UnpinChatMessage(chat_id=...) + request: Request = bot.get_request() + assert request.method == "unpinChatMessage" + # 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(UnpinChatMessage, ok=True, result=None) + + response: bool = await bot.unpin_chat_message(chat_id=...) + request: Request = bot.get_request() + assert request.method == "unpinChatMessage" + # assert request.data == {} + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_upload_sticker_file.py b/tests/test_api/test_methods/test_upload_sticker_file.py new file mode 100644 index 00000000..1a24522d --- /dev/null +++ b/tests/test_api/test_methods/test_upload_sticker_file.py @@ -0,0 +1,27 @@ +import pytest + +from aiogram.api.methods import Request, UploadStickerFile +from tests.mocked_bot import MockedBot + + +@pytest.mark.skip +class TestUploadStickerFile: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(UploadStickerFile, ok=True, result=None) + + response: File = await UploadStickerFile(user_id=..., png_sticker=...) + request: Request = bot.get_request() + assert request.method == "uploadStickerFile" + # 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(UploadStickerFile, ok=True, result=None) + + response: File = await bot.upload_sticker_file(user_id=..., png_sticker=...) + request: Request = bot.get_request() + assert request.method == "uploadStickerFile" + # assert request.data == {} + assert response == prepare_result.result