mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Fix tests, improved docs
This commit is contained in:
parent
e5644248f9
commit
c8ad7552a2
27 changed files with 296 additions and 206 deletions
|
|
@ -1,19 +1,18 @@
|
|||
import pytest
|
||||
|
||||
from aiogram.methods import AnswerWebAppQuery, Request
|
||||
from aiogram.types import SentWebAppMessage
|
||||
from aiogram.types import InlineQueryResult, SentWebAppMessage
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
@pytest.mark.skip
|
||||
class TestAnswerWebAppQuery:
|
||||
@pytest.mark.asyncio
|
||||
async def test_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(AnswerWebAppQuery, ok=True, result=None)
|
||||
prepare_result = bot.add_result_for(AnswerWebAppQuery, ok=True, result=SentWebAppMessage())
|
||||
|
||||
response: SentWebAppMessage = await AnswerWebAppQuery(
|
||||
web_app_query_id=...,
|
||||
result=...,
|
||||
web_app_query_id="test",
|
||||
result=InlineQueryResult(),
|
||||
)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "answerWebAppQuery"
|
||||
|
|
@ -22,11 +21,11 @@ class TestAnswerWebAppQuery:
|
|||
|
||||
@pytest.mark.asyncio
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(AnswerWebAppQuery, ok=True, result=None)
|
||||
prepare_result = bot.add_result_for(AnswerWebAppQuery, ok=True, result=SentWebAppMessage())
|
||||
|
||||
response: SentWebAppMessage = await bot.answer_web_app_query(
|
||||
web_app_query_id=...,
|
||||
result=...,
|
||||
web_app_query_id="test",
|
||||
result=InlineQueryResult(),
|
||||
)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "answerWebAppQuery"
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
import pytest
|
||||
|
||||
from aiogram.methods import GetChatMenuButton, Request
|
||||
from aiogram.types import MenuButton
|
||||
from aiogram.types import MenuButton, MenuButtonDefault
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
@pytest.mark.skip
|
||||
class TestGetChatMenuButton:
|
||||
@pytest.mark.asyncio
|
||||
async def test_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(GetChatMenuButton, ok=True, result=None)
|
||||
prepare_result = bot.add_result_for(GetChatMenuButton, ok=True, result=MenuButtonDefault())
|
||||
|
||||
response: MenuButton = await GetChatMenuButton()
|
||||
request: Request = bot.get_request()
|
||||
|
|
@ -19,7 +18,7 @@ class TestGetChatMenuButton:
|
|||
|
||||
@pytest.mark.asyncio
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(GetChatMenuButton, ok=True, result=None)
|
||||
prepare_result = bot.add_result_for(GetChatMenuButton, ok=True, result=MenuButtonDefault())
|
||||
|
||||
response: MenuButton = await bot.get_chat_menu_button()
|
||||
request: Request = bot.get_request()
|
||||
|
|
|
|||
|
|
@ -5,11 +5,23 @@ from aiogram.types import ChatAdministratorRights
|
|||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
@pytest.mark.skip
|
||||
class TestGetMyDefaultAdministratorRights:
|
||||
@pytest.mark.asyncio
|
||||
async def test_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(GetMyDefaultAdministratorRights, ok=True, result=None)
|
||||
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()
|
||||
|
|
@ -19,7 +31,20 @@ class TestGetMyDefaultAdministratorRights:
|
|||
|
||||
@pytest.mark.asyncio
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(GetMyDefaultAdministratorRights, ok=True, result=None)
|
||||
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 bot.get_my_default_administrator_rights()
|
||||
request: Request = bot.get_request()
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ class TestGetStickerSet:
|
|||
name="test",
|
||||
title="test",
|
||||
is_animated=False,
|
||||
is_video=False,
|
||||
contains_masks=False,
|
||||
stickers=[
|
||||
Sticker(
|
||||
|
|
@ -23,6 +24,7 @@ class TestGetStickerSet:
|
|||
width=42,
|
||||
height=42,
|
||||
is_animated=False,
|
||||
is_video=False,
|
||||
file_unique_id="file id",
|
||||
)
|
||||
],
|
||||
|
|
@ -42,6 +44,7 @@ class TestGetStickerSet:
|
|||
name="test",
|
||||
title="test",
|
||||
is_animated=False,
|
||||
is_video=False,
|
||||
contains_masks=False,
|
||||
stickers=[
|
||||
Sticker(
|
||||
|
|
@ -49,6 +52,7 @@ class TestGetStickerSet:
|
|||
width=42,
|
||||
height=42,
|
||||
is_animated=False,
|
||||
is_video=False,
|
||||
file_unique_id="file id",
|
||||
)
|
||||
],
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ class TestSendSticker:
|
|||
width=42,
|
||||
height=42,
|
||||
is_animated=False,
|
||||
is_video=False,
|
||||
file_unique_id="file id",
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
|
|
@ -45,6 +46,7 @@ class TestSendSticker:
|
|||
width=42,
|
||||
height=42,
|
||||
is_animated=False,
|
||||
is_video=False,
|
||||
file_unique_id="file id",
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
import pytest
|
||||
|
||||
from aiogram.api.methods import Request, SetChatMenuButton
|
||||
from aiogram.methods import Request, SetChatMenuButton
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
@pytest.mark.skip
|
||||
class TestSetChatMenuButton:
|
||||
@pytest.mark.asyncio
|
||||
async def test_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetChatMenuButton, ok=True, result=None)
|
||||
prepare_result = bot.add_result_for(SetChatMenuButton, ok=True, result=True)
|
||||
|
||||
response: bool = await SetChatMenuButton()
|
||||
request: Request = bot.get_request()
|
||||
|
|
@ -18,7 +17,7 @@ class TestSetChatMenuButton:
|
|||
|
||||
@pytest.mark.asyncio
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetChatMenuButton, ok=True, result=None)
|
||||
prepare_result = bot.add_result_for(SetChatMenuButton, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.set_chat_menu_button()
|
||||
request: Request = bot.get_request()
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
import pytest
|
||||
|
||||
from aiogram.api.methods import Request, SetMyDefaultAdministratorRights
|
||||
from aiogram.methods import Request, SetMyDefaultAdministratorRights
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
@pytest.mark.skip
|
||||
class TestSetMyDefaultAdministratorRights:
|
||||
@pytest.mark.asyncio
|
||||
async def test_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetMyDefaultAdministratorRights, ok=True, result=None)
|
||||
prepare_result = bot.add_result_for(SetMyDefaultAdministratorRights, ok=True, result=True)
|
||||
|
||||
response: bool = await SetMyDefaultAdministratorRights()
|
||||
request: Request = bot.get_request()
|
||||
|
|
@ -18,7 +17,7 @@ class TestSetMyDefaultAdministratorRights:
|
|||
|
||||
@pytest.mark.asyncio
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SetMyDefaultAdministratorRights, ok=True, result=None)
|
||||
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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue