Test new and renamed API methods

This commit is contained in:
evgfilim1 2021-07-24 17:04:55 +05:00
parent 769ae8124c
commit 16eac75332
No known key found for this signature in database
GPG key ID: 16AEE4D0BB188AEC
3 changed files with 72 additions and 0 deletions

View 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

View 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

View 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