2017-12-08 22:38:59 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#
|
|
|
|
# A library that provides a Python interface to the Telegram Bot API
|
2022-01-03 08:15:18 +01:00
|
|
|
# Copyright (C) 2015-2022
|
2017-12-08 22:38:59 +01:00
|
|
|
# Leandro Toledo de Souza <devs@python-telegram-bot.org>
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
2022-10-31 09:46:56 +01:00
|
|
|
import copy
|
|
|
|
|
2017-12-08 22:38:59 +01:00
|
|
|
import pytest
|
|
|
|
|
2020-10-09 17:22:07 +02:00
|
|
|
from telegram import (
|
|
|
|
InputFile,
|
2022-05-05 09:27:54 +02:00
|
|
|
InputMediaAnimation,
|
2020-10-09 17:22:07 +02:00
|
|
|
InputMediaAudio,
|
|
|
|
InputMediaDocument,
|
2022-05-05 09:27:54 +02:00
|
|
|
InputMediaPhoto,
|
|
|
|
InputMediaVideo,
|
|
|
|
Message,
|
2020-11-29 16:20:46 +01:00
|
|
|
MessageEntity,
|
2020-10-09 17:22:07 +02:00
|
|
|
)
|
2021-10-19 18:28:19 +02:00
|
|
|
from telegram.constants import ParseMode
|
2020-10-09 17:22:07 +02:00
|
|
|
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
# noinspection PyUnresolvedReferences
|
2020-11-29 16:20:46 +01:00
|
|
|
from telegram.error import BadRequest
|
2022-04-24 12:38:09 +02:00
|
|
|
from telegram.request import RequestData
|
2022-05-05 09:27:54 +02:00
|
|
|
from tests.conftest import data_file, expect_bad_request
|
|
|
|
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
from .test_animation import animation, animation_file # noqa: F401
|
2020-10-09 17:22:07 +02:00
|
|
|
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
# noinspection PyUnresolvedReferences
|
|
|
|
from .test_audio import audio, audio_file # noqa: F401
|
2020-10-09 17:22:07 +02:00
|
|
|
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
# noinspection PyUnresolvedReferences
|
|
|
|
from .test_document import document, document_file # noqa: F401
|
2020-10-09 17:22:07 +02:00
|
|
|
|
2022-11-22 10:43:50 +01:00
|
|
|
# noinspection PyUnresolvedReferences
|
|
|
|
from .test_forum import emoji_id, real_topic # noqa: F401
|
|
|
|
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
# noinspection PyUnresolvedReferences
|
2022-05-05 09:27:54 +02:00
|
|
|
from .test_photo import _photo, photo, photo_file, thumb # noqa: F401
|
2020-10-09 17:22:07 +02:00
|
|
|
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
# noinspection PyUnresolvedReferences
|
|
|
|
from .test_video import video, video_file # noqa: F401
|
2017-12-08 22:38:59 +01:00
|
|
|
|
|
|
|
|
2022-05-05 17:40:22 +02:00
|
|
|
@pytest.fixture(scope="class")
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
def input_media_video(class_thumb_file):
|
2020-10-09 17:22:07 +02:00
|
|
|
return InputMediaVideo(
|
|
|
|
media=TestInputMediaVideo.media,
|
|
|
|
caption=TestInputMediaVideo.caption,
|
|
|
|
width=TestInputMediaVideo.width,
|
|
|
|
height=TestInputMediaVideo.height,
|
|
|
|
duration=TestInputMediaVideo.duration,
|
|
|
|
parse_mode=TestInputMediaVideo.parse_mode,
|
2020-11-29 16:20:46 +01:00
|
|
|
caption_entities=TestInputMediaVideo.caption_entities,
|
2020-10-09 17:22:07 +02:00
|
|
|
thumb=class_thumb_file,
|
|
|
|
supports_streaming=TestInputMediaVideo.supports_streaming,
|
|
|
|
)
|
2017-12-08 22:38:59 +01:00
|
|
|
|
|
|
|
|
2022-05-05 17:40:22 +02:00
|
|
|
@pytest.fixture(scope="class")
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
def input_media_photo(class_thumb_file):
|
2020-10-09 17:22:07 +02:00
|
|
|
return InputMediaPhoto(
|
|
|
|
media=TestInputMediaPhoto.media,
|
|
|
|
caption=TestInputMediaPhoto.caption,
|
|
|
|
parse_mode=TestInputMediaPhoto.parse_mode,
|
2020-11-29 16:20:46 +01:00
|
|
|
caption_entities=TestInputMediaPhoto.caption_entities,
|
2020-10-09 17:22:07 +02:00
|
|
|
)
|
2017-12-08 22:38:59 +01:00
|
|
|
|
|
|
|
|
2022-05-05 17:40:22 +02:00
|
|
|
@pytest.fixture(scope="class")
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
def input_media_animation(class_thumb_file):
|
2020-10-09 17:22:07 +02:00
|
|
|
return InputMediaAnimation(
|
|
|
|
media=TestInputMediaAnimation.media,
|
|
|
|
caption=TestInputMediaAnimation.caption,
|
|
|
|
parse_mode=TestInputMediaAnimation.parse_mode,
|
2020-11-29 16:20:46 +01:00
|
|
|
caption_entities=TestInputMediaAnimation.caption_entities,
|
2020-10-09 17:22:07 +02:00
|
|
|
width=TestInputMediaAnimation.width,
|
|
|
|
height=TestInputMediaAnimation.height,
|
|
|
|
thumb=class_thumb_file,
|
|
|
|
duration=TestInputMediaAnimation.duration,
|
|
|
|
)
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
|
|
|
|
2022-05-05 17:40:22 +02:00
|
|
|
@pytest.fixture(scope="class")
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
def input_media_audio(class_thumb_file):
|
2020-10-09 17:22:07 +02:00
|
|
|
return InputMediaAudio(
|
|
|
|
media=TestInputMediaAudio.media,
|
|
|
|
caption=TestInputMediaAudio.caption,
|
|
|
|
duration=TestInputMediaAudio.duration,
|
|
|
|
performer=TestInputMediaAudio.performer,
|
|
|
|
title=TestInputMediaAudio.title,
|
|
|
|
thumb=class_thumb_file,
|
|
|
|
parse_mode=TestInputMediaAudio.parse_mode,
|
2020-11-29 16:20:46 +01:00
|
|
|
caption_entities=TestInputMediaAudio.caption_entities,
|
2020-10-09 17:22:07 +02:00
|
|
|
)
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
|
|
|
|
2022-05-05 17:40:22 +02:00
|
|
|
@pytest.fixture(scope="class")
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
def input_media_document(class_thumb_file):
|
2020-10-09 17:22:07 +02:00
|
|
|
return InputMediaDocument(
|
|
|
|
media=TestInputMediaDocument.media,
|
|
|
|
caption=TestInputMediaDocument.caption,
|
|
|
|
thumb=class_thumb_file,
|
|
|
|
parse_mode=TestInputMediaDocument.parse_mode,
|
2020-11-29 16:20:46 +01:00
|
|
|
caption_entities=TestInputMediaDocument.caption_entities,
|
|
|
|
disable_content_type_detection=TestInputMediaDocument.disable_content_type_detection,
|
2020-10-09 17:22:07 +02:00
|
|
|
)
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
|
|
|
|
2020-06-15 18:20:51 +02:00
|
|
|
class TestInputMediaVideo:
|
2020-02-23 22:03:58 +01:00
|
|
|
type_ = "video"
|
2017-12-08 22:38:59 +01:00
|
|
|
media = "NOTAREALFILEID"
|
|
|
|
caption = "My Caption"
|
|
|
|
width = 3
|
|
|
|
height = 4
|
|
|
|
duration = 5
|
2022-05-05 17:40:22 +02:00
|
|
|
parse_mode = "HTML"
|
2018-02-18 16:11:04 +01:00
|
|
|
supports_streaming = True
|
2020-11-29 16:20:46 +01:00
|
|
|
caption_entities = [MessageEntity(MessageEntity.BOLD, 0, 2)]
|
2017-12-08 22:38:59 +01:00
|
|
|
|
2021-08-19 22:01:10 +02:00
|
|
|
def test_slot_behaviour(self, input_media_video, mro_slots):
|
2021-05-29 16:18:16 +02:00
|
|
|
inst = input_media_video
|
|
|
|
for attr in inst.__slots__:
|
2022-05-05 17:40:22 +02:00
|
|
|
assert getattr(inst, attr, "err") != "err", f"got extra slot '{attr}'"
|
2021-05-29 16:18:16 +02:00
|
|
|
assert len(mro_slots(inst)) == len(set(mro_slots(inst))), "duplicate slot"
|
|
|
|
|
2017-12-08 22:38:59 +01:00
|
|
|
def test_expected_values(self, input_media_video):
|
2020-02-23 22:03:58 +01:00
|
|
|
assert input_media_video.type == self.type_
|
2017-12-08 22:38:59 +01:00
|
|
|
assert input_media_video.media == self.media
|
|
|
|
assert input_media_video.caption == self.caption
|
|
|
|
assert input_media_video.width == self.width
|
|
|
|
assert input_media_video.height == self.height
|
|
|
|
assert input_media_video.duration == self.duration
|
2018-02-18 16:11:04 +01:00
|
|
|
assert input_media_video.parse_mode == self.parse_mode
|
2020-11-29 16:20:46 +01:00
|
|
|
assert input_media_video.caption_entities == self.caption_entities
|
2018-02-18 16:11:04 +01:00
|
|
|
assert input_media_video.supports_streaming == self.supports_streaming
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
assert isinstance(input_media_video.thumb, InputFile)
|
2017-12-08 22:38:59 +01:00
|
|
|
|
|
|
|
def test_to_dict(self, input_media_video):
|
|
|
|
input_media_video_dict = input_media_video.to_dict()
|
2022-05-05 17:40:22 +02:00
|
|
|
assert input_media_video_dict["type"] == input_media_video.type
|
|
|
|
assert input_media_video_dict["media"] == input_media_video.media
|
|
|
|
assert input_media_video_dict["caption"] == input_media_video.caption
|
|
|
|
assert input_media_video_dict["width"] == input_media_video.width
|
|
|
|
assert input_media_video_dict["height"] == input_media_video.height
|
|
|
|
assert input_media_video_dict["duration"] == input_media_video.duration
|
|
|
|
assert input_media_video_dict["parse_mode"] == input_media_video.parse_mode
|
|
|
|
assert input_media_video_dict["caption_entities"] == [
|
2020-11-29 16:20:46 +01:00
|
|
|
ce.to_dict() for ce in input_media_video.caption_entities
|
|
|
|
]
|
2022-05-05 17:40:22 +02:00
|
|
|
assert input_media_video_dict["supports_streaming"] == input_media_video.supports_streaming
|
2017-12-08 22:38:59 +01:00
|
|
|
|
2018-02-19 11:41:38 +01:00
|
|
|
def test_with_video(self, video): # noqa: F811
|
2017-12-08 22:38:59 +01:00
|
|
|
# fixture found in test_video
|
|
|
|
input_media_video = InputMediaVideo(video, caption="test 3")
|
2020-02-23 22:03:58 +01:00
|
|
|
assert input_media_video.type == self.type_
|
2017-12-08 22:38:59 +01:00
|
|
|
assert input_media_video.media == video.file_id
|
|
|
|
assert input_media_video.width == video.width
|
|
|
|
assert input_media_video.height == video.height
|
|
|
|
assert input_media_video.duration == video.duration
|
|
|
|
assert input_media_video.caption == "test 3"
|
|
|
|
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
def test_with_video_file(self, video_file): # noqa: F811
|
2017-12-08 22:38:59 +01:00
|
|
|
# fixture found in test_video
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
input_media_video = InputMediaVideo(video_file, caption="test 3")
|
2020-02-23 22:03:58 +01:00
|
|
|
assert input_media_video.type == self.type_
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
assert isinstance(input_media_video.media, InputFile)
|
|
|
|
assert input_media_video.caption == "test 3"
|
2017-12-08 22:38:59 +01:00
|
|
|
|
2020-11-29 16:20:46 +01:00
|
|
|
def test_with_local_files(self):
|
|
|
|
input_media_video = InputMediaVideo(
|
2022-05-05 17:40:22 +02:00
|
|
|
data_file("telegram.mp4"), thumb=data_file("telegram.jpg")
|
2020-11-29 16:20:46 +01:00
|
|
|
)
|
2022-05-05 17:40:22 +02:00
|
|
|
assert input_media_video.media == data_file("telegram.mp4").as_uri()
|
|
|
|
assert input_media_video.thumb == data_file("telegram.jpg").as_uri()
|
2020-11-29 16:20:46 +01:00
|
|
|
|
2017-12-08 22:38:59 +01:00
|
|
|
|
2020-06-15 18:20:51 +02:00
|
|
|
class TestInputMediaPhoto:
|
2020-02-23 22:03:58 +01:00
|
|
|
type_ = "photo"
|
2017-12-08 22:38:59 +01:00
|
|
|
media = "NOTAREALFILEID"
|
|
|
|
caption = "My Caption"
|
2022-05-05 17:40:22 +02:00
|
|
|
parse_mode = "Markdown"
|
2020-11-29 16:20:46 +01:00
|
|
|
caption_entities = [MessageEntity(MessageEntity.BOLD, 0, 2)]
|
2017-12-08 22:38:59 +01:00
|
|
|
|
2021-08-19 22:01:10 +02:00
|
|
|
def test_slot_behaviour(self, input_media_photo, mro_slots):
|
2021-05-29 16:18:16 +02:00
|
|
|
inst = input_media_photo
|
|
|
|
for attr in inst.__slots__:
|
2022-05-05 17:40:22 +02:00
|
|
|
assert getattr(inst, attr, "err") != "err", f"got extra slot '{attr}'"
|
2021-05-29 16:18:16 +02:00
|
|
|
assert len(mro_slots(inst)) == len(set(mro_slots(inst))), "duplicate slot"
|
|
|
|
|
2017-12-08 22:38:59 +01:00
|
|
|
def test_expected_values(self, input_media_photo):
|
2020-02-23 22:03:58 +01:00
|
|
|
assert input_media_photo.type == self.type_
|
2017-12-08 22:38:59 +01:00
|
|
|
assert input_media_photo.media == self.media
|
|
|
|
assert input_media_photo.caption == self.caption
|
2018-02-18 16:11:04 +01:00
|
|
|
assert input_media_photo.parse_mode == self.parse_mode
|
2020-11-29 16:20:46 +01:00
|
|
|
assert input_media_photo.caption_entities == self.caption_entities
|
2017-12-08 22:38:59 +01:00
|
|
|
|
|
|
|
def test_to_dict(self, input_media_photo):
|
|
|
|
input_media_photo_dict = input_media_photo.to_dict()
|
2022-05-05 17:40:22 +02:00
|
|
|
assert input_media_photo_dict["type"] == input_media_photo.type
|
|
|
|
assert input_media_photo_dict["media"] == input_media_photo.media
|
|
|
|
assert input_media_photo_dict["caption"] == input_media_photo.caption
|
|
|
|
assert input_media_photo_dict["parse_mode"] == input_media_photo.parse_mode
|
|
|
|
assert input_media_photo_dict["caption_entities"] == [
|
2020-11-29 16:20:46 +01:00
|
|
|
ce.to_dict() for ce in input_media_photo.caption_entities
|
|
|
|
]
|
2017-12-08 22:38:59 +01:00
|
|
|
|
2018-02-19 11:41:38 +01:00
|
|
|
def test_with_photo(self, photo): # noqa: F811
|
2017-12-08 22:38:59 +01:00
|
|
|
# fixture found in test_photo
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
input_media_photo = InputMediaPhoto(photo, caption="test 2")
|
2020-02-23 22:03:58 +01:00
|
|
|
assert input_media_photo.type == self.type_
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
assert input_media_photo.media == photo.file_id
|
|
|
|
assert input_media_photo.caption == "test 2"
|
2017-12-08 22:38:59 +01:00
|
|
|
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
def test_with_photo_file(self, photo_file): # noqa: F811
|
2017-12-08 22:38:59 +01:00
|
|
|
# fixture found in test_photo
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
input_media_photo = InputMediaPhoto(photo_file, caption="test 2")
|
2020-02-23 22:03:58 +01:00
|
|
|
assert input_media_photo.type == self.type_
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
assert isinstance(input_media_photo.media, InputFile)
|
|
|
|
assert input_media_photo.caption == "test 2"
|
|
|
|
|
2020-11-29 16:20:46 +01:00
|
|
|
def test_with_local_files(self):
|
2022-05-05 17:40:22 +02:00
|
|
|
input_media_photo = InputMediaPhoto(data_file("telegram.mp4"))
|
|
|
|
assert input_media_photo.media == data_file("telegram.mp4").as_uri()
|
2020-11-29 16:20:46 +01:00
|
|
|
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
2020-06-15 18:20:51 +02:00
|
|
|
class TestInputMediaAnimation:
|
2020-02-23 22:03:58 +01:00
|
|
|
type_ = "animation"
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
media = "NOTAREALFILEID"
|
|
|
|
caption = "My Caption"
|
2022-05-05 17:40:22 +02:00
|
|
|
parse_mode = "Markdown"
|
2020-11-29 16:20:46 +01:00
|
|
|
caption_entities = [MessageEntity(MessageEntity.BOLD, 0, 2)]
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
width = 30
|
|
|
|
height = 30
|
|
|
|
duration = 1
|
|
|
|
|
2021-08-19 22:01:10 +02:00
|
|
|
def test_slot_behaviour(self, input_media_animation, mro_slots):
|
2021-05-29 16:18:16 +02:00
|
|
|
inst = input_media_animation
|
|
|
|
for attr in inst.__slots__:
|
2022-05-05 17:40:22 +02:00
|
|
|
assert getattr(inst, attr, "err") != "err", f"got extra slot '{attr}'"
|
2021-05-29 16:18:16 +02:00
|
|
|
assert len(mro_slots(inst)) == len(set(mro_slots(inst))), "duplicate slot"
|
|
|
|
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
def test_expected_values(self, input_media_animation):
|
2020-02-23 22:03:58 +01:00
|
|
|
assert input_media_animation.type == self.type_
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
assert input_media_animation.media == self.media
|
|
|
|
assert input_media_animation.caption == self.caption
|
|
|
|
assert input_media_animation.parse_mode == self.parse_mode
|
2020-11-29 16:20:46 +01:00
|
|
|
assert input_media_animation.caption_entities == self.caption_entities
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
assert isinstance(input_media_animation.thumb, InputFile)
|
|
|
|
|
|
|
|
def test_to_dict(self, input_media_animation):
|
|
|
|
input_media_animation_dict = input_media_animation.to_dict()
|
2022-05-05 17:40:22 +02:00
|
|
|
assert input_media_animation_dict["type"] == input_media_animation.type
|
|
|
|
assert input_media_animation_dict["media"] == input_media_animation.media
|
|
|
|
assert input_media_animation_dict["caption"] == input_media_animation.caption
|
|
|
|
assert input_media_animation_dict["parse_mode"] == input_media_animation.parse_mode
|
|
|
|
assert input_media_animation_dict["caption_entities"] == [
|
2020-11-29 16:20:46 +01:00
|
|
|
ce.to_dict() for ce in input_media_animation.caption_entities
|
|
|
|
]
|
2022-05-05 17:40:22 +02:00
|
|
|
assert input_media_animation_dict["width"] == input_media_animation.width
|
|
|
|
assert input_media_animation_dict["height"] == input_media_animation.height
|
|
|
|
assert input_media_animation_dict["duration"] == input_media_animation.duration
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
|
|
|
def test_with_animation(self, animation): # noqa: F811
|
|
|
|
# fixture found in test_animation
|
|
|
|
input_media_animation = InputMediaAnimation(animation, caption="test 2")
|
2020-02-23 22:03:58 +01:00
|
|
|
assert input_media_animation.type == self.type_
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
assert input_media_animation.media == animation.file_id
|
|
|
|
assert input_media_animation.caption == "test 2"
|
|
|
|
|
|
|
|
def test_with_animation_file(self, animation_file): # noqa: F811
|
|
|
|
# fixture found in test_animation
|
|
|
|
input_media_animation = InputMediaAnimation(animation_file, caption="test 2")
|
2020-02-23 22:03:58 +01:00
|
|
|
assert input_media_animation.type == self.type_
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
assert isinstance(input_media_animation.media, InputFile)
|
|
|
|
assert input_media_animation.caption == "test 2"
|
|
|
|
|
2020-11-29 16:20:46 +01:00
|
|
|
def test_with_local_files(self):
|
|
|
|
input_media_animation = InputMediaAnimation(
|
2022-05-05 17:40:22 +02:00
|
|
|
data_file("telegram.mp4"), thumb=data_file("telegram.jpg")
|
2020-11-29 16:20:46 +01:00
|
|
|
)
|
2022-05-05 17:40:22 +02:00
|
|
|
assert input_media_animation.media == data_file("telegram.mp4").as_uri()
|
|
|
|
assert input_media_animation.thumb == data_file("telegram.jpg").as_uri()
|
2020-11-29 16:20:46 +01:00
|
|
|
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
2020-06-15 18:20:51 +02:00
|
|
|
class TestInputMediaAudio:
|
2020-02-23 22:03:58 +01:00
|
|
|
type_ = "audio"
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
media = "NOTAREALFILEID"
|
|
|
|
caption = "My Caption"
|
|
|
|
duration = 3
|
2022-05-05 17:40:22 +02:00
|
|
|
performer = "performer"
|
|
|
|
title = "title"
|
|
|
|
parse_mode = "HTML"
|
2020-11-29 16:20:46 +01:00
|
|
|
caption_entities = [MessageEntity(MessageEntity.BOLD, 0, 2)]
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
2021-08-19 22:01:10 +02:00
|
|
|
def test_slot_behaviour(self, input_media_audio, mro_slots):
|
2021-05-29 16:18:16 +02:00
|
|
|
inst = input_media_audio
|
|
|
|
for attr in inst.__slots__:
|
2022-05-05 17:40:22 +02:00
|
|
|
assert getattr(inst, attr, "err") != "err", f"got extra slot '{attr}'"
|
2021-05-29 16:18:16 +02:00
|
|
|
assert len(mro_slots(inst)) == len(set(mro_slots(inst))), "duplicate slot"
|
|
|
|
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
def test_expected_values(self, input_media_audio):
|
2020-02-23 22:03:58 +01:00
|
|
|
assert input_media_audio.type == self.type_
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
assert input_media_audio.media == self.media
|
|
|
|
assert input_media_audio.caption == self.caption
|
|
|
|
assert input_media_audio.duration == self.duration
|
|
|
|
assert input_media_audio.performer == self.performer
|
|
|
|
assert input_media_audio.title == self.title
|
|
|
|
assert input_media_audio.parse_mode == self.parse_mode
|
2020-11-29 16:20:46 +01:00
|
|
|
assert input_media_audio.caption_entities == self.caption_entities
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
assert isinstance(input_media_audio.thumb, InputFile)
|
|
|
|
|
|
|
|
def test_to_dict(self, input_media_audio):
|
|
|
|
input_media_audio_dict = input_media_audio.to_dict()
|
2022-05-05 17:40:22 +02:00
|
|
|
assert input_media_audio_dict["type"] == input_media_audio.type
|
|
|
|
assert input_media_audio_dict["media"] == input_media_audio.media
|
|
|
|
assert input_media_audio_dict["caption"] == input_media_audio.caption
|
|
|
|
assert input_media_audio_dict["duration"] == input_media_audio.duration
|
|
|
|
assert input_media_audio_dict["performer"] == input_media_audio.performer
|
|
|
|
assert input_media_audio_dict["title"] == input_media_audio.title
|
|
|
|
assert input_media_audio_dict["parse_mode"] == input_media_audio.parse_mode
|
|
|
|
assert input_media_audio_dict["caption_entities"] == [
|
2020-11-29 16:20:46 +01:00
|
|
|
ce.to_dict() for ce in input_media_audio.caption_entities
|
|
|
|
]
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
|
|
|
def test_with_audio(self, audio): # noqa: F811
|
|
|
|
# fixture found in test_audio
|
|
|
|
input_media_audio = InputMediaAudio(audio, caption="test 3")
|
2020-02-23 22:03:58 +01:00
|
|
|
assert input_media_audio.type == self.type_
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
assert input_media_audio.media == audio.file_id
|
|
|
|
assert input_media_audio.duration == audio.duration
|
|
|
|
assert input_media_audio.performer == audio.performer
|
|
|
|
assert input_media_audio.title == audio.title
|
|
|
|
assert input_media_audio.caption == "test 3"
|
|
|
|
|
|
|
|
def test_with_audio_file(self, audio_file): # noqa: F811
|
|
|
|
# fixture found in test_audio
|
|
|
|
input_media_audio = InputMediaAudio(audio_file, caption="test 3")
|
2020-02-23 22:03:58 +01:00
|
|
|
assert input_media_audio.type == self.type_
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
assert isinstance(input_media_audio.media, InputFile)
|
|
|
|
assert input_media_audio.caption == "test 3"
|
|
|
|
|
2020-11-29 16:20:46 +01:00
|
|
|
def test_with_local_files(self):
|
|
|
|
input_media_audio = InputMediaAudio(
|
2022-05-05 17:40:22 +02:00
|
|
|
data_file("telegram.mp4"), thumb=data_file("telegram.jpg")
|
2020-11-29 16:20:46 +01:00
|
|
|
)
|
2022-05-05 17:40:22 +02:00
|
|
|
assert input_media_audio.media == data_file("telegram.mp4").as_uri()
|
|
|
|
assert input_media_audio.thumb == data_file("telegram.jpg").as_uri()
|
2020-11-29 16:20:46 +01:00
|
|
|
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
2020-06-15 18:20:51 +02:00
|
|
|
class TestInputMediaDocument:
|
2020-02-23 22:03:58 +01:00
|
|
|
type_ = "document"
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
media = "NOTAREALFILEID"
|
|
|
|
caption = "My Caption"
|
2022-05-05 17:40:22 +02:00
|
|
|
parse_mode = "HTML"
|
2020-11-29 16:20:46 +01:00
|
|
|
caption_entities = [MessageEntity(MessageEntity.BOLD, 0, 2)]
|
|
|
|
disable_content_type_detection = True
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
2021-08-19 22:01:10 +02:00
|
|
|
def test_slot_behaviour(self, input_media_document, mro_slots):
|
2021-05-29 16:18:16 +02:00
|
|
|
inst = input_media_document
|
|
|
|
for attr in inst.__slots__:
|
2022-05-05 17:40:22 +02:00
|
|
|
assert getattr(inst, attr, "err") != "err", f"got extra slot '{attr}'"
|
2021-05-29 16:18:16 +02:00
|
|
|
assert len(mro_slots(inst)) == len(set(mro_slots(inst))), "duplicate slot"
|
|
|
|
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
def test_expected_values(self, input_media_document):
|
2020-02-23 22:03:58 +01:00
|
|
|
assert input_media_document.type == self.type_
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
assert input_media_document.media == self.media
|
|
|
|
assert input_media_document.caption == self.caption
|
|
|
|
assert input_media_document.parse_mode == self.parse_mode
|
2020-11-29 16:20:46 +01:00
|
|
|
assert input_media_document.caption_entities == self.caption_entities
|
|
|
|
assert (
|
|
|
|
input_media_document.disable_content_type_detection
|
|
|
|
== self.disable_content_type_detection
|
|
|
|
)
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
assert isinstance(input_media_document.thumb, InputFile)
|
|
|
|
|
|
|
|
def test_to_dict(self, input_media_document):
|
|
|
|
input_media_document_dict = input_media_document.to_dict()
|
2022-05-05 17:40:22 +02:00
|
|
|
assert input_media_document_dict["type"] == input_media_document.type
|
|
|
|
assert input_media_document_dict["media"] == input_media_document.media
|
|
|
|
assert input_media_document_dict["caption"] == input_media_document.caption
|
|
|
|
assert input_media_document_dict["parse_mode"] == input_media_document.parse_mode
|
|
|
|
assert input_media_document_dict["caption_entities"] == [
|
2020-11-29 16:20:46 +01:00
|
|
|
ce.to_dict() for ce in input_media_document.caption_entities
|
|
|
|
]
|
|
|
|
assert (
|
2022-05-05 17:40:22 +02:00
|
|
|
input_media_document["disable_content_type_detection"]
|
2020-11-29 16:20:46 +01:00
|
|
|
== input_media_document.disable_content_type_detection
|
|
|
|
)
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
|
|
|
def test_with_document(self, document): # noqa: F811
|
|
|
|
# fixture found in test_document
|
|
|
|
input_media_document = InputMediaDocument(document, caption="test 3")
|
2020-02-23 22:03:58 +01:00
|
|
|
assert input_media_document.type == self.type_
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
assert input_media_document.media == document.file_id
|
|
|
|
assert input_media_document.caption == "test 3"
|
|
|
|
|
|
|
|
def test_with_document_file(self, document_file): # noqa: F811
|
|
|
|
# fixture found in test_document
|
|
|
|
input_media_document = InputMediaDocument(document_file, caption="test 3")
|
2020-02-23 22:03:58 +01:00
|
|
|
assert input_media_document.type == self.type_
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
assert isinstance(input_media_document.media, InputFile)
|
|
|
|
assert input_media_document.caption == "test 3"
|
2017-12-08 22:38:59 +01:00
|
|
|
|
2020-11-29 16:20:46 +01:00
|
|
|
def test_with_local_files(self):
|
|
|
|
input_media_document = InputMediaDocument(
|
2022-05-05 17:40:22 +02:00
|
|
|
data_file("telegram.mp4"), thumb=data_file("telegram.jpg")
|
2020-11-29 16:20:46 +01:00
|
|
|
)
|
2022-05-05 17:40:22 +02:00
|
|
|
assert input_media_document.media == data_file("telegram.mp4").as_uri()
|
|
|
|
assert input_media_document.thumb == data_file("telegram.jpg").as_uri()
|
2020-11-29 16:20:46 +01:00
|
|
|
|
2017-12-08 22:38:59 +01:00
|
|
|
|
2022-05-05 17:40:22 +02:00
|
|
|
@pytest.fixture(scope="function") # noqa: F811
|
2019-01-30 20:20:35 +01:00
|
|
|
def media_group(photo, thumb): # noqa: F811
|
2020-10-09 17:22:07 +02:00
|
|
|
return [
|
2022-05-05 17:40:22 +02:00
|
|
|
InputMediaPhoto(photo, caption="*photo* 1", parse_mode="Markdown"),
|
|
|
|
InputMediaPhoto(thumb, caption="<b>photo</b> 2", parse_mode="HTML"),
|
2020-11-29 16:20:46 +01:00
|
|
|
InputMediaPhoto(
|
2022-05-05 17:40:22 +02:00
|
|
|
photo, caption="photo 3", caption_entities=[MessageEntity(MessageEntity.BOLD, 0, 5)]
|
2020-11-29 16:20:46 +01:00
|
|
|
),
|
2020-10-09 17:22:07 +02:00
|
|
|
]
|
2017-12-08 22:38:59 +01:00
|
|
|
|
|
|
|
|
2022-11-02 08:32:40 +01:00
|
|
|
@pytest.fixture(scope="function") # noqa: F811
|
|
|
|
def media_group_no_caption_args(photo, thumb): # noqa: F811
|
|
|
|
return [InputMediaPhoto(photo), InputMediaPhoto(thumb), InputMediaPhoto(photo)]
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope="function") # noqa: F811
|
|
|
|
def media_group_no_caption_only_caption_entities(photo, thumb): # noqa: F811
|
|
|
|
return [
|
|
|
|
InputMediaPhoto(photo, caption_entities=[MessageEntity(MessageEntity.BOLD, 0, 5)]),
|
|
|
|
InputMediaPhoto(photo, caption_entities=[MessageEntity(MessageEntity.BOLD, 0, 5)]),
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope="function") # noqa: F811
|
|
|
|
def media_group_no_caption_only_parse_mode(photo, thumb): # noqa: F811
|
|
|
|
return [
|
|
|
|
InputMediaPhoto(photo, parse_mode="Markdown"),
|
|
|
|
InputMediaPhoto(thumb, parse_mode="HTML"),
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2020-06-15 18:20:51 +02:00
|
|
|
class TestSendMediaGroup:
|
2022-11-09 20:43:27 +01:00
|
|
|
@pytest.mark.flaky(3, 1)
|
2022-04-24 12:38:09 +02:00
|
|
|
async def test_send_media_group_photo(self, bot, chat_id, media_group):
|
|
|
|
messages = await bot.send_media_group(chat_id, media_group)
|
2017-12-08 22:38:59 +01:00
|
|
|
assert isinstance(messages, list)
|
2020-11-29 16:20:46 +01:00
|
|
|
assert len(messages) == 3
|
2021-05-27 09:38:17 +02:00
|
|
|
assert all(isinstance(mes, Message) for mes in messages)
|
|
|
|
assert all(mes.media_group_id == messages[0].media_group_id for mes in messages)
|
2022-05-05 17:40:22 +02:00
|
|
|
assert all(mes.caption == f"photo {idx+1}" for idx, mes in enumerate(messages))
|
2020-11-29 16:20:46 +01:00
|
|
|
assert all(
|
|
|
|
mes.caption_entities == [MessageEntity(MessageEntity.BOLD, 0, 5)] for mes in messages
|
|
|
|
)
|
2017-12-08 22:38:59 +01:00
|
|
|
|
2022-11-22 10:43:50 +01:00
|
|
|
async def test_send_media_group_with_message_thread_id(
|
|
|
|
self, bot, real_topic, forum_group_id, media_group # noqa: F811
|
|
|
|
):
|
|
|
|
messages = await bot.send_media_group(
|
|
|
|
forum_group_id,
|
|
|
|
media_group,
|
|
|
|
message_thread_id=real_topic.message_thread_id,
|
|
|
|
)
|
|
|
|
assert isinstance(messages, list)
|
|
|
|
assert len(messages) == 3
|
|
|
|
assert all(isinstance(mes, Message) for mes in messages)
|
|
|
|
assert all(i.message_thread_id == real_topic.message_thread_id for i in messages)
|
|
|
|
|
2022-11-02 08:32:40 +01:00
|
|
|
async def test_send_media_group_throws_error_with_group_caption_and_individual_captions(
|
|
|
|
self,
|
|
|
|
bot,
|
|
|
|
chat_id,
|
|
|
|
media_group,
|
|
|
|
media_group_no_caption_only_caption_entities,
|
|
|
|
media_group_no_caption_only_parse_mode,
|
|
|
|
):
|
|
|
|
for group in (
|
|
|
|
media_group,
|
|
|
|
media_group_no_caption_only_caption_entities,
|
|
|
|
media_group_no_caption_only_parse_mode,
|
|
|
|
):
|
|
|
|
with pytest.raises(
|
|
|
|
ValueError,
|
|
|
|
match="You can only supply either group caption or media with captions.",
|
|
|
|
):
|
|
|
|
await bot.send_media_group(chat_id, group, caption="foo")
|
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
"caption, parse_mode, caption_entities",
|
|
|
|
[
|
|
|
|
# same combinations of caption options as in media_group fixture
|
|
|
|
("*photo* 1", "Markdown", None),
|
|
|
|
("<b>photo</b> 1", "HTML", None),
|
|
|
|
("photo 1", None, [MessageEntity(MessageEntity.BOLD, 0, 5)]),
|
|
|
|
],
|
|
|
|
)
|
2022-11-09 20:43:27 +01:00
|
|
|
@pytest.mark.flaky(3, 1)
|
2022-11-02 08:32:40 +01:00
|
|
|
async def test_send_media_group_with_group_caption(
|
|
|
|
self,
|
|
|
|
bot,
|
|
|
|
chat_id,
|
|
|
|
media_group_no_caption_args,
|
|
|
|
caption,
|
|
|
|
parse_mode,
|
|
|
|
caption_entities,
|
|
|
|
):
|
|
|
|
# prepare a copy to check later on if calling the method has caused side effects
|
|
|
|
copied_media_group = media_group_no_caption_args.copy()
|
|
|
|
|
|
|
|
messages = await bot.send_media_group(
|
|
|
|
chat_id,
|
|
|
|
media_group_no_caption_args,
|
|
|
|
caption=caption,
|
|
|
|
parse_mode=parse_mode,
|
|
|
|
caption_entities=caption_entities,
|
|
|
|
)
|
|
|
|
|
|
|
|
# Check that the method had no side effects:
|
|
|
|
# original group was not changed and 1st item still points to the same object
|
|
|
|
# (1st item must be copied within the method before adding the caption)
|
|
|
|
assert media_group_no_caption_args == copied_media_group
|
|
|
|
assert media_group_no_caption_args[0] is copied_media_group[0]
|
|
|
|
|
|
|
|
assert not any(item.parse_mode for item in media_group_no_caption_args)
|
|
|
|
|
|
|
|
assert isinstance(messages, list)
|
|
|
|
assert len(messages) == 3
|
|
|
|
assert all(isinstance(mes, Message) for mes in messages)
|
|
|
|
|
|
|
|
first_message, other_messages = messages[0], messages[1:]
|
|
|
|
assert all(mes.media_group_id == first_message.media_group_id for mes in messages)
|
|
|
|
|
|
|
|
# Make sure first message got the caption, which will lead
|
|
|
|
# to Telegram displaying its caption as group caption
|
|
|
|
assert first_message.caption
|
|
|
|
assert first_message.caption_entities == [MessageEntity(MessageEntity.BOLD, 0, 5)]
|
|
|
|
|
|
|
|
# Check that other messages have no captions
|
|
|
|
assert all(mes.caption is None for mes in other_messages)
|
|
|
|
assert not any(mes.caption_entities for mes in other_messages)
|
|
|
|
|
2022-11-09 20:43:27 +01:00
|
|
|
@pytest.mark.flaky(3, 1)
|
2022-10-31 09:46:56 +01:00
|
|
|
async def test_send_media_group_all_args(self, bot, raw_bot, chat_id, media_group):
|
|
|
|
ext_bot = bot
|
|
|
|
for bot in (ext_bot, raw_bot):
|
|
|
|
# We need to test 1) below both the bot and raw_bot and setting this up with
|
|
|
|
# pytest.parametrize appears to be difficult ...
|
|
|
|
|
|
|
|
m1 = await bot.send_message(chat_id, text="test")
|
|
|
|
copied_media_group = copy.copy(media_group)
|
|
|
|
messages = await bot.send_media_group(
|
|
|
|
chat_id,
|
|
|
|
media_group,
|
|
|
|
disable_notification=True,
|
|
|
|
reply_to_message_id=m1.message_id,
|
|
|
|
protect_content=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
# 1)
|
|
|
|
# make sure that the media_group was not modified
|
|
|
|
assert media_group == copied_media_group
|
|
|
|
assert all(
|
|
|
|
a.parse_mode == b.parse_mode for a, b in zip(media_group, copied_media_group)
|
|
|
|
)
|
|
|
|
|
|
|
|
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)
|
|
|
|
assert all(mes.caption == f"photo {idx+1}" for idx, mes in enumerate(messages))
|
|
|
|
assert all(
|
|
|
|
mes.caption_entities == [MessageEntity(MessageEntity.BOLD, 0, 5)]
|
|
|
|
for mes in messages
|
|
|
|
)
|
|
|
|
assert all(mes.has_protected_content for mes in messages)
|
2017-12-08 22:38:59 +01:00
|
|
|
|
2022-11-09 20:43:27 +01:00
|
|
|
@pytest.mark.flaky(3, 1)
|
2022-04-24 12:38:09 +02:00
|
|
|
async def test_send_media_group_custom_filename(
|
2020-12-16 14:28:53 +01:00
|
|
|
self,
|
|
|
|
bot,
|
|
|
|
chat_id,
|
|
|
|
photo_file, # noqa: F811
|
|
|
|
animation_file, # noqa: F811
|
|
|
|
audio_file, # noqa: F811
|
|
|
|
video_file, # noqa: F811
|
|
|
|
monkeypatch,
|
|
|
|
):
|
2022-04-24 12:38:09 +02:00
|
|
|
async def make_assertion(url, request_data: RequestData, *args, **kwargs):
|
|
|
|
result = all(
|
2022-05-05 17:40:22 +02:00
|
|
|
field_tuple[0] == "custom_filename"
|
2022-04-24 12:38:09 +02:00
|
|
|
for field_tuple in request_data.multipart_data.values()
|
|
|
|
)
|
|
|
|
if result is True:
|
2022-05-05 17:40:22 +02:00
|
|
|
raise Exception("Test was successful")
|
2020-12-16 14:28:53 +01:00
|
|
|
|
2022-05-05 17:40:22 +02:00
|
|
|
monkeypatch.setattr(bot.request, "post", make_assertion)
|
2020-12-16 14:28:53 +01:00
|
|
|
|
|
|
|
media = [
|
2022-05-05 17:40:22 +02:00
|
|
|
InputMediaAnimation(animation_file, filename="custom_filename"),
|
|
|
|
InputMediaAudio(audio_file, filename="custom_filename"),
|
|
|
|
InputMediaPhoto(photo_file, filename="custom_filename"),
|
|
|
|
InputMediaVideo(video_file, filename="custom_filename"),
|
2020-12-16 14:28:53 +01:00
|
|
|
]
|
|
|
|
|
2022-05-05 17:40:22 +02:00
|
|
|
with pytest.raises(Exception, match="Test was successful"):
|
2022-04-24 12:38:09 +02:00
|
|
|
await bot.send_media_group(chat_id, media)
|
2020-12-16 14:28:53 +01:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def test_send_media_group_with_thumbs(
|
2020-10-09 17:22:07 +02:00
|
|
|
self, bot, chat_id, video_file, photo_file, monkeypatch # noqa: F811
|
|
|
|
):
|
2022-04-24 12:38:09 +02:00
|
|
|
async def make_assertion(method, url, request_data: RequestData, *args, **kwargs):
|
|
|
|
files = request_data.multipart_data
|
|
|
|
video_check = files[input_video.media.attach_name] == input_video.media.field_tuple
|
|
|
|
thumb_check = files[input_video.thumb.attach_name] == input_video.thumb.field_tuple
|
2020-09-19 16:50:34 +02:00
|
|
|
result = video_check and thumb_check
|
2020-11-23 22:09:29 +01:00
|
|
|
raise Exception(f"Test was {'successful' if result else 'failing'}")
|
2020-09-19 16:50:34 +02:00
|
|
|
|
2022-05-05 17:40:22 +02:00
|
|
|
monkeypatch.setattr(bot.request, "_request_wrapper", make_assertion)
|
2020-09-19 16:50:34 +02:00
|
|
|
input_video = InputMediaVideo(video_file, thumb=photo_file)
|
2022-05-05 17:40:22 +02:00
|
|
|
with pytest.raises(Exception, match="Test was successful"):
|
2022-04-24 12:38:09 +02:00
|
|
|
await bot.send_media_group(chat_id, [input_video, input_video])
|
2020-09-19 16:50:34 +02:00
|
|
|
|
2022-11-09 20:43:27 +01:00
|
|
|
@pytest.mark.flaky(3, 1) # noqa: F811
|
2022-04-24 12:38:09 +02:00
|
|
|
async def test_send_media_group_new_files(
|
2021-10-13 08:12:48 +02:00
|
|
|
self,
|
|
|
|
bot,
|
|
|
|
chat_id,
|
|
|
|
video_file, # noqa: F811
|
|
|
|
photo_file, # noqa: F811
|
|
|
|
animation_file, # noqa: F811
|
|
|
|
):
|
2022-04-24 12:38:09 +02:00
|
|
|
async def func():
|
|
|
|
return await bot.send_media_group(
|
2021-10-05 19:50:11 +02:00
|
|
|
chat_id,
|
|
|
|
[
|
|
|
|
InputMediaVideo(video_file),
|
|
|
|
InputMediaPhoto(photo_file),
|
2022-05-05 17:40:22 +02:00
|
|
|
InputMediaPhoto(data_file("telegram.jpg").read_bytes()),
|
2021-10-05 19:50:11 +02:00
|
|
|
],
|
|
|
|
)
|
2020-10-09 17:22:07 +02:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
messages = await expect_bad_request(
|
2022-05-05 17:40:22 +02:00
|
|
|
func, "Type of file mismatch", "Telegram did not accept the file."
|
2020-10-09 17:22:07 +02:00
|
|
|
)
|
2020-05-01 13:27:46 +02:00
|
|
|
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
assert isinstance(messages, list)
|
2020-12-18 11:20:03 +01:00
|
|
|
assert len(messages) == 3
|
2021-05-27 09:38:17 +02:00
|
|
|
assert all(isinstance(mes, Message) for mes in messages)
|
|
|
|
assert all(mes.media_group_id == messages[0].media_group_id for mes in messages)
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
2022-11-09 20:43:27 +01:00
|
|
|
@pytest.mark.flaky(3, 1)
|
2020-11-29 16:20:46 +01:00
|
|
|
@pytest.mark.parametrize(
|
2022-05-05 17:40:22 +02:00
|
|
|
"default_bot,custom",
|
2020-11-29 16:20:46 +01:00
|
|
|
[
|
2022-05-05 17:40:22 +02:00
|
|
|
({"allow_sending_without_reply": True}, None),
|
|
|
|
({"allow_sending_without_reply": False}, None),
|
|
|
|
({"allow_sending_without_reply": False}, True),
|
2020-11-29 16:20:46 +01:00
|
|
|
],
|
2022-05-05 17:40:22 +02:00
|
|
|
indirect=["default_bot"],
|
2020-11-29 16:20:46 +01:00
|
|
|
)
|
2022-04-24 12:38:09 +02:00
|
|
|
async def test_send_media_group_default_allow_sending_without_reply(
|
2020-11-29 16:20:46 +01:00
|
|
|
self, default_bot, chat_id, media_group, custom
|
|
|
|
):
|
2022-05-05 17:40:22 +02:00
|
|
|
reply_to_message = await default_bot.send_message(chat_id, "test")
|
2022-04-24 12:38:09 +02:00
|
|
|
await reply_to_message.delete()
|
2020-11-29 16:20:46 +01:00
|
|
|
if custom is not None:
|
2022-04-24 12:38:09 +02:00
|
|
|
messages = await default_bot.send_media_group(
|
2020-11-29 16:20:46 +01:00
|
|
|
chat_id,
|
|
|
|
media_group,
|
|
|
|
allow_sending_without_reply=custom,
|
|
|
|
reply_to_message_id=reply_to_message.message_id,
|
|
|
|
)
|
|
|
|
assert [m.reply_to_message is None for m in messages]
|
|
|
|
elif default_bot.defaults.allow_sending_without_reply:
|
2022-04-24 12:38:09 +02:00
|
|
|
messages = await default_bot.send_media_group(
|
2020-11-29 16:20:46 +01:00
|
|
|
chat_id, media_group, reply_to_message_id=reply_to_message.message_id
|
|
|
|
)
|
|
|
|
assert [m.reply_to_message is None for m in messages]
|
|
|
|
else:
|
2022-05-05 17:40:22 +02:00
|
|
|
with pytest.raises(BadRequest, match="message not found"):
|
2022-04-24 12:38:09 +02:00
|
|
|
await default_bot.send_media_group(
|
2020-11-29 16:20:46 +01:00
|
|
|
chat_id, media_group, reply_to_message_id=reply_to_message.message_id
|
|
|
|
)
|
|
|
|
|
2022-11-09 20:43:27 +01:00
|
|
|
@pytest.mark.flaky(3, 1)
|
2022-05-05 17:40:22 +02:00
|
|
|
@pytest.mark.parametrize("default_bot", [{"protect_content": True}], indirect=True)
|
2022-04-24 12:38:09 +02:00
|
|
|
async def test_send_media_group_default_protect_content(
|
|
|
|
self, chat_id, media_group, default_bot
|
|
|
|
):
|
|
|
|
protected = await default_bot.send_media_group(chat_id, media_group)
|
2022-01-07 17:02:23 +01:00
|
|
|
assert all(msg.has_protected_content for msg in protected)
|
2022-04-24 12:38:09 +02:00
|
|
|
unprotected = await default_bot.send_media_group(
|
|
|
|
chat_id, media_group, protect_content=False
|
|
|
|
)
|
2022-01-07 17:02:23 +01:00
|
|
|
assert not all(msg.has_protected_content for msg in unprotected)
|
|
|
|
|
2022-11-09 20:43:27 +01:00
|
|
|
@pytest.mark.flaky(3, 1)
|
2022-11-02 08:32:40 +01:00
|
|
|
@pytest.mark.parametrize("default_bot", [{"parse_mode": ParseMode.HTML}], indirect=True)
|
|
|
|
async def test_send_media_group_default_parse_mode(
|
|
|
|
self, chat_id, media_group_no_caption_args, default_bot
|
|
|
|
):
|
|
|
|
default = await default_bot.send_media_group(
|
|
|
|
chat_id, media_group_no_caption_args, caption="<b>photo</b> 1"
|
|
|
|
)
|
|
|
|
|
|
|
|
# make sure no parse_mode was set as a side effect
|
|
|
|
assert not any(item.parse_mode for item in media_group_no_caption_args)
|
|
|
|
|
|
|
|
overridden_markdown_v2 = await default_bot.send_media_group(
|
|
|
|
chat_id,
|
|
|
|
media_group_no_caption_args.copy(),
|
|
|
|
caption="*photo* 1",
|
|
|
|
parse_mode=ParseMode.MARKDOWN_V2,
|
|
|
|
)
|
|
|
|
|
|
|
|
overridden_none = await default_bot.send_media_group(
|
|
|
|
chat_id,
|
|
|
|
media_group_no_caption_args.copy(),
|
|
|
|
caption="<b>photo</b> 1",
|
|
|
|
parse_mode=None,
|
|
|
|
)
|
|
|
|
|
|
|
|
# Make sure first message got the caption, which will lead to Telegram
|
|
|
|
# displaying its caption as group caption
|
|
|
|
assert overridden_none[0].caption == "<b>photo</b> 1"
|
|
|
|
assert not overridden_none[0].caption_entities
|
|
|
|
# First messages in these two groups have to have caption "photo 1"
|
|
|
|
# because of parse mode (default or explicit)
|
|
|
|
for mes_group in (default, overridden_markdown_v2):
|
|
|
|
first_message = mes_group[0]
|
|
|
|
assert first_message.caption == "photo 1"
|
|
|
|
assert first_message.caption_entities == [MessageEntity(MessageEntity.BOLD, 0, 5)]
|
|
|
|
|
|
|
|
# This check is valid for all 3 groups of messages
|
|
|
|
for mes_group in (default, overridden_markdown_v2, overridden_none):
|
|
|
|
first_message, other_messages = mes_group[0], mes_group[1:]
|
|
|
|
assert all(mes.media_group_id == first_message.media_group_id for mes in mes_group)
|
|
|
|
# Check that messages from 2nd message onwards have no captions
|
|
|
|
assert all(mes.caption is None for mes in other_messages)
|
|
|
|
assert not any(mes.caption_entities for mes in other_messages)
|
|
|
|
|
2022-11-09 20:43:27 +01:00
|
|
|
@pytest.mark.flaky(3, 1)
|
2022-10-31 09:46:56 +01:00
|
|
|
async def test_edit_message_media(self, bot, raw_bot, chat_id, media_group):
|
|
|
|
ext_bot = bot
|
|
|
|
for bot in (ext_bot, raw_bot):
|
|
|
|
# We need to test 1) below both the bot and raw_bot and setting this up with
|
|
|
|
# pytest.parametrize appears to be difficult ...
|
|
|
|
messages = await bot.send_media_group(chat_id, media_group)
|
|
|
|
cid = messages[-1].chat.id
|
|
|
|
mid = messages[-1].message_id
|
|
|
|
copied_media = copy.copy(media_group[0])
|
|
|
|
new_message = await bot.edit_message_media(
|
|
|
|
chat_id=cid, message_id=mid, media=media_group[0]
|
|
|
|
)
|
|
|
|
assert isinstance(new_message, Message)
|
|
|
|
|
|
|
|
# 1)
|
|
|
|
# make sure that the media was not modified
|
|
|
|
assert media_group[0].parse_mode == copied_media.parse_mode
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
|
2022-11-09 20:43:27 +01:00
|
|
|
@pytest.mark.flaky(3, 1)
|
2022-04-24 12:38:09 +02:00
|
|
|
async def test_edit_message_media_new_file(self, bot, chat_id, media_group, thumb_file):
|
|
|
|
messages = await bot.send_media_group(chat_id, media_group)
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
cid = messages[-1].chat.id
|
|
|
|
mid = messages[-1].message_id
|
2022-04-24 12:38:09 +02:00
|
|
|
new_message = await bot.edit_message_media(
|
2020-10-09 17:22:07 +02:00
|
|
|
chat_id=cid, message_id=mid, media=InputMediaPhoto(thumb_file)
|
|
|
|
)
|
Bot API 4.0 (#1168)
Telegram Passport (#1174):
- Add full support for telegram passport.
- New types: PassportData, PassportFile, EncryptedPassportElement, EncryptedCredentials, PassportElementError, PassportElementErrorDataField, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorFile and PassportElementErrorFiles.
- New bot method: set_passport_data_errors
- New filter: Filters.passport_data
- Field passport_data field on Message
- PassportData is automagically decrypted when you specify your private key when creating Updater or Bot.
- PassportFiles is also automagically decrypted as you download/retrieve them.
- See new passportbot.py example for details on how to use, or go to our telegram passport wiki page for more info
- NOTE: Passport decryption requires new dependency `cryptography`.
Inputfile rework (#1184):
- Change how Inputfile is handled internally
- This allows support for specifying the thumbnails of photos and videos using the thumb= argument in the different send_ methods.
- Also allows Bot.send_media_group to actually finally send more than one media.
- Add thumb to Audio, Video and Videonote
- Add Bot.edit_message_media together with InputMediaAnimation, InputMediaAudio, and inputMediaDocument.
Other Bot API 4.0 changes:
- Add forusquare_type to Venue, InlineQueryResultVenue, InputVenueMessageContent, and Bot.send_venue. (#1170)
- Add vCard support by adding vcard field to Contact, InlineQueryResultContact, InputContactMessageContent, and Bot.send_contact. (#1166)
- Support new message entities: CASHTAG and PHONE_NUMBER. (#1179)
- Cashtag seems to be things like $USD and $GBP, but it seems telegram doesn't currently send them to bots.
- Phone number also seems to have limited support for now
- Add Bot.send_animation, add width, height, and duration to Animation, and add Filters.animation. (#1172)
Co-authored-by: Jasmin Bom <jsmnbom@gmail.com>
Co-authored-by: code1mountain <32801117+code1mountain@users.noreply.github.com>
Co-authored-by: Eldinnie <pieter.schutz+github@gmail.com>
Co-authored-by: mathefreak1 <mathefreak@hi2.in>
2018-08-29 14:18:58 +02:00
|
|
|
assert isinstance(new_message, Message)
|
2021-02-19 19:07:48 +01:00
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
async def test_edit_message_media_with_thumb(
|
2021-08-11 08:34:47 +02:00
|
|
|
self, bot, chat_id, video_file, photo_file, monkeypatch # noqa: F811
|
|
|
|
):
|
2022-04-24 12:38:09 +02:00
|
|
|
async def make_assertion(
|
|
|
|
method: str, url: str, request_data: RequestData = None, *args, **kwargs
|
|
|
|
):
|
|
|
|
files = request_data.multipart_data
|
|
|
|
video_check = files[input_video.media.attach_name] == input_video.media.field_tuple
|
|
|
|
thumb_check = files[input_video.thumb.attach_name] == input_video.thumb.field_tuple
|
2021-08-11 08:34:47 +02:00
|
|
|
result = video_check and thumb_check
|
|
|
|
raise Exception(f"Test was {'successful' if result else 'failing'}")
|
|
|
|
|
2022-05-05 17:40:22 +02:00
|
|
|
monkeypatch.setattr(bot.request, "_request_wrapper", make_assertion)
|
2021-08-11 08:34:47 +02:00
|
|
|
input_video = InputMediaVideo(video_file, thumb=photo_file)
|
2022-05-05 17:40:22 +02:00
|
|
|
with pytest.raises(Exception, match="Test was successful"):
|
2022-04-24 12:38:09 +02:00
|
|
|
await bot.edit_message_media(chat_id=chat_id, message_id=123, media=input_video)
|
2021-08-11 08:34:47 +02:00
|
|
|
|
2022-11-09 20:43:27 +01:00
|
|
|
@pytest.mark.flaky(3, 1)
|
2021-02-19 19:07:48 +01:00
|
|
|
@pytest.mark.parametrize(
|
2022-05-05 17:40:22 +02:00
|
|
|
"default_bot", [{"parse_mode": ParseMode.HTML}], indirect=True, ids=["HTML-Bot"]
|
2021-02-19 19:07:48 +01:00
|
|
|
)
|
2022-05-05 17:40:22 +02:00
|
|
|
@pytest.mark.parametrize("media_type", ["animation", "document", "audio", "photo", "video"])
|
2022-04-24 12:38:09 +02:00
|
|
|
async def test_edit_message_media_default_parse_mode(
|
2021-02-19 19:07:48 +01:00
|
|
|
self,
|
|
|
|
chat_id,
|
|
|
|
default_bot,
|
|
|
|
media_type,
|
|
|
|
animation, # noqa: F811
|
|
|
|
document, # noqa: F811
|
|
|
|
audio, # noqa: F811
|
|
|
|
photo, # noqa: F811
|
|
|
|
video, # noqa: F811
|
|
|
|
):
|
2022-05-05 17:40:22 +02:00
|
|
|
html_caption = "<b>bold</b> <i>italic</i> <code>code</code>"
|
|
|
|
markdown_caption = "*bold* _italic_ `code`"
|
|
|
|
test_caption = "bold italic code"
|
2021-02-19 19:07:48 +01:00
|
|
|
test_entities = [
|
|
|
|
MessageEntity(MessageEntity.BOLD, 0, 4),
|
|
|
|
MessageEntity(MessageEntity.ITALIC, 5, 6),
|
|
|
|
MessageEntity(MessageEntity.CODE, 12, 4),
|
|
|
|
]
|
|
|
|
|
|
|
|
def build_media(parse_mode, med_type):
|
|
|
|
kwargs = {}
|
|
|
|
if parse_mode != ParseMode.HTML:
|
2022-05-05 17:40:22 +02:00
|
|
|
kwargs["parse_mode"] = parse_mode
|
|
|
|
kwargs["caption"] = markdown_caption
|
2021-02-19 19:07:48 +01:00
|
|
|
else:
|
2022-05-05 17:40:22 +02:00
|
|
|
kwargs["caption"] = html_caption
|
2021-02-19 19:07:48 +01:00
|
|
|
|
2022-05-05 17:40:22 +02:00
|
|
|
if med_type == "animation":
|
2021-02-19 19:07:48 +01:00
|
|
|
return InputMediaAnimation(animation, **kwargs)
|
2022-05-05 17:40:22 +02:00
|
|
|
if med_type == "document":
|
2021-02-19 19:07:48 +01:00
|
|
|
return InputMediaDocument(document, **kwargs)
|
2022-05-05 17:40:22 +02:00
|
|
|
if med_type == "audio":
|
2021-02-19 19:07:48 +01:00
|
|
|
return InputMediaAudio(audio, **kwargs)
|
2022-05-05 17:40:22 +02:00
|
|
|
if med_type == "photo":
|
2021-02-19 19:07:48 +01:00
|
|
|
return InputMediaPhoto(photo, **kwargs)
|
2022-05-05 17:40:22 +02:00
|
|
|
if med_type == "video":
|
2021-02-19 19:07:48 +01:00
|
|
|
return InputMediaVideo(video, **kwargs)
|
|
|
|
|
2022-04-24 12:38:09 +02:00
|
|
|
message = await default_bot.send_photo(chat_id, photo)
|
2021-02-19 19:07:48 +01:00
|
|
|
|
2022-10-31 09:46:56 +01:00
|
|
|
media = build_media(parse_mode=ParseMode.HTML, med_type=media_type)
|
|
|
|
copied_media = copy.copy(media)
|
2022-04-24 12:38:09 +02:00
|
|
|
message = await default_bot.edit_message_media(
|
2022-10-31 09:46:56 +01:00
|
|
|
media,
|
2021-02-19 19:07:48 +01:00
|
|
|
message.chat_id,
|
|
|
|
message.message_id,
|
|
|
|
)
|
|
|
|
assert message.caption == test_caption
|
|
|
|
assert message.caption_entities == test_entities
|
2022-10-31 09:46:56 +01:00
|
|
|
# make sure that the media was not modified
|
|
|
|
assert media.parse_mode == copied_media.parse_mode
|
2021-02-19 19:07:48 +01:00
|
|
|
|
|
|
|
# Remove caption to avoid "Message not changed"
|
2022-04-24 12:38:09 +02:00
|
|
|
await message.edit_caption()
|
2021-02-19 19:07:48 +01:00
|
|
|
|
2022-10-31 09:46:56 +01:00
|
|
|
media = build_media(parse_mode=ParseMode.MARKDOWN_V2, med_type=media_type)
|
|
|
|
copied_media = copy.copy(media)
|
2022-04-24 12:38:09 +02:00
|
|
|
message = await default_bot.edit_message_media(
|
2022-10-31 09:46:56 +01:00
|
|
|
media,
|
2021-02-19 19:07:48 +01:00
|
|
|
message.chat_id,
|
|
|
|
message.message_id,
|
|
|
|
)
|
|
|
|
assert message.caption == test_caption
|
|
|
|
assert message.caption_entities == test_entities
|
2022-10-31 09:46:56 +01:00
|
|
|
# make sure that the media was not modified
|
|
|
|
assert media.parse_mode == copied_media.parse_mode
|
2021-02-19 19:07:48 +01:00
|
|
|
|
|
|
|
# Remove caption to avoid "Message not changed"
|
2022-04-24 12:38:09 +02:00
|
|
|
await message.edit_caption()
|
2021-02-19 19:07:48 +01:00
|
|
|
|
2022-10-31 09:46:56 +01:00
|
|
|
media = build_media(parse_mode=None, med_type=media_type)
|
|
|
|
copied_media = copy.copy(media)
|
2022-04-24 12:38:09 +02:00
|
|
|
message = await default_bot.edit_message_media(
|
2022-10-31 09:46:56 +01:00
|
|
|
media,
|
2021-02-19 19:07:48 +01:00
|
|
|
message.chat_id,
|
|
|
|
message.message_id,
|
|
|
|
)
|
|
|
|
assert message.caption == markdown_caption
|
|
|
|
assert message.caption_entities == []
|
2022-10-31 09:46:56 +01:00
|
|
|
# make sure that the media was not modified
|
|
|
|
assert media.parse_mode == copied_media.parse_mode
|