Reworked request builder (#1142)

* Reworked request builder

* Added more default values

* Update tests

* Fixed timestamp

* Fixed Py3.8 support

* Describe changes
This commit is contained in:
Alex Root Junior 2023-03-11 20:46:36 +02:00 committed by GitHub
parent 924a83966d
commit fea1b7b0a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
300 changed files with 1003 additions and 3448 deletions

View file

@ -1,21 +1,9 @@
from aiogram.methods import AddStickerToSet, Request
from aiogram.methods import AddStickerToSet
from aiogram.types import InputSticker
from tests.mocked_bot import MockedBot
class TestAddStickerToSet:
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",
sticker=InputSticker(sticker="file id", emoji_list=[":)"]),
)
request: Request = bot.get_request()
assert request.method == "addStickerToSet"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(AddStickerToSet, ok=True, result=True)
@ -24,6 +12,5 @@ class TestAddStickerToSet:
name="test stickers pack",
sticker=InputSticker(sticker="file id", emoji_list=[":)"]),
)
request: Request = bot.get_request()
assert request.method == "addStickerToSet"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,9 @@ from tests.mocked_bot import MockedBot
class TestAnswerCallbackQuery:
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
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"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -9,55 +9,11 @@ from tests.mocked_bot import MockedBot
class TestAnswerInlineQuery:
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
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"
request = bot.get_request()
assert response == prepare_result.result
def test_parse_mode(self, bot: MockedBot):
query = AnswerInlineQuery(
inline_query_id="query id",
results=[
InlineQueryResultPhoto(id="result id", photo_url="photo", thumbnail_url="thumb")
],
)
request = query.build_request(bot)
assert request.data["results"][0]["parse_mode"] is None
new_bot = Bot(token="42:TEST", parse_mode="HTML")
request = query.build_request(new_bot)
assert request.data["results"][0]["parse_mode"] == "HTML"
def test_parse_mode_input_message_content(self, bot: MockedBot):
query = AnswerInlineQuery(
inline_query_id="query id",
results=[
InlineQueryResultPhoto(
id="result id",
photo_url="photo",
thumbnail_url="thumb",
input_message_content=InputTextMessageContent(message_text="test"),
)
],
)
request = query.build_request(bot)
assert request.data["results"][0]["input_message_content"]["parse_mode"] is None
new_bot = Bot(token="42:TEST", parse_mode="HTML")
request = query.build_request(new_bot)
assert request.data["results"][0]["input_message_content"]["parse_mode"] == "HTML"

View file

@ -3,20 +3,11 @@ from tests.mocked_bot import MockedBot
class TestAnswerPreCheckoutQuery:
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
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"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,9 @@ from tests.mocked_bot import MockedBot
class TestAnswerShippingQuery:
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
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"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -4,18 +4,6 @@ from tests.mocked_bot import MockedBot
class TestAnswerWebAppQuery:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(AnswerWebAppQuery, ok=True, result=SentWebAppMessage())
response: SentWebAppMessage = await AnswerWebAppQuery(
web_app_query_id="test",
result=InlineQueryResult(),
)
request: Request = bot.get_request()
assert request.method == "answerWebAppQuery"
# assert request.data == {}
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(AnswerWebAppQuery, ok=True, result=SentWebAppMessage())
@ -23,7 +11,5 @@ class TestAnswerWebAppQuery:
web_app_query_id="test",
result=InlineQueryResult(),
)
request: Request = bot.get_request()
assert request.method == "answerWebAppQuery"
# assert request.data == {}
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,17 +3,6 @@ from tests.mocked_bot import MockedBot
class TestApproveChatJoinRequest:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(ApproveChatJoinRequest, ok=True, result=True)
response: bool = await ApproveChatJoinRequest(
chat_id=-42,
user_id=42,
)
request: Request = bot.get_request()
assert request.method == "approveChatJoinRequest"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(ApproveChatJoinRequest, ok=True, result=None)
@ -21,6 +10,5 @@ class TestApproveChatJoinRequest:
chat_id=-42,
user_id=42,
)
request: Request = bot.get_request()
assert request.method == "approveChatJoinRequest"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,9 @@ from tests.mocked_bot import MockedBot
class TestKickChatMember:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(BanChatMember, ok=True, result=True)
response: bool = await BanChatMember(chat_id=-42, user_id=42)
request: Request = bot.get_request()
assert request.method == "banChatMember"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(BanChatMember, ok=True, result=True)
response: bool = await bot.ban_chat_member(chat_id=-42, user_id=42)
request: Request = bot.get_request()
assert request.method == "banChatMember"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,6 @@ from tests.mocked_bot import MockedBot
class TestBanChatSenderChat:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(BanChatSenderChat, ok=True, result=True)
response: bool = await BanChatSenderChat(
chat_id=-42,
sender_chat_id=-1337,
)
request: Request = bot.get_request()
assert request.method == "banChatSenderChat"
# assert request.data == {}
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(BanChatSenderChat, ok=True, result=True)
@ -22,7 +10,5 @@ class TestBanChatSenderChat:
chat_id=-42,
sender_chat_id=-1337,
)
request: Request = bot.get_request()
assert request.method == "banChatSenderChat"
# assert request.data == {}
request = bot.get_request()
assert response == prepare_result.result

View file

@ -1,61 +1,27 @@
from typing import Dict, Optional
from unittest.mock import sentinel
import pytest
from aiogram import Bot
from aiogram.methods.base import prepare_parse_mode
from aiogram.methods import GetMe, TelegramMethod
from aiogram.types import User
from tests.mocked_bot import MockedBot
class TestPrepareFile:
# TODO: Add tests
pass
class TestPrepareInputMedia:
# TODO: Add tests
pass
class TestPrepareMediaFile:
# TODO: Add tests
pass
class TestPrepareParseMode:
class TestTelegramMethodRemoveUnset:
@pytest.mark.parametrize(
"parse_mode,data,result",
"values,names",
[
[None, {}, None],
["HTML", {}, "HTML"],
["Markdown", {}, "Markdown"],
[None, {"parse_mode": "HTML"}, "HTML"],
["HTML", {"parse_mode": "HTML"}, "HTML"],
["Markdown", {"parse_mode": "HTML"}, "HTML"],
[{}, set()],
[{"foo": "bar"}, {"foo"}],
[{"foo": "bar", "baz": sentinel.DEFAULT}, {"foo"}],
],
)
async def test_default_parse_mode(
self, bot: MockedBot, parse_mode: str, data: Dict[str, str], result: Optional[str]
):
async with Bot(token="42:TEST", parse_mode=parse_mode).context() as bot:
assert bot.parse_mode == parse_mode
prepare_parse_mode(bot, data)
assert data.get("parse_mode") == result
def test_remove_unset(self, values, names):
validated = TelegramMethod.remove_unset(values)
assert set(validated.keys()) == names
async def test_list(self):
data = [{}] * 2
data.append({"parse_mode": "HTML"})
bot = Bot(token="42:TEST", parse_mode="Markdown")
prepare_parse_mode(bot, data)
assert isinstance(data, list)
assert len(data) == 3
assert all("parse_mode" in item for item in data)
assert data[0]["parse_mode"] == "Markdown"
assert data[1]["parse_mode"] == "Markdown"
assert data[2]["parse_mode"] == "HTML"
def test_bot_not_in_context(self, bot: MockedBot):
data = {}
prepare_parse_mode(bot, data)
assert data["parse_mode"] is None
class TestTelegramMethodCall:
async def test_async_emit(self, bot: MockedBot):
bot.add_result_for(GetMe, ok=True, result=User(id=42, is_bot=True, first_name="Test"))
assert isinstance(await GetMe(), User)

View file

@ -3,20 +3,9 @@ from tests.mocked_bot import MockedBot
class TestClose:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(Close, ok=True, result=True)
response: bool = await Close()
request: Request = bot.get_request()
assert request.method == "close"
# assert request.data == {}
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(Close, ok=True, result=True)
response: bool = await bot.close()
request: Request = bot.get_request()
assert request.method == "close"
# assert request.data == {}
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,6 @@ from tests.mocked_bot import MockedBot
class TestCloseForumTopic:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(CloseForumTopic, ok=True, result=True)
response: bool = await CloseForumTopic(
chat_id=42,
message_thread_id=42,
)
request: Request = bot.get_request()
assert request.method == "closeForumTopic"
# assert request.data == {}
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(CloseForumTopic, ok=True, result=True)
@ -22,7 +10,5 @@ class TestCloseForumTopic:
chat_id=42,
message_thread_id=42,
)
request: Request = bot.get_request()
assert request.method == "closeForumTopic"
# assert request.data == {}
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,9 @@ from tests.mocked_bot import MockedBot
class TestCloseGeneralForumTopic:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(CloseGeneralForumTopic, ok=True, result=True)
response: bool = await bot(CloseGeneralForumTopic(chat_id=42))
request: Request = bot.get_request()
assert request.method == "closeGeneralForumTopic"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(CloseGeneralForumTopic, ok=True, result=True)
response: bool = await bot.close_general_forum_topic(chat_id=42)
request: Request = bot.get_request()
assert request.method == "closeGeneralForumTopic"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -4,19 +4,6 @@ from tests.mocked_bot import MockedBot
class TestCopyMessage:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(CopyMessage, ok=True, result=MessageId(message_id=42))
response: MessageId = await CopyMessage(
chat_id=42,
from_chat_id=42,
message_id=42,
)
request: Request = bot.get_request()
assert request.method == "copyMessage"
# assert request.data == {}
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(CopyMessage, ok=True, result=MessageId(message_id=42))
@ -25,7 +12,5 @@ class TestCopyMessage:
from_chat_id=42,
message_id=42,
)
request: Request = bot.get_request()
assert request.method == "copyMessage"
# assert request.data == {}
request = bot.get_request()
assert response == prepare_result.result

View file

@ -4,27 +4,6 @@ from tests.mocked_bot import MockedBot
class TestCreateChatInviteLink:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
CreateChatInviteLink,
ok=True,
result=ChatInviteLink(
invite_link="https://t.me/username",
creator=User(id=42, is_bot=False, first_name="User"),
is_primary=False,
is_revoked=False,
creates_join_request=False,
),
)
response: ChatInviteLink = await CreateChatInviteLink(
chat_id=-42,
)
request: Request = bot.get_request()
assert request.method == "createChatInviteLink"
# assert request.data == {"chat_id": -42}
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
CreateChatInviteLink,
@ -41,7 +20,5 @@ class TestCreateChatInviteLink:
response: ChatInviteLink = await bot.create_chat_invite_link(
chat_id=-42,
)
request: Request = bot.get_request()
assert request.method == "createChatInviteLink"
# assert request.data == {"chat_id": -42}
request = bot.get_request()
assert response == prepare_result.result

View file

@ -4,22 +4,6 @@ from tests.mocked_bot import MockedBot
class TestCreateForumTopic:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
CreateForumTopic,
ok=True,
result=ForumTopic(message_thread_id=42, name="test", icon_color=0xFFD67E),
)
response: ForumTopic = await CreateForumTopic(
chat_id=42,
name="test",
)
request: Request = bot.get_request()
assert request.method == "createForumTopic"
# assert request.data == {}
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
CreateForumTopic,
@ -31,7 +15,5 @@ class TestCreateForumTopic:
chat_id=42,
name="test",
)
request: Request = bot.get_request()
assert request.method == "createForumTopic"
# assert request.data == {}
request = bot.get_request()
assert response == prepare_result.result

View file

@ -4,23 +4,6 @@ from tests.mocked_bot import MockedBot
class TestCreateInvoiceLink:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
CreateInvoiceLink, ok=True, result="https://t.me/invoice/example"
)
response: str = await CreateInvoiceLink(
title="test",
description="test",
payload="test",
provider_token="test",
currency="BTC",
prices=[LabeledPrice(label="Test", amount=1)],
)
request: Request = bot.get_request()
assert request.method == "createInvoiceLink"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
CreateInvoiceLink, ok=True, result="https://t.me/invoice/example"
@ -34,6 +17,5 @@ class TestCreateInvoiceLink:
currency="BTC",
prices=[LabeledPrice(label="Test", amount=1)],
)
request: Request = bot.get_request()
assert request.method == "createInvoiceLink"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -5,23 +5,6 @@ from tests.mocked_bot import MockedBot
class TestCreateNewStickerSet:
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",
stickers=[
InputSticker(sticker="file id", emoji_list=[":)"]),
InputSticker(sticker=FSInputFile("file.png"), emoji_list=["=("]),
],
sticker_format=StickerFormat.STATIC,
)
request: Request = bot.get_request()
assert request.method == "createNewStickerSet"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(CreateNewStickerSet, ok=True, result=True)
@ -35,6 +18,5 @@ class TestCreateNewStickerSet:
],
sticker_format=StickerFormat.STATIC,
)
request: Request = bot.get_request()
assert request.method == "createNewStickerSet"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,17 +3,6 @@ from tests.mocked_bot import MockedBot
class TestDeclineChatJoinRequest:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(DeclineChatJoinRequest, ok=True, result=True)
response: bool = await DeclineChatJoinRequest(
chat_id=-42,
user_id=42,
)
request: Request = bot.get_request()
assert request.method == "declineChatJoinRequest"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(DeclineChatJoinRequest, ok=True, result=True)
@ -21,6 +10,5 @@ class TestDeclineChatJoinRequest:
chat_id=-42,
user_id=42,
)
request: Request = bot.get_request()
assert request.method == "declineChatJoinRequest"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,9 @@ from tests.mocked_bot import MockedBot
class TestDeleteChatPhoto:
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
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"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,9 @@ from tests.mocked_bot import MockedBot
class TestDeleteChatStickerSet:
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
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"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,6 @@ from tests.mocked_bot import MockedBot
class TestDeleteForumTopic:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(DeleteForumTopic, ok=True, result=True)
response: bool = await DeleteForumTopic(
chat_id=42,
message_thread_id=42,
)
request: Request = bot.get_request()
assert request.method == "deleteForumTopic"
# assert request.data == {}
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(DeleteForumTopic, ok=True, result=True)
@ -22,7 +10,5 @@ class TestDeleteForumTopic:
chat_id=42,
message_thread_id=42,
)
request: Request = bot.get_request()
assert request.method == "deleteForumTopic"
# assert request.data == {}
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,9 @@ from tests.mocked_bot import MockedBot
class TestDeleteMessage:
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
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"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,9 @@ from tests.mocked_bot import MockedBot
class TestKickChatMember:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(DeleteMyCommands, ok=True, result=True)
response: bool = await DeleteMyCommands()
request: Request = bot.get_request()
assert request.method == "deleteMyCommands"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(DeleteMyCommands, ok=True, result=True)
response: bool = await bot.delete_my_commands()
request: Request = bot.get_request()
assert request.method == "deleteMyCommands"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,9 @@ from tests.mocked_bot import MockedBot
class TestDeleteStickerFromSet:
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
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"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,9 @@ from tests.mocked_bot import MockedBot
class TestDeleteStickerSet:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(DeleteStickerSet, ok=True, result=True)
response: bool = await DeleteStickerSet(name="test")
request: Request = bot.get_request()
assert request.method == "deleteStickerSet"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(DeleteStickerSet, ok=True, result=True)
response: bool = await bot.delete_sticker_set(name="test")
request: Request = bot.get_request()
assert request.method == "deleteStickerSet"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,9 @@ from tests.mocked_bot import MockedBot
class TestDeleteWebhook:
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
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"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -4,26 +4,6 @@ from tests.mocked_bot import MockedBot
class TestEditChatInviteLink:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
EditChatInviteLink,
ok=True,
result=ChatInviteLink(
invite_link="https://t.me/username2",
creator=User(id=42, is_bot=False, first_name="User"),
is_primary=False,
is_revoked=False,
creates_join_request=False,
),
)
response: ChatInviteLink = await EditChatInviteLink(
chat_id=-42, invite_link="https://t.me/username", member_limit=1
)
request: Request = bot.get_request()
assert request.method == "editChatInviteLink"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
EditChatInviteLink,
@ -40,6 +20,5 @@ class TestEditChatInviteLink:
response: ChatInviteLink = await bot.edit_chat_invite_link(
chat_id=-42, invite_link="https://t.me/username", member_limit=1
)
request: Request = bot.get_request()
assert request.method == "editChatInviteLink"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,21 +3,6 @@ from tests.mocked_bot import MockedBot
class TestEditForumTopic:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(EditForumTopic, ok=True, result=True)
response: bool = await EditForumTopic(
chat_id=42,
message_thread_id=42,
name="test",
icon_color=0xFFD67E,
icon_custom_emoji_id="0",
)
request: Request = bot.get_request()
assert request.method == "editForumTopic"
# assert request.data == {}
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(EditForumTopic, ok=True, result=True)
@ -27,7 +12,5 @@ class TestEditForumTopic:
name="test",
icon_custom_emoji_id="0",
)
request: Request = bot.get_request()
assert request.method == "editForumTopic"
# assert request.data == {}
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,9 @@ from tests.mocked_bot import MockedBot
class TestCloseGeneralForumTopic:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(EditGeneralForumTopic, ok=True, result=True)
response: bool = await bot(EditGeneralForumTopic(chat_id=42, name="Test"))
request: Request = bot.get_request()
assert request.method == "editGeneralForumTopic"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(EditGeneralForumTopic, ok=True, result=True)
response: bool = await bot.edit_general_forum_topic(chat_id=42, name="Test")
request: Request = bot.get_request()
assert request.method == "editGeneralForumTopic"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -7,23 +7,6 @@ from tests.mocked_bot import MockedBot
class TestEditMessageCaption:
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
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
EditMessageCaption,
@ -37,6 +20,5 @@ class TestEditMessageCaption:
)
response: Union[Message, bool] = await bot.edit_message_caption()
request: Request = bot.get_request()
assert request.method == "editMessageCaption"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -6,22 +6,11 @@ from tests.mocked_bot import MockedBot
class TestEditMessageLiveLocation:
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
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"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -6,22 +6,11 @@ from tests.mocked_bot import MockedBot
class TestEditMessageMedia:
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=InputMediaPhoto(media=BufferedInputFile(b"", "photo.png"))
)
request: Request = bot.get_request()
assert request.method == "editMessageMedia"
assert response == prepare_result.result
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=InputMediaPhoto(media=BufferedInputFile(b"", "photo.png"))
)
request: Request = bot.get_request()
assert request.method == "editMessageMedia"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -6,22 +6,6 @@ from tests.mocked_bot import MockedBot
class TestEditMessageReplyMarkup:
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
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(EditMessageReplyMarkup, ok=True, result=True)
@ -34,6 +18,5 @@ class TestEditMessageReplyMarkup:
]
),
)
request: Request = bot.get_request()
assert request.method == "editMessageReplyMarkup"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -6,22 +6,11 @@ from tests.mocked_bot import MockedBot
class TestEditMessageText:
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
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"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,22 +3,11 @@ from tests.mocked_bot import MockedBot
class TestExportChatInviteLink:
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
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"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -6,24 +6,6 @@ from tests.mocked_bot import MockedBot
class TestForwardMessage:
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
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
ForwardMessage,
@ -37,7 +19,5 @@ class TestForwardMessage:
)
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 == {}
request = bot.get_request()
assert response == prepare_result.result

View file

@ -4,22 +4,11 @@ from tests.mocked_bot import MockedBot
class TestGetChat:
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
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"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -6,22 +6,6 @@ from tests.mocked_bot import MockedBot
class TestGetChatAdministrators:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
GetChatAdministrators,
ok=True,
result=[
ChatMemberOwner(
user=User(id=42, is_bot=False, first_name="User"), is_anonymous=False
)
],
)
response: List[ChatMember] = await GetChatAdministrators(chat_id=-42)
request: Request = bot.get_request()
assert request.method == "getChatAdministrators"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
GetChatAdministrators,
@ -33,6 +17,5 @@ class TestGetChatAdministrators:
],
)
response: List[ChatMember] = await bot.get_chat_administrators(chat_id=-42)
request: Request = bot.get_request()
assert request.method == "getChatAdministrators"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -4,20 +4,6 @@ from tests.mocked_bot import MockedBot
class TestGetChatMember:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
GetChatMember,
ok=True,
result=ChatMemberOwner(
user=User(id=42, is_bot=False, first_name="User"), is_anonymous=False
),
)
response: ChatMember = await GetChatMember(chat_id=-42, user_id=42)
request: Request = bot.get_request()
assert request.method == "getChatMember"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
GetChatMember,
@ -26,8 +12,6 @@ class TestGetChatMember:
user=User(id=42, is_bot=False, first_name="User"), is_anonymous=False
),
)
response: ChatMember = await bot.get_chat_member(chat_id=-42, user_id=42)
request: Request = bot.get_request()
assert request.method == "getChatMember"
response = await bot.get_chat_member(chat_id=-42, user_id=42)
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,9 @@ from tests.mocked_bot import MockedBot
class TestGetChatMembersCount:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(GetChatMemberCount, ok=True, result=42)
response: int = await GetChatMemberCount(chat_id=-42)
request: Request = bot.get_request()
assert request.method == "getChatMemberCount"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(GetChatMemberCount, ok=True, result=42)
response: int = await bot.get_chat_member_count(chat_id=-42)
request: Request = bot.get_request()
assert request.method == "getChatMemberCount"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -4,20 +4,9 @@ from tests.mocked_bot import MockedBot
class TestGetChatMenuButton:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(GetChatMenuButton, ok=True, result=MenuButtonDefault())
response: MenuButton = await GetChatMenuButton()
request: Request = bot.get_request()
assert request.method == "getChatMenuButton"
# assert request.data == {}
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(GetChatMenuButton, ok=True, result=MenuButtonDefault())
response: MenuButton = await bot.get_chat_menu_button()
request: Request = bot.get_request()
assert request.method == "getChatMenuButton"
# assert request.data == {}
request = bot.get_request()
assert response == prepare_result.result

View file

@ -6,32 +6,6 @@ from tests.mocked_bot import MockedBot
class TestGetCustomEmojiStickers:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
GetCustomEmojiStickers,
ok=True,
result=[
Sticker(
file_id="file id",
width=42,
height=42,
is_animated=False,
is_video=False,
file_unique_id="file id",
custom_emoji_id="1",
type="custom_emoji",
)
],
)
response: List[Sticker] = await GetCustomEmojiStickers(
custom_emoji_ids=["1"],
)
request: Request = bot.get_request()
assert request.method == "getCustomEmojiStickers"
# assert request.data == {}
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
GetCustomEmojiStickers,
@ -53,7 +27,5 @@ class TestGetCustomEmojiStickers:
response: List[Sticker] = await bot.get_custom_emoji_stickers(
custom_emoji_ids=["1", "2"],
)
request: Request = bot.get_request()
assert request.method == "getCustomEmojiStickers"
# assert request.data == {}
request = bot.get_request()
assert response == prepare_result.result

View file

@ -4,22 +4,11 @@ from tests.mocked_bot import MockedBot
class TestGetFile:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
GetFile, ok=True, result=File(file_id="file id", file_unique_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
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
GetFile, ok=True, result=File(file_id="file id", file_unique_id="file id")
)
response: File = await bot.get_file(file_id="file id")
request: Request = bot.get_request()
assert request.method == "getFile"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -6,20 +6,9 @@ from tests.mocked_bot import MockedBot
class TestGetForumTopicIconStickers:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(GetForumTopicIconStickers, ok=True, result=[])
response: List[Sticker] = await GetForumTopicIconStickers()
request: Request = bot.get_request()
assert request.method == "getForumTopicIconStickers"
# assert request.data == {}
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(GetForumTopicIconStickers, ok=True, result=[])
response: List[Sticker] = await bot.get_forum_topic_icon_stickers()
request: Request = bot.get_request()
assert request.method == "getForumTopicIconStickers"
# assert request.data == {}
request = bot.get_request()
assert response == prepare_result.result

View file

@ -6,22 +6,6 @@ from tests.mocked_bot import MockedBot
class TestGetGameHighScores:
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
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
GetGameHighScores,
@ -34,6 +18,5 @@ class TestGetGameHighScores:
)
response: List[GameHighScore] = await bot.get_game_high_scores(user_id=42)
request: Request = bot.get_request()
assert request.method == "getGameHighScores"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -4,25 +4,12 @@ from tests.mocked_bot import MockedBot
class TestGetMe:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
GetMe, ok=True, result=User(id=42, is_bot=False, first_name="User")
)
response: User = await GetMe()
request: Request = bot.get_request()
assert request.method == "getMe"
assert request.data == {}
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
GetMe, ok=True, result=User(id=42, is_bot=False, first_name="User")
)
response: User = await bot.get_me()
request: Request = bot.get_request()
assert request.method == "getMe"
assert request.data == {}
request = bot.get_request()
assert response == prepare_result.result
async def test_me_property(self, bot: MockedBot):

View file

@ -6,18 +6,9 @@ from tests.mocked_bot import MockedBot
class TestGetMyCommands:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(GetMyCommands, ok=True, result=None)
response: List[BotCommand] = await GetMyCommands()
request: Request = bot.get_request()
assert request.method == "getMyCommands"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(GetMyCommands, ok=True, result=None)
response: List[BotCommand] = await bot.get_my_commands()
request: Request = bot.get_request()
assert request.method == "getMyCommands"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -4,28 +4,6 @@ from tests.mocked_bot import MockedBot
class TestGetMyDefaultAdministratorRights:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
GetMyDefaultAdministratorRights,
ok=True,
result=ChatAdministratorRights(
is_anonymous=False,
can_manage_chat=False,
can_delete_messages=False,
can_manage_video_chats=False,
can_restrict_members=False,
can_promote_members=False,
can_change_info=False,
can_invite_users=False,
),
)
response: ChatAdministratorRights = await GetMyDefaultAdministratorRights()
request: Request = bot.get_request()
assert request.method == "getMyDefaultAdministratorRights"
# assert request.data == {}
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
GetMyDefaultAdministratorRights,
@ -43,7 +21,5 @@ class TestGetMyDefaultAdministratorRights:
)
response: ChatAdministratorRights = await bot.get_my_default_administrator_rights()
request: Request = bot.get_request()
assert request.method == "getMyDefaultAdministratorRights"
# assert request.data == {}
request = bot.get_request()
assert response == prepare_result.result

View file

@ -4,22 +4,11 @@ from tests.mocked_bot import MockedBot
class TestGetMyDescription:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
GetMyDescription, ok=True, result=BotDescription(description="Test")
)
response: BotDescription = await GetMyDescription()
request: Request = bot.get_request()
assert request.method == "getMyDescription"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
GetMyDescription, ok=True, result=BotDescription(description="Test")
)
response: BotDescription = await bot.get_my_description()
request: Request = bot.get_request()
assert request.method == "getMyDescription"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -4,22 +4,11 @@ from tests.mocked_bot import MockedBot
class TestGetMyShortDescription:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
GetMyShortDescription, ok=True, result=BotShortDescription(short_description="Test")
)
response: BotShortDescription = await GetMyShortDescription()
request: Request = bot.get_request()
assert request.method == "getMyShortDescription"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
GetMyShortDescription, ok=True, result=BotShortDescription(short_description="Test")
)
response: BotShortDescription = await bot.get_my_short_description()
request: Request = bot.get_request()
assert request.method == "getMyShortDescription"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -4,35 +4,6 @@ from tests.mocked_bot import MockedBot
class TestGetStickerSet:
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,
is_video=False,
stickers=[
Sticker(
file_id="file if",
width=42,
height=42,
is_animated=False,
is_video=False,
file_unique_id="file id",
type="regular",
)
],
sticker_type="regular",
),
)
response: StickerSet = await GetStickerSet(name="test")
request: Request = bot.get_request()
assert request.method == "getStickerSet"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
GetStickerSet,
@ -58,6 +29,5 @@ class TestGetStickerSet:
)
response: StickerSet = await bot.get_sticker_set(name="test")
request: Request = bot.get_request()
assert request.method == "getStickerSet"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -6,18 +6,9 @@ from tests.mocked_bot import MockedBot
class TestGetUpdates:
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
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"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -4,23 +4,6 @@ from tests.mocked_bot import MockedBot
class TestGetUserProfilePhotos:
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, file_unique_id="file id")]
],
),
)
response: UserProfilePhotos = await GetUserProfilePhotos(user_id=42)
request: Request = bot.get_request()
assert request.method == "getUserProfilePhotos"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
GetUserProfilePhotos,
@ -34,6 +17,5 @@ class TestGetUserProfilePhotos:
)
response: UserProfilePhotos = await bot.get_user_profile_photos(user_id=42)
request: Request = bot.get_request()
assert request.method == "getUserProfilePhotos"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -4,20 +4,6 @@ from tests.mocked_bot import MockedBot
class TestGetWebhookInfo:
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
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
GetWebhookInfo,
@ -28,6 +14,5 @@ class TestGetWebhookInfo:
)
response: WebhookInfo = await bot.get_webhook_info()
request: Request = bot.get_request()
assert request.method == "getWebhookInfo"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,9 @@ from tests.mocked_bot import MockedBot
class TestHideGeneralForumTopic:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(HideGeneralForumTopic, ok=True, result=True)
response: bool = await bot(HideGeneralForumTopic(chat_id=42))
request: Request = bot.get_request()
assert request.method == "hideGeneralForumTopic"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(HideGeneralForumTopic, ok=True, result=True)
response: bool = await bot.hide_general_forum_topic(chat_id=42)
request: Request = bot.get_request()
assert request.method == "hideGeneralForumTopic"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,9 @@ from tests.mocked_bot import MockedBot
class TestLeaveChat:
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
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"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,20 +3,9 @@ from tests.mocked_bot import MockedBot
class TestLogOut:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(LogOut, ok=True, result=True)
response: bool = await LogOut()
request: Request = bot.get_request()
assert request.method == "logOut"
# assert request.data == {}
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(LogOut, ok=True, result=True)
response: bool = await bot.log_out()
request: Request = bot.get_request()
assert request.method == "logOut"
# assert request.data == {}
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,9 @@ from tests.mocked_bot import MockedBot
class TestPinChatMessage:
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
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"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,9 @@ from tests.mocked_bot import MockedBot
class TestPromoteChatMember:
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
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"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,6 @@ from tests.mocked_bot import MockedBot
class TestReopenForumTopic:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(ReopenForumTopic, ok=True, result=None)
response: bool = await ReopenForumTopic(
chat_id=42,
message_thread_id=42,
)
request: Request = bot.get_request()
assert request.method == "reopenForumTopic"
# assert request.data == {}
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(ReopenForumTopic, ok=True, result=None)
@ -22,7 +10,5 @@ class TestReopenForumTopic:
chat_id=42,
message_thread_id=42,
)
request: Request = bot.get_request()
assert request.method == "reopenForumTopic"
# assert request.data == {}
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,9 @@ from tests.mocked_bot import MockedBot
class TestReopenGeneralForumTopic:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(ReopenGeneralForumTopic, ok=True, result=True)
response: bool = await bot(ReopenGeneralForumTopic(chat_id=42))
request: Request = bot.get_request()
assert request.method == "reopenGeneralForumTopic"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(ReopenGeneralForumTopic, ok=True, result=True)
response: bool = await bot.reopen_general_forum_topic(chat_id=42)
request: Request = bot.get_request()
assert request.method == "reopenGeneralForumTopic"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -4,22 +4,11 @@ from tests.mocked_bot import MockedBot
class TestRestrictChatMember:
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
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"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -4,27 +4,6 @@ from tests.mocked_bot import MockedBot
class TestRevokeChatInviteLink:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
RevokeChatInviteLink,
ok=True,
result=ChatInviteLink(
invite_link="https://t.me/username",
creator=User(id=42, is_bot=False, first_name="User"),
is_primary=False,
is_revoked=True,
creates_join_request=False,
),
)
response: ChatInviteLink = await RevokeChatInviteLink(
chat_id=-42,
invite_link="https://t.me/username",
)
request: Request = bot.get_request()
assert request.method == "revokeChatInviteLink"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
RevokeChatInviteLink,
@ -42,6 +21,5 @@ class TestRevokeChatInviteLink:
chat_id=-42,
invite_link="https://t.me/username",
)
request: Request = bot.get_request()
assert request.method == "revokeChatInviteLink"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -6,25 +6,6 @@ from tests.mocked_bot import MockedBot
class TestSendAnimation:
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, file_unique_id="file id"
),
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
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendAnimation,
@ -40,6 +21,5 @@ class TestSendAnimation:
)
response: Message = await bot.send_animation(chat_id=42, animation="file id")
request: Request = bot.get_request()
assert request.method == "sendAnimation"
request = bot.get_request()
assert response == prepare_result.result

View file

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

View file

@ -4,27 +4,9 @@ from tests.mocked_bot import MockedBot
class TestSendChatAction:
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
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
async def test_chat_action_class(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=ChatAction.TYPING)
request: Request = bot.get_request()
assert request.method == "sendChatAction"
assert request.data["action"] == "typing"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -6,23 +6,6 @@ from tests.mocked_bot import MockedBot
class TestSendContact:
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
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendContact,
@ -38,6 +21,5 @@ class TestSendContact:
response: Message = await bot.send_contact(
chat_id=42, phone_number="911", first_name="911"
)
request: Request = bot.get_request()
assert request.method == "sendContact"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -4,18 +4,9 @@ from tests.mocked_bot import MockedBot
class TestSendDice:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SendDice, ok=True, result=None)
response: Message = await SendDice(chat_id=42)
request: Request = bot.get_request()
assert request.method == "sendDice"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SendDice, ok=True, result=None)
response: Message = await bot.send_dice(chat_id=42)
request: Request = bot.get_request()
assert request.method == "sendDice"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -6,23 +6,6 @@ from tests.mocked_bot import MockedBot
class TestSendDocument:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendDocument,
ok=True,
result=Message(
message_id=42,
date=datetime.datetime.now(),
document=Document(file_id="file id", file_unique_id="file id"),
chat=Chat(id=42, type="private"),
),
)
response: Message = await SendDocument(chat_id=42, document="file id")
request: Request = bot.get_request()
assert request.method == "sendDocument"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendDocument,
@ -36,6 +19,5 @@ class TestSendDocument:
)
response: Message = await bot.send_document(chat_id=42, document="file id")
request: Request = bot.get_request()
assert request.method == "sendDocument"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -6,29 +6,6 @@ from tests.mocked_bot import MockedBot
class TestSendGame:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendGame,
ok=True,
result=Message(
message_id=42,
date=datetime.datetime.now(),
game=Game(
title="title",
description="description",
photo=[
PhotoSize(file_id="file id", width=42, height=42, file_unique_id="file id")
],
),
chat=Chat(id=42, type="private"),
),
)
response: Message = await SendGame(chat_id=42, game_short_name="game")
request: Request = bot.get_request()
assert request.method == "sendGame"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendGame,
@ -48,6 +25,5 @@ class TestSendGame:
)
response: Message = await bot.send_game(chat_id=42, game_short_name="game")
request: Request = bot.get_request()
assert request.method == "sendGame"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -6,38 +6,6 @@ from tests.mocked_bot import MockedBot
class TestSendInvoice:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendInvoice,
ok=True,
result=Message(
message_id=42,
date=datetime.datetime.now(),
invoice=Invoice(
title="test",
description="test",
start_parameter="brilliant",
currency="BTC",
total_amount=1,
),
chat=Chat(id=42, type="private"),
),
)
response: Message = await SendInvoice(
chat_id=42,
title="test",
description="test",
payload="payload",
provider_token="TEST:token",
start_parameter="brilliant",
currency="BTC",
prices=[LabeledPrice(amount=1, label="test")],
)
request: Request = bot.get_request()
assert request.method == "sendInvoice"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendInvoice,
@ -66,6 +34,5 @@ class TestSendInvoice:
currency="BTC",
prices=[LabeledPrice(amount=1, label="test")],
)
request: Request = bot.get_request()
assert request.method == "sendInvoice"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -6,23 +6,6 @@ from tests.mocked_bot import MockedBot
class TestSendLocation:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendLocation,
ok=True,
result=Message(
message_id=42,
date=datetime.datetime.now(),
location=Location(longitude=3.14, latitude=3.14),
chat=Chat(id=42, type="private"),
),
)
response: Message = await SendLocation(chat_id=42, latitude=3.14, longitude=3.14)
request: Request = bot.get_request()
assert request.method == "sendLocation"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendLocation,
@ -36,6 +19,5 @@ class TestSendLocation:
)
response: Message = await bot.send_location(chat_id=42, latitude=3.14, longitude=3.14)
request: Request = bot.get_request()
assert request.method == "sendLocation"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -15,47 +15,6 @@ from tests.mocked_bot import MockedBot
class TestSendMediaGroup:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendMediaGroup,
ok=True,
result=[
Message(
message_id=42,
date=datetime.datetime.now(),
photo=[
PhotoSize(file_id="file id", width=42, height=42, file_unique_id="file id")
],
media_group_id="media group",
chat=Chat(id=42, type="private"),
),
Message(
message_id=43,
date=datetime.datetime.now(),
video=Video(
file_id="file id",
width=42,
height=42,
duration=0,
file_unique_id="file id",
),
media_group_id="media group",
chat=Chat(id=42, type="private"),
),
],
)
response: List[Message] = await SendMediaGroup(
chat_id=42,
media=[
InputMediaPhoto(media="file id"),
InputMediaVideo(media=BufferedInputFile(b"", "video.mp4")),
],
)
request: Request = bot.get_request()
assert request.method == "sendMediaGroup"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendMediaGroup,
@ -93,6 +52,5 @@ class TestSendMediaGroup:
InputMediaVideo(media=BufferedInputFile(b"", "video.mp4")),
],
)
request: Request = bot.get_request()
assert request.method == "sendMediaGroup"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -6,23 +6,6 @@ from tests.mocked_bot import MockedBot
class TestSendMessage:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendMessage,
ok=True,
result=Message(
message_id=42,
date=datetime.datetime.now(),
text="test",
chat=Chat(id=42, type="private"),
),
)
response: Message = await SendMessage(chat_id=42, text="test")
request: Request = bot.get_request()
assert request.method == "sendMessage"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendMessage,
@ -36,8 +19,7 @@ class TestSendMessage:
)
response: Message = await bot.send_message(chat_id=42, text="test")
request: Request = bot.get_request()
assert request.method == "sendMessage"
request = bot.get_request()
assert response == prepare_result.result
async def test_force_reply(self):

View file

@ -6,25 +6,6 @@ from tests.mocked_bot import MockedBot
class TestSendPhoto:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendPhoto,
ok=True,
result=Message(
message_id=42,
date=datetime.datetime.now(),
photo=[
PhotoSize(file_id="file id", width=42, height=42, file_unique_id="file id")
],
chat=Chat(id=42, type="private"),
),
)
response: Message = await SendPhoto(chat_id=42, photo="file id")
request: Request = bot.get_request()
assert request.method == "sendPhoto"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendPhoto,
@ -40,6 +21,5 @@ class TestSendPhoto:
)
response: Message = await bot.send_photo(chat_id=42, photo="file id")
request: Request = bot.get_request()
assert request.method == "sendPhoto"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -6,38 +6,6 @@ from tests.mocked_bot import MockedBot
class TestSendPoll:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendPoll,
ok=True,
result=Message(
message_id=42,
date=datetime.datetime.now(),
poll=Poll(
id="QA",
question="Q",
options=[
PollOption(text="A", voter_count=0),
PollOption(text="B", voter_count=0),
],
is_closed=False,
is_anonymous=False,
type="quiz",
allows_multiple_answers=False,
total_voter_count=0,
correct_option_id=0,
),
chat=Chat(id=42, type="private"),
),
)
response: Message = await SendPoll(
chat_id=42, question="Q?", options=["A", "B"], correct_option_id=0, type="quiz"
)
request: Request = bot.get_request()
assert request.method == "sendPoll"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendPoll,
@ -66,6 +34,5 @@ class TestSendPoll:
response: Message = await bot.send_poll(
chat_id=42, question="Q?", options=["A", "B"], correct_option_id=0, type="quiz"
)
request: Request = bot.get_request()
assert request.method == "sendPoll"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -6,31 +6,6 @@ from tests.mocked_bot import MockedBot
class TestSendSticker:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendSticker,
ok=True,
result=Message(
message_id=42,
date=datetime.datetime.now(),
sticker=Sticker(
file_id="file id",
width=42,
height=42,
is_animated=False,
is_video=False,
file_unique_id="file id",
type="regular",
),
chat=Chat(id=42, type="private"),
),
)
response: Message = await SendSticker(chat_id=42, sticker="file id")
request: Request = bot.get_request()
assert request.method == "sendSticker"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendSticker,
@ -52,6 +27,5 @@ class TestSendSticker:
)
response: Message = await bot.send_sticker(chat_id=42, sticker="file id")
request: Request = bot.get_request()
assert request.method == "sendSticker"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -6,35 +6,6 @@ from tests.mocked_bot import MockedBot
class TestSendVenue:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendVenue,
ok=True,
result=Message(
message_id=42,
date=datetime.datetime.now(),
venue=Venue(
location=Location(latitude=3.14, longitude=3.14),
title="Cupboard Under the Stairs",
address="Under the stairs, 4 Privet Drive, "
"Little Whinging, Surrey, England, Great Britain",
),
chat=Chat(id=42, type="private"),
),
)
response: Message = await SendVenue(
chat_id=42,
latitude=3.14,
longitude=3.14,
title="Cupboard Under the Stairs",
address="Under the stairs, 4 Privet Drive, "
"Little Whinging, Surrey, England, Great Britain",
)
request: Request = bot.get_request()
assert request.method == "sendVenue"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendVenue,
@ -60,6 +31,5 @@ class TestSendVenue:
address="Under the stairs, 4 Privet Drive, "
"Little Whinging, Surrey, England, Great Britain",
)
request: Request = bot.get_request()
assert request.method == "sendVenue"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -6,25 +6,6 @@ from tests.mocked_bot import MockedBot
class TestSendVideo:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendVideo,
ok=True,
result=Message(
message_id=42,
date=datetime.datetime.now(),
video=Video(
file_id="file id", width=42, height=42, duration=0, file_unique_id="file id"
),
chat=Chat(id=42, type="private"),
),
)
response: Message = await SendVideo(chat_id=42, video="file id")
request: Request = bot.get_request()
assert request.method == "sendVideo"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendVideo,
@ -40,6 +21,5 @@ class TestSendVideo:
)
response: Message = await bot.send_video(chat_id=42, video="file id")
request: Request = bot.get_request()
assert request.method == "sendVideo"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -6,29 +6,6 @@ from tests.mocked_bot import MockedBot
class TestSendVideoNote:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendVideoNote,
ok=True,
result=Message(
message_id=42,
date=datetime.datetime.now(),
video_note=VideoNote(
file_id="file id", length=0, duration=0, file_unique_id="file id"
),
chat=Chat(id=42, type="private"),
),
)
response: Message = await SendVideoNote(
chat_id=42,
video_note="file id",
thumbnail=BufferedInputFile(b"", "file.png"),
)
request: Request = bot.get_request()
assert request.method == "sendVideoNote"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendVideoNote,
@ -48,6 +25,5 @@ class TestSendVideoNote:
video_note="file id",
thumbnail=BufferedInputFile(b"", "file.png"),
)
request: Request = bot.get_request()
assert request.method == "sendVideoNote"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -6,23 +6,6 @@ from tests.mocked_bot import MockedBot
class TestSendVoice:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendVoice,
ok=True,
result=Message(
message_id=42,
date=datetime.datetime.now(),
voice=Voice(file_id="file id", duration=0, file_unique_id="file id"),
chat=Chat(id=42, type="private"),
),
)
response: Message = await SendVoice(chat_id=42, voice="file id")
request: Request = bot.get_request()
assert request.method == "sendVoice"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SendVoice,
@ -36,6 +19,5 @@ class TestSendVoice:
)
response: Message = await bot.send_voice(chat_id=42, voice="file id")
request: Request = bot.get_request()
assert request.method == "sendVoice"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,22 +3,11 @@ from tests.mocked_bot import MockedBot
class TestSetChatTitle:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetChatAdministratorCustomTitle, ok=True, result=True)
response: bool = await SetChatAdministratorCustomTitle(
chat_id=-42, user_id=42, custom_title="test chat"
)
request: Request = bot.get_request()
assert request.method == "setChatAdministratorCustomTitle"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetChatAdministratorCustomTitle, ok=True, result=True)
response: bool = await bot.set_chat_administrator_custom_title(
chat_id=-42, user_id=42, custom_title="test chat"
)
request: Request = bot.get_request()
assert request.method == "setChatAdministratorCustomTitle"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,9 @@ from tests.mocked_bot import MockedBot
class TestSetChatDescription:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetChatDescription, ok=True, result=True)
response: bool = await SetChatDescription(chat_id=-42, description="awesome chat")
request: Request = bot.get_request()
assert request.method == "setChatDescription"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetChatDescription, ok=True, result=True)
response: bool = await bot.set_chat_description(chat_id=-42, description="awesome chat")
request: Request = bot.get_request()
assert request.method == "setChatDescription"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,20 +3,9 @@ from tests.mocked_bot import MockedBot
class TestSetChatMenuButton:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetChatMenuButton, ok=True, result=True)
response: bool = await SetChatMenuButton()
request: Request = bot.get_request()
assert request.method == "setChatMenuButton"
# assert request.data == {}
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetChatMenuButton, ok=True, result=True)
response: bool = await bot.set_chat_menu_button()
request: Request = bot.get_request()
assert request.method == "setChatMenuButton"
# assert request.data == {}
request = bot.get_request()
assert response == prepare_result.result

View file

@ -4,22 +4,11 @@ from tests.mocked_bot import MockedBot
class TestSetChatPermissions:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetChatPermissions, ok=True, result=True)
response: bool = await SetChatPermissions(
chat_id=-42, permissions=ChatPermissions(can_send_messages=False)
)
request: Request = bot.get_request()
assert request.method == "setChatPermissions"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetChatPermissions, ok=True, result=True)
response: bool = await bot.set_chat_permissions(
chat_id=-42, permissions=ChatPermissions(can_send_messages=False)
)
request: Request = bot.get_request()
assert request.method == "setChatPermissions"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -4,22 +4,11 @@ from tests.mocked_bot import MockedBot
class TestSetChatPhoto:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetChatPhoto, ok=True, result=True)
response: bool = await SetChatPhoto(
chat_id=-42, photo=BufferedInputFile(b"", filename="file.png")
)
request: Request = bot.get_request()
assert request.method == "setChatPhoto"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetChatPhoto, ok=True, result=True)
response: bool = await bot.set_chat_photo(
chat_id=-42, photo=BufferedInputFile(b"", filename="file.png")
)
request: Request = bot.get_request()
assert request.method == "setChatPhoto"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,9 @@ from tests.mocked_bot import MockedBot
class TestSetChatStickerSet:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetChatStickerSet, ok=True, result=True)
response: bool = await SetChatStickerSet(chat_id=-42, sticker_set_name="test")
request: Request = bot.get_request()
assert request.method == "setChatStickerSet"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetChatStickerSet, ok=True, result=True)
response: bool = await bot.set_chat_sticker_set(chat_id=-42, sticker_set_name="test")
request: Request = bot.get_request()
assert request.method == "setChatStickerSet"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,9 @@ from tests.mocked_bot import MockedBot
class TestSetChatTitle:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetChatTitle, ok=True, result=True)
response: bool = await SetChatTitle(chat_id=-42, title="test chat")
request: Request = bot.get_request()
assert request.method == "setChatTitle"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetChatTitle, ok=True, result=True)
response: bool = await bot.set_chat_title(chat_id=-42, title="test chat")
request: Request = bot.get_request()
assert request.method == "setChatTitle"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,6 @@ from tests.mocked_bot import MockedBot
class TestSetCustomEmojiStickerSetThumbnail:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SetCustomEmojiStickerSetThumbnail, ok=True, result=True
)
response: bool = await SetCustomEmojiStickerSetThumbnail(
name="test", custom_emoji_id="custom id"
)
request: Request = bot.get_request()
assert request.method == "setCustomEmojiStickerSetThumbnail"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
SetCustomEmojiStickerSetThumbnail, ok=True, result=True
@ -23,6 +11,5 @@ class TestSetCustomEmojiStickerSetThumbnail:
response: bool = await bot.set_custom_emoji_sticker_set_thumbnail(
name="test", custom_emoji_id="custom id"
)
request: Request = bot.get_request()
assert request.method == "setCustomEmojiStickerSetThumbnail"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -6,22 +6,11 @@ from tests.mocked_bot import MockedBot
class TestSetGameScore:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetGameScore, ok=True, result=True)
response: Union[Message, bool] = await SetGameScore(
user_id=42, score=100500, inline_message_id="inline message"
)
request: Request = bot.get_request()
assert request.method == "setGameScore"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetGameScore, ok=True, result=True)
response: Union[Message, bool] = await bot.set_game_score(
user_id=42, score=100500, inline_message_id="inline message"
)
request: Request = bot.get_request()
assert request.method == "setGameScore"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -4,23 +4,11 @@ from tests.mocked_bot import MockedBot
class TestSetMyCommands:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetMyCommands, ok=True, result=None)
response: bool = await SetMyCommands(
commands=[BotCommand(command="command", description="Bot command")],
)
request: Request = bot.get_request()
assert request.method == "setMyCommands"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetMyCommands, ok=True, result=None)
response: bool = await bot.set_my_commands(
commands=[],
)
request: Request = bot.get_request()
assert request.method == "setMyCommands"
# assert request.data == {}
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,20 +3,9 @@ from tests.mocked_bot import MockedBot
class TestSetMyDefaultAdministratorRights:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetMyDefaultAdministratorRights, ok=True, result=True)
response: bool = await SetMyDefaultAdministratorRights()
request: Request = bot.get_request()
assert request.method == "setMyDefaultAdministratorRights"
# assert request.data == {}
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetMyDefaultAdministratorRights, ok=True, result=True)
response: bool = await bot.set_my_default_administrator_rights()
request: Request = bot.get_request()
assert request.method == "setMyDefaultAdministratorRights"
# assert request.data == {}
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,9 @@ from tests.mocked_bot import MockedBot
class TestSetMyDescription:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetMyDescription, ok=True, result=True)
response: bool = await SetMyDescription(description="Test")
request: Request = bot.get_request()
assert request.method == "setMyDescription"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetMyDescription, ok=True, result=True)
response: bool = await bot.set_my_description(description="Test")
request: Request = bot.get_request()
assert request.method == "setMyDescription"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,9 @@ from tests.mocked_bot import MockedBot
class TestSetMyShortDescription:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetMyShortDescription, ok=True, result=True)
response: bool = await SetMyShortDescription(short_description="Test")
request: Request = bot.get_request()
assert request.method == "setMyShortDescription"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetMyShortDescription, ok=True, result=True)
response: bool = await bot.set_my_short_description(short_description="Test")
request: Request = bot.get_request()
assert request.method == "setMyShortDescription"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -4,20 +4,11 @@ from tests.mocked_bot import MockedBot
class TestSetPassportDataErrors:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetPassportDataErrors, ok=True, result=True)
response: bool = await SetPassportDataErrors(user_id=42, errors=[PassportElementError()])
request: Request = bot.get_request()
assert request.method == "setPassportDataErrors"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetPassportDataErrors, ok=True, result=True)
response: bool = await bot.set_passport_data_errors(
user_id=42, errors=[PassportElementError()]
)
request: Request = bot.get_request()
assert request.method == "setPassportDataErrors"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,9 @@ from tests.mocked_bot import MockedBot
class TestSetStickerEmojiList:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetStickerEmojiList, ok=True, result=True)
response: bool = await SetStickerEmojiList(sticker="sticker id", emoji_list=["X"])
request: Request = bot.get_request()
assert request.method == "setStickerEmojiList"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetStickerEmojiList, ok=True, result=True)
response: bool = await bot.set_sticker_emoji_list(sticker="sticker id", emoji_list=["X"])
request: Request = bot.get_request()
assert request.method == "setStickerEmojiList"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,9 @@ from tests.mocked_bot import MockedBot
class TestSetStickerKeywords:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetStickerKeywords, ok=True, result=True)
response: bool = await SetStickerKeywords(sticker="sticker id", keywords=["X"])
request: Request = bot.get_request()
assert request.method == "setStickerKeywords"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetStickerKeywords, ok=True, result=True)
response: bool = await bot.set_sticker_keywords(sticker="sticker id", keywords=["X"])
request: Request = bot.get_request()
assert request.method == "setStickerKeywords"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,9 @@ from tests.mocked_bot import MockedBot
class TestSetStickerEmojiList:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetStickerMaskPosition, ok=True, result=True)
response: bool = await SetStickerMaskPosition(sticker="sticker id")
request: Request = bot.get_request()
assert request.method == "setStickerMaskPosition"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetStickerMaskPosition, ok=True, result=True)
response: bool = await bot.set_sticker_mask_position(sticker="sticker id")
request: Request = bot.get_request()
assert request.method == "setStickerMaskPosition"
request = bot.get_request()
assert response == prepare_result.result

View file

@ -3,18 +3,9 @@ from tests.mocked_bot import MockedBot
class TestSetStickerPositionInSet:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetStickerPositionInSet, ok=True, result=True)
response: bool = await SetStickerPositionInSet(sticker="sticker", position=42)
request: Request = bot.get_request()
assert request.method == "setStickerPositionInSet"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetStickerPositionInSet, ok=True, result=True)
response: bool = await bot.set_sticker_position_in_set(sticker="sticker", position=42)
request: Request = bot.get_request()
assert request.method == "setStickerPositionInSet"
request = bot.get_request()
assert response == prepare_result.result

Some files were not shown because too many files have changed in this diff Show more