mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Test new and renamed API methods
This commit is contained in:
parent
769ae8124c
commit
16eac75332
3 changed files with 72 additions and 0 deletions
24
tests/test_api/test_methods/test_ban_chat_member.py
Normal file
24
tests/test_api/test_methods/test_ban_chat_member.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import pytest
|
||||
|
||||
from aiogram.methods import BanChatMember, Request
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestKickChatMember:
|
||||
@pytest.mark.asyncio
|
||||
async def test_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(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
|
||||
|
||||
@pytest.mark.asyncio
|
||||
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"
|
||||
assert response == prepare_result.result
|
||||
24
tests/test_api/test_methods/test_delete_my_commands.py
Normal file
24
tests/test_api/test_methods/test_delete_my_commands.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import pytest
|
||||
|
||||
from aiogram.methods import BanChatMember, Request, DeleteMyCommands
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestKickChatMember:
|
||||
@pytest.mark.asyncio
|
||||
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
|
||||
|
||||
@pytest.mark.asyncio
|
||||
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"
|
||||
assert response == prepare_result.result
|
||||
24
tests/test_api/test_methods/test_get_chat_member_count.py
Normal file
24
tests/test_api/test_methods/test_get_chat_member_count.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import pytest
|
||||
|
||||
from aiogram.methods import GetChatMemberCount, Request
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestGetChatMembersCount:
|
||||
@pytest.mark.asyncio
|
||||
async def test_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(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
|
||||
|
||||
@pytest.mark.asyncio
|
||||
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"
|
||||
assert response == prepare_result.result
|
||||
Loading…
Add table
Add a link
Reference in a new issue