예제 #1
0
파일: test_bot.py 프로젝트: vip-v2a/aiogram
async def test_get_chat_member(bot: Bot, event_loop):
    """ getChatMember method test """
    from .types.dataset import CHAT, CHAT_MEMBER
    chat = types.Chat(**CHAT)
    member = types.ChatMember(**CHAT_MEMBER)

    async with FakeTelegram(message_data=CHAT_MEMBER, loop=event_loop):
        result = await bot.get_chat_member(chat_id=chat.id,
                                           user_id=member.user.id)
        assert isinstance(result, types.ChatMember)
        assert result == member
예제 #2
0
async def test_get_chat_administrators(bot: Bot, event_loop):
    """ getChatAdministrators method test """
    from .types.dataset import CHAT, CHAT_MEMBER
    chat = types.Chat(**CHAT)
    member = types.ChatMember(**CHAT_MEMBER)

    async with FakeTelegram(message_data=[CHAT_MEMBER, CHAT_MEMBER],
                            loop=event_loop):
        result = await bot.get_chat_administrators(chat_id=chat.id)
        assert result[0] == member
        assert len(result) == 2
예제 #3
0
from aiogram import types
from .dataset import CHAT_MEMBER

chat_member = types.ChatMember(**CHAT_MEMBER)


def test_export():
    exported = chat_member.to_python()
    assert isinstance(exported, dict)
    assert exported == CHAT_MEMBER


def test_user():
    assert isinstance(chat_member.user, types.User)


def test_status():
    assert isinstance(chat_member.status, str)
    assert chat_member.status == CHAT_MEMBER['status']


def test_privileges():
    assert isinstance(chat_member.can_be_edited, bool)
    assert chat_member.can_be_edited == CHAT_MEMBER['can_be_edited']

    assert isinstance(chat_member.can_change_info, bool)
    assert chat_member.can_change_info == CHAT_MEMBER['can_change_info']

    assert isinstance(chat_member.can_delete_messages, bool)
    assert chat_member.can_delete_messages == CHAT_MEMBER[
        'can_delete_messages']