Update ChatActions (#2460)

* deprecate CA.upload/record_audio in favor of ca.u/r_voice

* tests

* tests

* Fix test
This commit is contained in:
Bibo-Joshi 2021-04-22 08:57:56 +02:00 committed by GitHub
parent b63877b1f2
commit 3b92901892
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 59 additions and 4 deletions

View file

@ -28,7 +28,17 @@ class ChatAction:
FIND_LOCATION: ClassVar[str] = constants.CHATACTION_FIND_LOCATION
""":const:`telegram.constants.CHATACTION_FIND_LOCATION`"""
RECORD_AUDIO: ClassVar[str] = constants.CHATACTION_RECORD_AUDIO
""":const:`telegram.constants.CHATACTION_RECORD_AUDIO`"""
""":const:`telegram.constants.CHATACTION_RECORD_AUDIO`
.. deprecated:: 13.5
Deprecated by Telegram. Use :attr:`RECORD_VOICE` instead, as backwards
compatibility is not guaranteed by Telegram.
"""
RECORD_VOICE: ClassVar[str] = constants.CHATACTION_RECORD_VOICE
""":const:`telegram.constants.CHATACTION_RECORD_VOICE`
.. versionadded:: 13.5
"""
RECORD_VIDEO: ClassVar[str] = constants.CHATACTION_RECORD_VIDEO
""":const:`telegram.constants.CHATACTION_RECORD_VIDEO`"""
RECORD_VIDEO_NOTE: ClassVar[str] = constants.CHATACTION_RECORD_VIDEO_NOTE
@ -36,7 +46,17 @@ class ChatAction:
TYPING: ClassVar[str] = constants.CHATACTION_TYPING
""":const:`telegram.constants.CHATACTION_TYPING`"""
UPLOAD_AUDIO: ClassVar[str] = constants.CHATACTION_UPLOAD_AUDIO
""":const:`telegram.constants.CHATACTION_UPLOAD_AUDIO`"""
""":const:`telegram.constants.CHATACTION_UPLOAD_AUDIO`
.. deprecated:: 13.5
Deprecated by Telegram. Use :attr:`UPLOAD_VOICE` instead, as backwards
compatibility is not guaranteed by Telegram.
"""
UPLOAD_VOICE: ClassVar[str] = constants.CHATACTION_UPLOAD_VOICE
""":const:`telegram.constants.CHATACTION_UPLOAD_VOICE`
.. versionadded:: 13.5
"""
UPLOAD_DOCUMENT: ClassVar[str] = constants.CHATACTION_UPLOAD_DOCUMENT
""":const:`telegram.constants.CHATACTION_UPLOAD_DOCUMENT`"""
UPLOAD_PHOTO: ClassVar[str] = constants.CHATACTION_UPLOAD_PHOTO

View file

@ -65,10 +65,24 @@ Attributes:
Attributes:
CHATACTION_FIND_LOCATION (:obj:`str`): 'find_location'
CHATACTION_RECORD_AUDIO (:obj:`str`): 'record_audio'
.. deprecated:: 13.5
Deprecated by Telegram. Use :const:`CHATACTION_RECORD_VOICE` instead, as backwards
compatibility is not guaranteed by Telegram.
CHATACTION_RECORD_VOICE (:obj:`str`): 'record_voice'
.. versionadded:: 13.5
CHATACTION_RECORD_VIDEO (:obj:`str`): 'record_video'
CHATACTION_RECORD_VIDEO_NOTE (:obj:`str`): 'record_video_note'
CHATACTION_TYPING (:obj:`str`): 'typing'
CHATACTION_UPLOAD_AUDIO (:obj:`str`): 'upload_audio'
.. deprecated:: 13.5
Deprecated by Telegram. Use :const:`CHATACTION_UPLOAD_VOICE` instead, as backwards
compatibility is not guaranteed by Telegram.
CHATACTION_UPLOAD_VOICE (:obj:`str`): 'upload_voice'
.. versionadded:: 13.5
CHATACTION_UPLOAD_DOCUMENT (:obj:`str`): 'upload_document'
CHATACTION_UPLOAD_PHOTO (:obj:`str`): 'upload_photo'
CHATACTION_UPLOAD_VIDEO (:obj:`str`): 'upload_video'
@ -172,10 +186,12 @@ CHAT_CHANNEL: str = 'channel'
CHATACTION_FIND_LOCATION: str = 'find_location'
CHATACTION_RECORD_AUDIO: str = 'record_audio'
CHATACTION_RECORD_VOICE: str = 'record_voice'
CHATACTION_RECORD_VIDEO: str = 'record_video'
CHATACTION_RECORD_VIDEO_NOTE: str = 'record_video_note'
CHATACTION_TYPING: str = 'typing'
CHATACTION_UPLOAD_AUDIO: str = 'upload_audio'
CHATACTION_UPLOAD_VOICE: str = 'upload_voice'
CHATACTION_UPLOAD_DOCUMENT: str = 'upload_document'
CHATACTION_UPLOAD_PHOTO: str = 'upload_photo'
CHATACTION_UPLOAD_VIDEO: str = 'upload_video'

View file

@ -614,8 +614,27 @@ class TestBot:
@flaky(3, 1)
@pytest.mark.timeout(10)
def test_send_chat_action(self, bot, chat_id):
assert bot.send_chat_action(chat_id, ChatAction.TYPING)
@pytest.mark.parametrize(
'chat_action',
[
ChatAction.FIND_LOCATION,
ChatAction.RECORD_AUDIO,
ChatAction.RECORD_VIDEO,
ChatAction.RECORD_VIDEO_NOTE,
ChatAction.RECORD_VOICE,
ChatAction.TYPING,
ChatAction.UPLOAD_AUDIO,
ChatAction.UPLOAD_DOCUMENT,
ChatAction.UPLOAD_PHOTO,
ChatAction.UPLOAD_VIDEO,
ChatAction.UPLOAD_VIDEO_NOTE,
ChatAction.UPLOAD_VOICE,
],
)
def test_send_chat_action(self, bot, chat_id, chat_action):
assert bot.send_chat_action(chat_id, chat_action)
with pytest.raises(BadRequest, match='Wrong parameter action'):
bot.send_chat_action(chat_id, 'unknown action')
# TODO: Needs improvement. We need incoming inline query to test answer.
def test_answer_inline_query(self, monkeypatch, bot):