diff --git a/docs/source/telegram.rst b/docs/source/telegram.rst index cf2b3eb48..daa1f9656 100644 --- a/docs/source/telegram.rst +++ b/docs/source/telegram.rst @@ -140,6 +140,7 @@ Passport telegram.credentials telegram.datacredentials telegram.securedata + telegram.securevalue telegram.filecredentials telegram.iddocumentdata telegram.personaldetails diff --git a/docs/source/telegram.securevalue.rst b/docs/source/telegram.securevalue.rst new file mode 100644 index 000000000..ba756a2cc --- /dev/null +++ b/docs/source/telegram.securevalue.rst @@ -0,0 +1,6 @@ +telegram.SecureValue +==================== + +.. autoclass:: telegram.SecureValue + :members: + :show-inheritance: diff --git a/telegram/__init__.py b/telegram/__init__.py index 732f64807..f1dc551c4 100644 --- a/telegram/__init__.py +++ b/telegram/__init__.py @@ -139,6 +139,7 @@ from .passport.credentials import ( Credentials, DataCredentials, SecureData, + SecureValue, FileCredentials, TelegramDecryptionError, ) @@ -147,24 +148,37 @@ from .version import __version__ # noqa: F401 __author__ = 'devs@python-telegram-bot.org' -__all__ = [ +__all__ = ( # Keep this alphabetically ordered + 'Animation', 'Audio', 'Bot', + 'BotCommand', + 'CallbackGame', + 'CallbackQuery', 'Chat', + 'ChatAction', + 'ChatLocation', 'ChatMember', 'ChatPermissions', - 'ChatAction', + 'ChatPhoto', 'ChosenInlineResult', - 'CallbackQuery', 'Contact', + 'Credentials', + 'DataCredentials', + 'Dice', 'Document', + 'EncryptedCredentials', + 'EncryptedPassportElement', 'File', + 'FileCredentials', 'ForceReply', + 'Game', + 'GameHighScore', + 'IdDocumentData', 'InlineKeyboardButton', 'InlineKeyboardMarkup', 'InlineQuery', 'InlineQueryResult', - 'InlineQueryResult', 'InlineQueryResultArticle', 'InlineQueryResultAudio', 'InlineQueryResultCachedAudio', @@ -177,6 +191,7 @@ __all__ = [ 'InlineQueryResultCachedVoice', 'InlineQueryResultContact', 'InlineQueryResultDocument', + 'InlineQueryResultGame', 'InlineQueryResultGif', 'InlineQueryResultLocation', 'InlineQueryResultMpeg4Gif', @@ -184,28 +199,70 @@ __all__ = [ 'InlineQueryResultVenue', 'InlineQueryResultVideo', 'InlineQueryResultVoice', - 'InlineQueryResultGame', 'InputContactMessageContent', 'InputFile', 'InputLocationMessageContent', + 'InputMedia', + 'InputMediaAnimation', + 'InputMediaAudio', + 'InputMediaDocument', + 'InputMediaPhoto', + 'InputMediaVideo', 'InputMessageContent', 'InputTextMessageContent', 'InputVenueMessageContent', + 'Invoice', + 'KeyboardButton', + 'KeyboardButtonPollType', + 'LabeledPrice', 'Location', - 'ChatLocation', - 'ProximityAlertTriggered', - 'EncryptedCredentials', - 'PassportFile', - 'EncryptedPassportElement', - 'PassportData', + 'LoginUrl', + 'MAX_CAPTION_LENGTH', + 'MAX_FILESIZE_DOWNLOAD', + 'MAX_FILESIZE_UPLOAD', + 'MAX_MESSAGES_PER_MINUTE_PER_GROUP', + 'MAX_MESSAGES_PER_SECOND', + 'MAX_MESSAGES_PER_SECOND_PER_CHAT', + 'MAX_MESSAGE_LENGTH', + 'MaskPosition', 'Message', 'MessageEntity', + 'MessageId', + 'OrderInfo', 'ParseMode', + 'PassportData', + 'PassportElementError', + 'PassportElementErrorDataField', + 'PassportElementErrorFile', + 'PassportElementErrorFiles', + 'PassportElementErrorFrontSide', + 'PassportElementErrorReverseSide', + 'PassportElementErrorSelfie', + 'PassportElementErrorTranslationFile', + 'PassportElementErrorTranslationFiles', + 'PassportElementErrorUnspecified', + 'PassportFile', + 'PersonalDetails', 'PhotoSize', - 'ReplyKeyboardRemove', + 'Poll', + 'PollAnswer', + 'PollOption', + 'PreCheckoutQuery', + 'ProximityAlertTriggered', 'ReplyKeyboardMarkup', + 'ReplyKeyboardRemove', 'ReplyMarkup', + 'ResidentialAddress', + 'SUPPORTED_WEBHOOK_PORTS', + 'SecureData', + 'SecureValue', + 'ShippingAddress', + 'ShippingOption', + 'ShippingQuery', 'Sticker', + 'StickerSet', + 'SuccessfulPayment', + 'TelegramDecryptionError', 'TelegramError', 'TelegramObject', 'Update', @@ -213,65 +270,7 @@ __all__ = [ 'UserProfilePhotos', 'Venue', 'Video', - 'Voice', - 'MAX_MESSAGE_LENGTH', - 'MAX_CAPTION_LENGTH', - 'SUPPORTED_WEBHOOK_PORTS', - 'MAX_FILESIZE_DOWNLOAD', - 'MAX_FILESIZE_UPLOAD', - 'MAX_MESSAGES_PER_SECOND_PER_CHAT', - 'MAX_MESSAGES_PER_SECOND', - 'MAX_MESSAGES_PER_MINUTE_PER_GROUP', - 'WebhookInfo', - 'Animation', - 'Game', - 'GameHighScore', 'VideoNote', - 'LabeledPrice', - 'SuccessfulPayment', - 'ShippingOption', - 'ShippingAddress', - 'PreCheckoutQuery', - 'OrderInfo', - 'Invoice', - 'ShippingQuery', - 'ChatPhoto', - 'StickerSet', - 'MaskPosition', - 'CallbackGame', - 'InputMedia', - 'InputMediaPhoto', - 'InputMediaVideo', - 'PassportElementError', - 'PassportElementErrorFile', - 'PassportElementErrorReverseSide', - 'PassportElementErrorFrontSide', - 'PassportElementErrorFiles', - 'PassportElementErrorDataField', - 'PassportElementErrorFile', - 'Credentials', - 'DataCredentials', - 'SecureData', - 'FileCredentials', - 'IdDocumentData', - 'PersonalDetails', - 'ResidentialAddress', - 'InputMediaVideo', - 'InputMediaAnimation', - 'InputMediaAudio', - 'InputMediaDocument', - 'TelegramDecryptionError', - 'PassportElementErrorSelfie', - 'PassportElementErrorTranslationFile', - 'PassportElementErrorTranslationFiles', - 'PassportElementErrorUnspecified', - 'Poll', - 'PollOption', - 'PollAnswer', - 'LoginUrl', - 'KeyboardButton', - 'KeyboardButtonPollType', - 'Dice', - 'BotCommand', - 'MessageId', -] + 'Voice', + 'WebhookInfo', +) diff --git a/tests/test_passport.py b/tests/test_passport.py index f5099af73..f46a4b234 100644 --- a/tests/test_passport.py +++ b/tests/test_passport.py @@ -31,27 +31,12 @@ from telegram import ( TelegramDecryptionError, ) -# Generated using the scope: -# { -# data: [ -# { -# type: 'personal_details', -# native_names: true -# }, -# { -# type: 'id_document', -# selfie: true, -# translation: true -# }, -# { -# type: 'address_document', -# translation: true -# }, -# 'address', -# 'email' -# ], -# v: 1 -# } + +# Note: All classes in telegram.credentials (except EncryptedCredentials) aren't directly tested +# here, although they are implicitly tested. Testing for those classes was too much work and not +# worth it. + + RAW_PASSPORT_DATA = { 'credentials': { 'hash': 'qB4hz2LMcXYhglwz6EvXMMyI3PURisWLXl/iCmCXcSk=',