def test_send_all_args(self, bot, super_group_id, chatphoto_file,
                           chat_photo, thumb_file):
        def func():
            assert bot.set_chat_photo(super_group_id, chatphoto_file)

        expect_bad_request(func, 'Type of file mismatch',
                           'Telegram did not accept the file.')
Esempio n. 2
0
def _photo(bot, chat_id):
    def func():
        with open('tests/data/telegram.jpg', 'rb') as f:
            return bot.send_photo(chat_id, photo=f, timeout=50).photo

    return expect_bad_request(func, 'Type of file mismatch',
                              'Telegram did not accept the file.')
Esempio n. 3
0
    def test_send_media_group_new_files(
            self,
            bot,
            chat_id,
            video_file,
            photo_file,
            animation_file  # noqa: F811
    ):  # noqa: F811
        def func():
            with open('tests/data/telegram.jpg', 'rb') as file:
                return bot.send_media_group(
                    chat_id,
                    [
                        InputMediaVideo(video_file),
                        InputMediaPhoto(photo_file),
                        InputMediaPhoto(file.read()),
                    ],
                )

        messages = expect_bad_request(func, 'Type of file mismatch',
                                      'Telegram did not accept the file.')

        assert isinstance(messages, list)
        assert len(messages) == 3
        assert all([isinstance(mes, Message) for mes in messages])
        assert all([
            mes.media_group_id == messages[0].media_group_id
            for mes in messages
        ])
Esempio n. 4
0
    def test_send_media_group_new_files(self, bot, chat_id, video_file, photo_file,  # noqa: F811
                                        animation_file):  # noqa: F811
        def func():
            return bot.send_media_group(chat_id, [
                InputMediaVideo(video_file),
                InputMediaPhoto(photo_file)
            ])
        messages = expect_bad_request(func, 'Type of file mismatch',
                                      'Telegram did not accept the file.')

        assert isinstance(messages, list)
        assert len(messages) == 2
        assert all([isinstance(mes, Message) for mes in messages])
        assert all([mes.media_group_id == messages[0].media_group_id for mes in messages])
Esempio n. 5
0
def chat_photo(bot, super_group_id):
    def func():
        return bot.get_chat(super_group_id, timeout=50).photo

    return expect_bad_request(func, 'Type of file mismatch', 'Telegram did not accept the file.')