Пример #1
0
async def test_send_photo(bot: Bot):
    """ sendPhoto method test with file_id """
    from .types.dataset import MESSAGE_WITH_PHOTO, PHOTO
    msg = types.Message(**MESSAGE_WITH_PHOTO)
    photo = types.PhotoSize(**PHOTO)

    async with FakeTelegram(message_data=MESSAGE_WITH_PHOTO):
        result = await bot.send_photo(msg.chat.id, photo=photo.file_id, caption=msg.caption,
                                      parse_mode=types.ParseMode.HTML, disable_notification=False)
        assert result == msg
Пример #2
0
async def test_send_media_group(bot: Bot):
    """ sendMediaGroup method test with file_id """
    from .types.dataset import MESSAGE_WITH_MEDIA_GROUP, PHOTO
    msg = types.Message(**MESSAGE_WITH_MEDIA_GROUP)
    photo = types.PhotoSize(**PHOTO)
    media = [types.InputMediaPhoto(media=photo.file_id), types.InputMediaPhoto(media=photo.file_id)]

    async with FakeTelegram(message_data=[MESSAGE_WITH_MEDIA_GROUP, MESSAGE_WITH_MEDIA_GROUP]):
        result = await bot.send_media_group(msg.chat.id, media=media, disable_notification=False)
        assert len(result) == len(media)
        assert result.pop().media_group_id
Пример #3
0
from aiogram import types
from .dataset import PHOTO

photo = types.PhotoSize(**PHOTO)


def test_export():
    exported = photo.to_python()
    assert isinstance(exported, dict)
    assert exported == PHOTO


def test_file_id():
    assert isinstance(photo.file_id, str)
    assert photo.file_id == PHOTO['file_id']


def test_file_size():
    assert isinstance(photo.file_size, int)
    assert photo.file_size == PHOTO['file_size']


def test_size():
    assert isinstance(photo.width, int)
    assert isinstance(photo.height, int)
    assert photo.width == PHOTO['width']
    assert photo.height == PHOTO['height']
Пример #4
0
from aiogram import types
from .dataset import AUDIO, ANIMATION, \
    DOCUMENT, PHOTO, VIDEO

WIDTH = 'width'
HEIGHT = 'height'

input_media_audio = types.InputMediaAudio(types.Audio(**AUDIO))
input_media_animation = types.InputMediaAnimation(types.Animation(**ANIMATION))
input_media_document = types.InputMediaDocument(types.Document(**DOCUMENT))
input_media_video = types.InputMediaVideo(types.Video(**VIDEO))
input_media_photo = types.InputMediaPhoto(types.PhotoSize(**PHOTO))


def test_field_width():
    """
    https://core.telegram.org/bots/api#inputmedia
    """
    assert not hasattr(input_media_audio, WIDTH)
    assert not hasattr(input_media_document, WIDTH)
    assert not hasattr(input_media_photo, WIDTH)

    assert hasattr(input_media_animation, WIDTH)
    assert hasattr(input_media_video, WIDTH)


def test_field_height():
    """
    https://core.telegram.org/bots/api#inputmedia
    """
    assert not hasattr(input_media_audio, HEIGHT)