Merge remote-tracking branch 'origin/dev-3.x' into dev-3.x

This commit is contained in:
jrootjunior 2019-11-19 18:28:55 +02:00
commit 635f08b88f
67 changed files with 1920 additions and 15 deletions

View file

@ -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

View file

@ -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

View file

@ -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,

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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