aiogram/tests/test_api/test_methods/test_get_chat_member.py
Alex Root Junior ac2b0bb198
[3.x] Bot API 5.3 + Improvements (#618)
* Regenerate API

* Update code

* Fixed command filter for photos

* Fix tests so they are able to run

* Test new and renamed API methods

* Reformat files

* Fix outer_middleware resolution (#637) (#640)

* Fix outer_middleware resolution (#637)

* Reformat files

* Reorder routers when resolve middlewares

Co-authored-by: Alex Root Junior <jroot.junior@gmail.com>

* Added possibility to use empty callback data factory filter

* Rename KeyboardConstructor to KeyboardBuilder

* Fixed type

Co-authored-by: evgfilim1 <evgfilim1@yandex.ru>
2021-07-29 00:40:50 +03:00

37 lines
1.2 KiB
Python

import pytest
from aiogram.methods import GetChatMember, Request
from aiogram.types import ChatMember, ChatMemberOwner, User
from tests.mocked_bot import MockedBot
class TestGetChatMember:
@pytest.mark.asyncio
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
GetChatMember,
ok=True,
result=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
@pytest.mark.asyncio
async def test_bot_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 bot.get_chat_member(chat_id=-42, user_id=42)
request: Request = bot.get_request()
assert request.method == "getChatMember"
assert response == prepare_result.result