mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-01-03 17:52:31 +01:00
Add InlineKeyboardButtonTest and reformatting.
This commit is contained in:
parent
1f29093027
commit
35f6de326b
50 changed files with 255 additions and 206 deletions
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents a Base class for tests"""
|
||||
|
||||
import signal
|
||||
|
@ -37,8 +36,8 @@ class BaseTest(object):
|
|||
def __init__(self, *args, **kwargs):
|
||||
super(BaseTest, self).__init__(*args, **kwargs)
|
||||
|
||||
bot = telegram.Bot(os.environ.get('TOKEN',
|
||||
'133505823:AAHZFMHno3mzVLErU5b5jJvaeG--qUyLyG0'))
|
||||
bot = telegram.Bot(os.environ.get(
|
||||
'TOKEN', '133505823:AAHZFMHno3mzVLErU5b5jJvaeG--qUyLyG0'))
|
||||
chat_id = os.environ.get('CHAT_ID', '12173560')
|
||||
|
||||
self._bot = bot
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram Audio"""
|
||||
|
||||
import sys
|
||||
|
@ -56,8 +55,7 @@ class AudioTest(BaseTest, unittest.TestCase):
|
|||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
def test_send_audio_required_args_only(self):
|
||||
message = self._bot.sendAudio(self._chat_id,
|
||||
self.audio_file)
|
||||
message = self._bot.sendAudio(self._chat_id, self.audio_file)
|
||||
|
||||
audio = message.audio
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram Bot"""
|
||||
|
||||
import sys
|
||||
|
@ -55,8 +54,9 @@ class BotTest(BaseTest, unittest.TestCase):
|
|||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
def testSendMessage(self):
|
||||
message = self._bot.sendMessage(chat_id=self._chat_id,
|
||||
text='Моё судно на воздушной подушке полно угрей')
|
||||
message = self._bot.sendMessage(
|
||||
chat_id=self._chat_id,
|
||||
text='Моё судно на воздушной подушке полно угрей')
|
||||
|
||||
self.assertTrue(self.is_json(message.to_json()))
|
||||
self.assertEqual(message.text,
|
||||
|
@ -66,9 +66,10 @@ class BotTest(BaseTest, unittest.TestCase):
|
|||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
def testSilentSendMessage(self):
|
||||
message = self._bot.sendMessage(chat_id=self._chat_id,
|
||||
text='Моё судно на воздушной подушке полно угрей',
|
||||
disable_notification=True)
|
||||
message = self._bot.sendMessage(
|
||||
chat_id=self._chat_id,
|
||||
text='Моё судно на воздушной подушке полно угрей',
|
||||
disable_notification=True)
|
||||
|
||||
self.assertTrue(self.is_json(message.to_json()))
|
||||
self.assertEqual(message.text,
|
||||
|
@ -129,8 +130,9 @@ class BotTest(BaseTest, unittest.TestCase):
|
|||
chat_id=self._chat_id)
|
||||
|
||||
self.assertTrue(self.is_json(message.to_json()))
|
||||
self.assertEqual(message.photo[0].file_id,
|
||||
'AgADAQADyKcxGx8j9Qdp6d-gpUsw4Gja1i8ABEVJsVqQk8LfJ3wAAgI')
|
||||
self.assertEqual(
|
||||
message.photo[0].file_id,
|
||||
'AgADAQADyKcxGx8j9Qdp6d-gpUsw4Gja1i8ABEVJsVqQk8LfJ3wAAgI')
|
||||
|
||||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
|
@ -167,8 +169,7 @@ class BotTest(BaseTest, unittest.TestCase):
|
|||
def testSendBufferedReaderPhoto(self):
|
||||
photo = open('tests/data/telegram.png', 'rb')
|
||||
br_photo = io.BufferedReader(io.BytesIO(photo.read()))
|
||||
message = self._bot.sendPhoto(photo=br_photo,
|
||||
chat_id=self._chat_id)
|
||||
message = self._bot.sendPhoto(photo=br_photo, chat_id=self._chat_id)
|
||||
|
||||
self.assertTrue(self.is_json(message.to_json()))
|
||||
self.assertEqual(message.photo[0].file_size, 1451)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""This module contains a object that represents Tests for Botan analytics integration"""
|
||||
|
||||
import sys
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram Chat"""
|
||||
|
||||
import sys
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram
|
||||
ChosenInlineResult"""
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram Contact"""
|
||||
|
||||
import sys
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram Document"""
|
||||
|
||||
import sys
|
||||
|
@ -57,8 +56,7 @@ class DocumentTest(BaseTest, unittest.TestCase):
|
|||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
def test_send_document_png_file(self):
|
||||
message = self._bot.sendDocument(self._chat_id,
|
||||
self.document_file)
|
||||
message = self._bot.sendDocument(self._chat_id, self.document_file)
|
||||
|
||||
document = message.document
|
||||
|
||||
|
@ -88,8 +86,7 @@ class DocumentTest(BaseTest, unittest.TestCase):
|
|||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
def test_send_document_url_gif_file(self):
|
||||
message = self._bot.sendDocument(self._chat_id,
|
||||
self.document_file_url)
|
||||
message = self._bot.sendDocument(self._chat_id, self.document_file_url)
|
||||
|
||||
document = message.document
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram Emoji"""
|
||||
|
||||
import sys
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram File"""
|
||||
|
||||
import sys
|
||||
|
@ -42,7 +41,8 @@ class FileTest(BaseTest, unittest.TestCase):
|
|||
|
||||
self.json_dict = {
|
||||
'file_id': self.audio_file_id,
|
||||
'file_path': 'https://api.telegram.org/file/bot133505823:AAHZFMHno3mzVLErU5b5jJvaeG--qUyLyG0/document/file_3',
|
||||
'file_path':
|
||||
'https://api.telegram.org/file/bot133505823:AAHZFMHno3mzVLErU5b5jJvaeG--qUyLyG0/document/file_3',
|
||||
'file_size': 28232
|
||||
}
|
||||
|
||||
|
@ -137,8 +137,7 @@ class FileTest(BaseTest, unittest.TestCase):
|
|||
del (json_dict['file_path'])
|
||||
del (json_dict['file_size'])
|
||||
|
||||
self.assertRaises(TypeError,
|
||||
lambda: self._bot.getFile(**json_dict))
|
||||
self.assertRaises(TypeError, lambda: self._bot.getFile(**json_dict))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram ForceReply"""
|
||||
|
||||
import sys
|
||||
|
@ -42,10 +41,10 @@ class ForceReplyTest(BaseTest, unittest.TestCase):
|
|||
}
|
||||
|
||||
def test_send_message_with_force_reply(self):
|
||||
message = self._bot.sendMessage(self._chat_id,
|
||||
'Моё судно на воздушной подушке полно угрей',
|
||||
reply_markup=telegram.ForceReply.de_json(
|
||||
self.json_dict))
|
||||
message = self._bot.sendMessage(
|
||||
self._chat_id,
|
||||
'Моё судно на воздушной подушке полно угрей',
|
||||
reply_markup=telegram.ForceReply.de_json(self.json_dict))
|
||||
|
||||
self.assertTrue(self.is_json(message.to_json()))
|
||||
self.assertEqual(message.text,
|
||||
|
|
73
tests/test_inlinekeyboardbutton.py
Normal file
73
tests/test_inlinekeyboardbutton.py
Normal file
|
@ -0,0 +1,73 @@
|
|||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
#
|
||||
# A library that provides a Python interface to the Telegram Bot API
|
||||
# Copyright (C) 2015-2016
|
||||
# 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/].
|
||||
"""This module contains a object that represents Tests for Telegram InlineKeyboardButton"""
|
||||
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
import telegram
|
||||
from tests.base import BaseTest
|
||||
|
||||
|
||||
class InlineKeyboardButtonTest(BaseTest, unittest.TestCase):
|
||||
"""This object represents Tests for Telegram KeyboardButton."""
|
||||
|
||||
def setUp(self):
|
||||
self.text = 'text'
|
||||
self.url = 'url'
|
||||
self.callback_data = 'callback data'
|
||||
self.switch_inline_query = ''
|
||||
|
||||
self.json_dict = {
|
||||
'text': self.text,
|
||||
'url': self.url,
|
||||
'callback_data': self.callback_data,
|
||||
'switch_inline_query': self.switch_inline_query
|
||||
}
|
||||
|
||||
def test_inline_keyboard_button_markup_de_json(self):
|
||||
inline_keyboard_button_markup = telegram.InlineKeyboardButton.de_json(
|
||||
self.json_dict)
|
||||
|
||||
self.assertEqual(inline_keyboard_button_markup.text, self.text)
|
||||
self.assertEqual(inline_keyboard_button_markup.url, self.url)
|
||||
self.assertEqual(inline_keyboard_button_markup.callback_data,
|
||||
self.callback_data)
|
||||
self.assertEqual(inline_keyboard_button_markup.switch_inline_query,
|
||||
self.switch_inline_query)
|
||||
|
||||
def test_inline_keyboard_button_markup_to_json(self):
|
||||
inline_keyboard_button_markup = telegram.InlineKeyboardButton.de_json(
|
||||
self.json_dict)
|
||||
|
||||
self.assertTrue(self.is_json(inline_keyboard_button_markup.to_json()))
|
||||
|
||||
def test_inline_keyboard_button_markup_to_dict(self):
|
||||
inline_keyboard_button_markup = telegram.InlineKeyboardButton.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(inline_keyboard_button_markup))
|
||||
self.assertDictEqual(self.json_dict, inline_keyboard_button_markup)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
|
@ -17,7 +17,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram InlineKeyboardMarkup"""
|
||||
|
||||
import sys
|
||||
|
@ -33,11 +32,10 @@ class InlineKeyboardMarkupTest(BaseTest, unittest.TestCase):
|
|||
"""This object represents Tests for Telegram KeyboardButton."""
|
||||
|
||||
def setUp(self):
|
||||
self.inline_keyboard = \
|
||||
[[telegram.InlineKeyboardButton(text='button1',
|
||||
callback_data='data1'),
|
||||
telegram.InlineKeyboardButton(text='button2',
|
||||
callback_data='data2')]]
|
||||
self.inline_keyboard = [[telegram.InlineKeyboardButton(
|
||||
text='button1',
|
||||
callback_data='data1'), telegram.InlineKeyboardButton(
|
||||
text='button2', callback_data='data2')]]
|
||||
|
||||
self.json_dict = {
|
||||
'inline_keyboard': [[self.inline_keyboard[0][0].to_dict(),
|
||||
|
@ -45,11 +43,10 @@ class InlineKeyboardMarkupTest(BaseTest, unittest.TestCase):
|
|||
}
|
||||
|
||||
def test_send_message_with_inline_keyboard_markup(self):
|
||||
message = self._bot.sendMessage(self._chat_id,
|
||||
'Testing InlineKeyboardMarkup',
|
||||
reply_markup=
|
||||
telegram.InlineKeyboardMarkup(
|
||||
self.inline_keyboard))
|
||||
message = self._bot.sendMessage(
|
||||
self._chat_id,
|
||||
'Testing InlineKeyboardMarkup',
|
||||
reply_markup=telegram.InlineKeyboardMarkup(self.inline_keyboard))
|
||||
|
||||
self.assertTrue(self.is_json(message.to_json()))
|
||||
self.assertEqual(message.text, 'Testing InlineKeyboardMarkup')
|
||||
|
@ -58,9 +55,10 @@ class InlineKeyboardMarkupTest(BaseTest, unittest.TestCase):
|
|||
inline_keyboard_markup = telegram.InlineKeyboardMarkup.de_json(
|
||||
self.json_dict)
|
||||
|
||||
self.assertTrue(isinstance(inline_keyboard_markup.inline_keyboard, list))
|
||||
self.assertTrue(isinstance(inline_keyboard_markup.inline_keyboard[0][0],
|
||||
telegram.InlineKeyboardButton))
|
||||
self.assertTrue(isinstance(inline_keyboard_markup.inline_keyboard,
|
||||
list))
|
||||
self.assertTrue(isinstance(inline_keyboard_markup.inline_keyboard[0][
|
||||
0], telegram.InlineKeyboardButton))
|
||||
|
||||
def test_inline_keyboard_markup_to_json(self):
|
||||
inline_keyboard_markup = telegram.InlineKeyboardMarkup.de_json(
|
||||
|
@ -72,9 +70,10 @@ class InlineKeyboardMarkupTest(BaseTest, unittest.TestCase):
|
|||
inline_keyboard_markup = telegram.InlineKeyboardMarkup.de_json(
|
||||
self.json_dict)
|
||||
|
||||
self.assertTrue(isinstance(inline_keyboard_markup.inline_keyboard, list))
|
||||
self.assertTrue(isinstance(inline_keyboard_markup.inline_keyboard[0][0],
|
||||
telegram.InlineKeyboardButton))
|
||||
self.assertTrue(isinstance(inline_keyboard_markup.inline_keyboard,
|
||||
list))
|
||||
self.assertTrue(isinstance(inline_keyboard_markup.inline_keyboard[0][
|
||||
0], telegram.InlineKeyboardButton))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram
|
||||
InlineQuery"""
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram
|
||||
InlineQueryResultArticle"""
|
||||
|
||||
|
@ -43,7 +42,8 @@ class InlineQueryResultArticleTest(BaseTest, unittest.TestCase):
|
|||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
telegram.InlineKeyboardButton('reply_markup')
|
||||
]])
|
||||
self.url = 'url'
|
||||
self.hide_url = True
|
||||
self.description = 'description'
|
||||
|
@ -88,8 +88,8 @@ class InlineQueryResultArticleTest(BaseTest, unittest.TestCase):
|
|||
self.assertTrue(self.is_json(article.to_json()))
|
||||
|
||||
def test_article_to_dict(self):
|
||||
article = \
|
||||
telegram.InlineQueryResultArticle.de_json(self.json_dict).to_dict()
|
||||
article = telegram.InlineQueryResultArticle.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(article))
|
||||
self.assertDictEqual(self.json_dict, article)
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram
|
||||
InlineQueryResultAudio"""
|
||||
|
||||
|
@ -46,7 +45,8 @@ class InlineQueryResultAudioTest(BaseTest, unittest.TestCase):
|
|||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
telegram.InlineKeyboardButton('reply_markup')
|
||||
]])
|
||||
|
||||
self.json_dict = {
|
||||
'type': self.type,
|
||||
|
@ -79,8 +79,8 @@ class InlineQueryResultAudioTest(BaseTest, unittest.TestCase):
|
|||
self.assertTrue(self.is_json(audio.to_json()))
|
||||
|
||||
def test_audio_to_dict(self):
|
||||
audio = \
|
||||
telegram.InlineQueryResultAudio.de_json(self.json_dict).to_dict()
|
||||
audio = telegram.InlineQueryResultAudio.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(audio))
|
||||
self.assertDictEqual(self.json_dict, audio)
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram
|
||||
InlineQueryResultCachedAudio"""
|
||||
|
||||
|
@ -44,7 +43,8 @@ class InlineQueryResultCachedAudioTest(BaseTest, unittest.TestCase):
|
|||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
telegram.InlineKeyboardButton('reply_markup')
|
||||
]])
|
||||
|
||||
self.json_dict = {
|
||||
'type': self.type,
|
||||
|
@ -71,9 +71,8 @@ class InlineQueryResultCachedAudioTest(BaseTest, unittest.TestCase):
|
|||
self.assertTrue(self.is_json(audio.to_json()))
|
||||
|
||||
def test_audio_to_dict(self):
|
||||
audio = \
|
||||
telegram.InlineQueryResultCachedAudio.de_json(
|
||||
self.json_dict).to_dict()
|
||||
audio = telegram.InlineQueryResultCachedAudio.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(audio))
|
||||
self.assertDictEqual(self.json_dict, audio)
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram
|
||||
InlineQueryResultCachedDocument"""
|
||||
|
||||
|
@ -47,7 +46,8 @@ class InlineQueryResultCachedDocumentTest(BaseTest, unittest.TestCase):
|
|||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
telegram.InlineKeyboardButton('reply_markup')
|
||||
]])
|
||||
self.json_dict = {
|
||||
'id': self.id,
|
||||
'type': self.type,
|
||||
|
@ -81,9 +81,8 @@ class InlineQueryResultCachedDocumentTest(BaseTest, unittest.TestCase):
|
|||
self.assertTrue(self.is_json(document.to_json()))
|
||||
|
||||
def test_document_to_dict(self):
|
||||
document = \
|
||||
telegram.InlineQueryResultCachedDocument.de_json(
|
||||
self.json_dict).to_dict()
|
||||
document = telegram.InlineQueryResultCachedDocument.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(document))
|
||||
self.assertDictEqual(self.json_dict, document)
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram
|
||||
InlineQueryResultCachedGif"""
|
||||
|
||||
|
@ -45,7 +44,8 @@ class InlineQueryResultCachedGifTest(BaseTest, unittest.TestCase):
|
|||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
telegram.InlineKeyboardButton('reply_markup')
|
||||
]])
|
||||
|
||||
self.json_dict = {
|
||||
'type': self.type,
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram
|
||||
InlineQueryResultCachedMpeg4Gif"""
|
||||
|
||||
|
@ -46,7 +45,8 @@ class InlineQueryResultCachedMpeg4GifTest(BaseTest, unittest.TestCase):
|
|||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
telegram.InlineKeyboardButton('reply_markup')
|
||||
]])
|
||||
|
||||
self.json_dict = {
|
||||
'type': self.type,
|
||||
|
@ -79,9 +79,8 @@ class InlineQueryResultCachedMpeg4GifTest(BaseTest, unittest.TestCase):
|
|||
self.assertTrue(self.is_json(mpeg4.to_json()))
|
||||
|
||||
def test_mpeg4_to_dict(self):
|
||||
mpeg4 = \
|
||||
telegram.InlineQueryResultCachedMpeg4Gif.de_json(
|
||||
self.json_dict).to_dict()
|
||||
mpeg4 = telegram.InlineQueryResultCachedMpeg4Gif.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(mpeg4))
|
||||
self.assertDictEqual(self.json_dict, mpeg4)
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram
|
||||
InlineQueryResultCachedPhoto"""
|
||||
|
||||
|
@ -47,7 +46,8 @@ class InlineQueryResultCachedPhotoTest(BaseTest, unittest.TestCase):
|
|||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
telegram.InlineKeyboardButton('reply_markup')
|
||||
]])
|
||||
|
||||
self.json_dict = {
|
||||
'type': self.type,
|
||||
|
@ -80,9 +80,8 @@ class InlineQueryResultCachedPhotoTest(BaseTest, unittest.TestCase):
|
|||
self.assertTrue(self.is_json(photo.to_json()))
|
||||
|
||||
def test_photo_to_dict(self):
|
||||
photo = \
|
||||
telegram.InlineQueryResultCachedPhoto.de_json(
|
||||
self.json_dict).to_dict()
|
||||
photo = telegram.InlineQueryResultCachedPhoto.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(photo))
|
||||
self.assertDictEqual(self.json_dict, photo)
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram
|
||||
InlineQueryResultCachedSticker"""
|
||||
|
||||
|
@ -44,7 +43,8 @@ class InlineQueryResultCachedStickerTest(BaseTest, unittest.TestCase):
|
|||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
telegram.InlineKeyboardButton('reply_markup')
|
||||
]])
|
||||
|
||||
self.json_dict = {
|
||||
'type': self.type,
|
||||
|
@ -73,9 +73,8 @@ class InlineQueryResultCachedStickerTest(BaseTest, unittest.TestCase):
|
|||
self.assertTrue(self.is_json(sticker.to_json()))
|
||||
|
||||
def test_sticker_to_dict(self):
|
||||
sticker = \
|
||||
telegram.InlineQueryResultCachedSticker.de_json(
|
||||
self.json_dict).to_dict()
|
||||
sticker = telegram.InlineQueryResultCachedSticker.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(sticker))
|
||||
self.assertDictEqual(self.json_dict, sticker)
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram
|
||||
InlineQueryResultCachedVideo"""
|
||||
|
||||
|
@ -47,7 +46,8 @@ class InlineQueryResultCachedVideoTest(BaseTest, unittest.TestCase):
|
|||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
telegram.InlineKeyboardButton('reply_markup')
|
||||
]])
|
||||
|
||||
self.json_dict = {
|
||||
'type': self.type,
|
||||
|
@ -80,9 +80,8 @@ class InlineQueryResultCachedVideoTest(BaseTest, unittest.TestCase):
|
|||
self.assertTrue(self.is_json(video.to_json()))
|
||||
|
||||
def test_video_to_dict(self):
|
||||
video = \
|
||||
telegram.InlineQueryResultCachedVideo.de_json(
|
||||
self.json_dict).to_dict()
|
||||
video = telegram.InlineQueryResultCachedVideo.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(video))
|
||||
self.assertDictEqual(self.json_dict, video)
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram
|
||||
InlineQueryResultCachedVoice"""
|
||||
|
||||
|
@ -46,7 +45,8 @@ class InlineQueryResultCachedVoiceTest(BaseTest, unittest.TestCase):
|
|||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
telegram.InlineKeyboardButton('reply_markup')
|
||||
]])
|
||||
|
||||
self.json_dict = {
|
||||
'type': self.type,
|
||||
|
@ -77,9 +77,8 @@ class InlineQueryResultCachedVoiceTest(BaseTest, unittest.TestCase):
|
|||
self.assertTrue(self.is_json(voice.to_json()))
|
||||
|
||||
def test_voice_to_dict(self):
|
||||
voice = \
|
||||
telegram.InlineQueryResultCachedVoice.de_json(
|
||||
self.json_dict).to_dict()
|
||||
voice = telegram.InlineQueryResultCachedVoice.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(voice))
|
||||
self.assertDictEqual(self.json_dict, voice)
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram
|
||||
InlineQueryResultContact"""
|
||||
|
||||
|
@ -48,7 +47,8 @@ class InlineQueryResultContactTest(BaseTest, unittest.TestCase):
|
|||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
telegram.InlineKeyboardButton('reply_markup')
|
||||
]])
|
||||
self.json_dict = {
|
||||
'id': self.id,
|
||||
'type': self.type,
|
||||
|
@ -84,9 +84,8 @@ class InlineQueryResultContactTest(BaseTest, unittest.TestCase):
|
|||
self.assertTrue(self.is_json(contact.to_json()))
|
||||
|
||||
def test_contact_to_dict(self):
|
||||
contact = \
|
||||
telegram.InlineQueryResultContact.de_json(
|
||||
self.json_dict).to_dict()
|
||||
contact = telegram.InlineQueryResultContact.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(contact))
|
||||
self.assertDictEqual(self.json_dict, contact)
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram
|
||||
InlineQueryResultDocument"""
|
||||
|
||||
|
@ -50,7 +49,8 @@ class InlineQueryResultDocumentTest(BaseTest, unittest.TestCase):
|
|||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
telegram.InlineKeyboardButton('reply_markup')
|
||||
]])
|
||||
self.json_dict = {
|
||||
'id': self.id,
|
||||
'type': self.type,
|
||||
|
@ -90,9 +90,8 @@ class InlineQueryResultDocumentTest(BaseTest, unittest.TestCase):
|
|||
self.assertTrue(self.is_json(document.to_json()))
|
||||
|
||||
def test_document_to_dict(self):
|
||||
document = \
|
||||
telegram.InlineQueryResultDocument.de_json(
|
||||
self.json_dict).to_dict()
|
||||
document = telegram.InlineQueryResultDocument.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(document))
|
||||
self.assertDictEqual(self.json_dict, document)
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram
|
||||
InlineQueryResultGif"""
|
||||
|
||||
|
@ -48,7 +47,8 @@ class InlineQueryResultGifTest(BaseTest, unittest.TestCase):
|
|||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
telegram.InlineKeyboardButton('reply_markup')
|
||||
]])
|
||||
|
||||
self.json_dict = {
|
||||
'type': self.type,
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram
|
||||
InlineQueryResultLocation"""
|
||||
|
||||
|
@ -48,7 +47,8 @@ class InlineQueryResultLocationTest(BaseTest, unittest.TestCase):
|
|||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
telegram.InlineKeyboardButton('reply_markup')
|
||||
]])
|
||||
self.json_dict = {
|
||||
'id': self.id,
|
||||
'type': self.type,
|
||||
|
@ -84,9 +84,8 @@ class InlineQueryResultLocationTest(BaseTest, unittest.TestCase):
|
|||
self.assertTrue(self.is_json(location.to_json()))
|
||||
|
||||
def test_location_to_dict(self):
|
||||
location = \
|
||||
telegram.InlineQueryResultLocation.de_json(
|
||||
self.json_dict).to_dict()
|
||||
location = telegram.InlineQueryResultLocation.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(location))
|
||||
self.assertDictEqual(self.json_dict, location)
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram
|
||||
InlineQueryResultMpeg4Gif"""
|
||||
|
||||
|
@ -48,7 +47,8 @@ class InlineQueryResultMpeg4GifTest(BaseTest, unittest.TestCase):
|
|||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
telegram.InlineKeyboardButton('reply_markup')
|
||||
]])
|
||||
|
||||
self.json_dict = {
|
||||
'type': self.type,
|
||||
|
@ -85,9 +85,8 @@ class InlineQueryResultMpeg4GifTest(BaseTest, unittest.TestCase):
|
|||
self.assertTrue(self.is_json(mpeg4.to_json()))
|
||||
|
||||
def test_mpeg4_to_dict(self):
|
||||
mpeg4 = \
|
||||
telegram.InlineQueryResultMpeg4Gif.de_json(
|
||||
self.json_dict).to_dict()
|
||||
mpeg4 = telegram.InlineQueryResultMpeg4Gif.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(mpeg4))
|
||||
self.assertDictEqual(self.json_dict, mpeg4)
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram
|
||||
InlineQueryResultPhoto"""
|
||||
|
||||
|
@ -49,7 +48,8 @@ class InlineQueryResultPhotoTest(BaseTest, unittest.TestCase):
|
|||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
telegram.InlineKeyboardButton('reply_markup')
|
||||
]])
|
||||
|
||||
self.json_dict = {
|
||||
'type': self.type,
|
||||
|
@ -88,8 +88,8 @@ class InlineQueryResultPhotoTest(BaseTest, unittest.TestCase):
|
|||
self.assertTrue(self.is_json(photo.to_json()))
|
||||
|
||||
def test_photo_to_dict(self):
|
||||
photo = \
|
||||
telegram.InlineQueryResultPhoto.de_json(self.json_dict).to_dict()
|
||||
photo = telegram.InlineQueryResultPhoto.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(photo))
|
||||
self.assertDictEqual(self.json_dict, photo)
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram
|
||||
InlineQueryResultVenue"""
|
||||
|
||||
|
@ -50,7 +49,8 @@ class InlineQueryResultVenueTest(BaseTest, unittest.TestCase):
|
|||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
telegram.InlineKeyboardButton('reply_markup')
|
||||
]])
|
||||
self.json_dict = {
|
||||
'id': self.id,
|
||||
'type': self.type,
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram
|
||||
InlineQueryResultVideo"""
|
||||
|
||||
|
@ -51,7 +50,8 @@ class InlineQueryResultVideoTest(BaseTest, unittest.TestCase):
|
|||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
telegram.InlineKeyboardButton('reply_markup')
|
||||
]])
|
||||
|
||||
self.json_dict = {
|
||||
'type': self.type,
|
||||
|
@ -94,8 +94,8 @@ class InlineQueryResultVideoTest(BaseTest, unittest.TestCase):
|
|||
self.assertTrue(self.is_json(video.to_json()))
|
||||
|
||||
def test_video_to_dict(self):
|
||||
video = \
|
||||
telegram.InlineQueryResultVideo.de_json(self.json_dict).to_dict()
|
||||
video = telegram.InlineQueryResultVideo.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(video))
|
||||
self.assertDictEqual(self.json_dict, video)
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram
|
||||
InlineQueryResultVoice"""
|
||||
|
||||
|
@ -45,7 +44,8 @@ class InlineQueryResultVoiceTest(BaseTest, unittest.TestCase):
|
|||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
telegram.InlineKeyboardButton('reply_markup')
|
||||
]])
|
||||
|
||||
self.json_dict = {
|
||||
'type': self.type,
|
||||
|
@ -76,8 +76,8 @@ class InlineQueryResultVoiceTest(BaseTest, unittest.TestCase):
|
|||
self.assertTrue(self.is_json(voice.to_json()))
|
||||
|
||||
def test_voice_to_dict(self):
|
||||
voice = \
|
||||
telegram.InlineQueryResultVoice.de_json(self.json_dict).to_dict()
|
||||
voice = telegram.InlineQueryResultVoice.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(voice))
|
||||
self.assertDictEqual(self.json_dict, voice)
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram
|
||||
InputContactMessageContent"""
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram
|
||||
InputLocationMessageContent"""
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram
|
||||
InputMessageContent"""
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram
|
||||
InputTextMessageContent"""
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram
|
||||
InputVenueMessageContent"""
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""
|
||||
This module contains a object that represents Tests for JobQueue
|
||||
"""
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram Location"""
|
||||
|
||||
import sys
|
||||
|
@ -41,8 +40,7 @@ class LocationTest(BaseTest, unittest.TestCase):
|
|||
}
|
||||
|
||||
def test_send_location_implicit_args(self):
|
||||
message = self._bot.sendLocation(self._chat_id,
|
||||
self.latitude,
|
||||
message = self._bot.sendLocation(self._chat_id, self.latitude,
|
||||
self.longitude)
|
||||
|
||||
location = message.location
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram ParseMode"""
|
||||
|
||||
import sys
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram Photo"""
|
||||
|
||||
import sys
|
||||
|
@ -40,10 +39,13 @@ class PhotoTest(BaseTest, unittest.TestCase):
|
|||
self.photo_file_url = 'https://raw.githubusercontent.com/python-telegram-bot/python-telegram-bot/master/tests/data/telegram.jpg'
|
||||
self.width = 300
|
||||
self.height = 300
|
||||
self.thumb = {'width': 90,
|
||||
'height': 90,
|
||||
'file_id': 'AgADAQADvb8xGx8j9QcpZDKxYoFK3bfX1i8ABBxRLXFhLnhIQ-gAAgI',
|
||||
'file_size': 1478}
|
||||
self.thumb = {
|
||||
'width': 90,
|
||||
'height': 90,
|
||||
'file_id':
|
||||
'AgADAQADvb8xGx8j9QcpZDKxYoFK3bfX1i8ABBxRLXFhLnhIQ-gAAgI',
|
||||
'file_size': 1478
|
||||
}
|
||||
self.file_size = 10209
|
||||
|
||||
# caption is part of sendPhoto method but not Photo object
|
||||
|
@ -84,8 +86,7 @@ class PhotoTest(BaseTest, unittest.TestCase):
|
|||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
def test_send_photo_jpg_file(self):
|
||||
message = self._bot.sendPhoto(self._chat_id,
|
||||
self.photo_file)
|
||||
message = self._bot.sendPhoto(self._chat_id, self.photo_file)
|
||||
|
||||
thumb, photo = message.photo
|
||||
|
||||
|
@ -106,8 +107,7 @@ class PhotoTest(BaseTest, unittest.TestCase):
|
|||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
def test_send_photo_url_jpg_file(self):
|
||||
message = self._bot.sendPhoto(self._chat_id,
|
||||
self.photo_file_url)
|
||||
message = self._bot.sendPhoto(self._chat_id, self.photo_file_url)
|
||||
|
||||
thumb, photo = message.photo
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram ReplyKeyboardHide"""
|
||||
|
||||
import sys
|
||||
|
@ -42,10 +41,10 @@ class ReplyKeyboardHideTest(BaseTest, unittest.TestCase):
|
|||
}
|
||||
|
||||
def test_send_message_with_reply_keyboard_hide(self):
|
||||
message = self._bot.sendMessage(self._chat_id,
|
||||
'Моё судно на воздушной подушке полно угрей',
|
||||
reply_markup=telegram.ReplyKeyboardHide.de_json(
|
||||
self.json_dict))
|
||||
message = self._bot.sendMessage(
|
||||
self._chat_id,
|
||||
'Моё судно на воздушной подушке полно угрей',
|
||||
reply_markup=telegram.ReplyKeyboardHide.de_json(self.json_dict))
|
||||
|
||||
self.assertTrue(self.is_json(message.to_json()))
|
||||
self.assertEqual(message.text,
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram ReplyKeyboardMarkup"""
|
||||
|
||||
import sys
|
||||
|
@ -48,10 +47,10 @@ class ReplyKeyboardMarkupTest(BaseTest, unittest.TestCase):
|
|||
}
|
||||
|
||||
def test_send_message_with_reply_keyboard_markup(self):
|
||||
message = self._bot.sendMessage(self._chat_id,
|
||||
'Моё судно на воздушной подушке полно угрей',
|
||||
reply_markup=telegram.ReplyKeyboardMarkup.de_json(
|
||||
self.json_dict))
|
||||
message = self._bot.sendMessage(
|
||||
self._chat_id,
|
||||
'Моё судно на воздушной подушке полно угрей',
|
||||
reply_markup=telegram.ReplyKeyboardMarkup.de_json(self.json_dict))
|
||||
|
||||
self.assertTrue(self.is_json(message.to_json()))
|
||||
self.assertEqual(message.text,
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram Sticker"""
|
||||
|
||||
import sys
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram Update"""
|
||||
|
||||
import sys
|
||||
|
@ -46,10 +45,7 @@ class UpdateTest(BaseTest, unittest.TestCase):
|
|||
'date': 1441644592,
|
||||
'text': "Update Test"}
|
||||
|
||||
self.json_dict = {
|
||||
'update_id': self.update_id,
|
||||
'message': self.message
|
||||
}
|
||||
self.json_dict = {'update_id': self.update_id, 'message': self.message}
|
||||
|
||||
def test_update_de_json(self):
|
||||
update = telegram.Update.de_json(self.json_dict)
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""
|
||||
This module contains a object that represents Tests for Updater, Dispatcher,
|
||||
WebhookServer and WebhookHandler
|
||||
|
@ -162,8 +161,8 @@ class UpdaterTest(BaseTest, unittest.TestCase):
|
|||
|
||||
def test_addTelegramMessageHandlerMultipleMessages(self):
|
||||
self._setup_updater('Multiple', 100)
|
||||
self.updater.dispatcher.addHandler(
|
||||
MessageHandler([], self.telegramHandlerTest))
|
||||
self.updater.dispatcher.addHandler(MessageHandler(
|
||||
[], self.telegramHandlerTest))
|
||||
self.updater.start_polling(0.0)
|
||||
sleep(2)
|
||||
self.assertEqual(self.received_message, 'Multiple')
|
||||
|
@ -366,8 +365,10 @@ class UpdaterTest(BaseTest, unittest.TestCase):
|
|||
|
||||
def test_additionalArgs(self):
|
||||
self._setup_updater('', messages=0)
|
||||
handler = StringCommandHandler('test5', self.additionalArgsTest,
|
||||
pass_update_queue=True, pass_args=True)
|
||||
handler = StringCommandHandler('test5',
|
||||
self.additionalArgsTest,
|
||||
pass_update_queue=True,
|
||||
pass_args=True)
|
||||
self.updater.dispatcher.addHandler(handler)
|
||||
|
||||
queue = self.updater.start_polling(0.01)
|
||||
|
@ -381,7 +382,8 @@ class UpdaterTest(BaseTest, unittest.TestCase):
|
|||
d = self.updater.dispatcher
|
||||
handler = StringRegexHandler('^(This).*?(?P<testgroup>regex group).*',
|
||||
self.regexGroupHandlerTest,
|
||||
pass_groupdict=True, pass_groups=True)
|
||||
pass_groupdict=True,
|
||||
pass_groups=True)
|
||||
d.addHandler(handler)
|
||||
queue = self.updater.start_polling(0.01)
|
||||
queue.put('This is a test message for regex group matching.')
|
||||
|
@ -392,7 +394,8 @@ class UpdaterTest(BaseTest, unittest.TestCase):
|
|||
def test_runAsyncWithAdditionalArgs(self):
|
||||
self._setup_updater('Test6', messages=2)
|
||||
d = self.updater.dispatcher
|
||||
handler = MessageHandler([], self.asyncAdditionalHandlerTest,
|
||||
handler = MessageHandler([],
|
||||
self.asyncAdditionalHandlerTest,
|
||||
pass_update_queue=True)
|
||||
d.addHandler(handler)
|
||||
self.updater.start_polling(0.01)
|
||||
|
@ -408,7 +411,8 @@ class UpdaterTest(BaseTest, unittest.TestCase):
|
|||
|
||||
ip = '127.0.0.1'
|
||||
port = randrange(1024, 49152) # Select random port for travis
|
||||
self.updater.start_webhook(ip, port,
|
||||
self.updater.start_webhook(ip,
|
||||
port,
|
||||
url_path='TOKEN',
|
||||
cert='./tests/test_updater.py',
|
||||
key='./tests/test_updater.py',
|
||||
|
@ -418,7 +422,9 @@ class UpdaterTest(BaseTest, unittest.TestCase):
|
|||
Thread(target=self.updater.httpd.serve_forever).start()
|
||||
|
||||
# Now, we send an update to the server via urlopen
|
||||
message = Message(1, User(1, "Tester"), datetime.now(),
|
||||
message = Message(1,
|
||||
User(1, "Tester"),
|
||||
datetime.now(),
|
||||
Chat(1, "group", title="Test Group"))
|
||||
|
||||
message.text = "Webhook Test"
|
||||
|
@ -435,8 +441,10 @@ class UpdaterTest(BaseTest, unittest.TestCase):
|
|||
self.assertEqual(b'', response.read())
|
||||
self.assertEqual(200, response.code)
|
||||
|
||||
response = self._send_webhook_msg(ip, port, None, 'webookhandler.py',
|
||||
get_method=lambda: 'HEAD')
|
||||
response = self._send_webhook_msg(
|
||||
ip, port,
|
||||
None, 'webookhandler.py',
|
||||
get_method=lambda: 'HEAD')
|
||||
|
||||
self.assertEqual(b'', response.read())
|
||||
self.assertEqual(200, response.code)
|
||||
|
@ -458,7 +466,9 @@ class UpdaterTest(BaseTest, unittest.TestCase):
|
|||
sleep(0.5)
|
||||
|
||||
# Now, we send an update to the server via urlopen
|
||||
message = Message(1, User(1, "Tester 2"), datetime.now(),
|
||||
message = Message(1,
|
||||
User(1, "Tester 2"),
|
||||
datetime.now(),
|
||||
Chat(1, 'group', title="Test Group 2"))
|
||||
|
||||
message.text = "Webhook Test 2"
|
||||
|
@ -484,7 +494,9 @@ class UpdaterTest(BaseTest, unittest.TestCase):
|
|||
|
||||
def test_bootstrap_retries_unauth(self):
|
||||
retries = 3
|
||||
self._setup_updater('', messages=0, bootstrap_retries=retries,
|
||||
self._setup_updater('',
|
||||
messages=0,
|
||||
bootstrap_retries=retries,
|
||||
bootstrap_err=Unauthorized())
|
||||
|
||||
self.assertRaises(Unauthorized, self.updater._set_webhook, 'path',
|
||||
|
@ -493,7 +505,9 @@ class UpdaterTest(BaseTest, unittest.TestCase):
|
|||
|
||||
def test_bootstrap_retries_invalid_token(self):
|
||||
retries = 3
|
||||
self._setup_updater('', messages=0, bootstrap_retries=retries,
|
||||
self._setup_updater('',
|
||||
messages=0,
|
||||
bootstrap_retries=retries,
|
||||
bootstrap_err=InvalidToken())
|
||||
|
||||
self.assertRaises(InvalidToken, self.updater._set_webhook, 'path',
|
||||
|
@ -522,14 +536,16 @@ class UpdaterTest(BaseTest, unittest.TestCase):
|
|||
|
||||
try:
|
||||
with self.assertRaises(HTTPError) as ctx:
|
||||
self._send_webhook_msg(ip, port,
|
||||
self._send_webhook_msg(ip,
|
||||
port,
|
||||
'<root><bla>data</bla></root>',
|
||||
content_type='application/xml')
|
||||
self.assertEqual(ctx.exception.code, 403)
|
||||
|
||||
with self.assertRaises(HTTPError) as ctx:
|
||||
self._send_webhook_msg(ip, port, 'dummy-payload',
|
||||
content_len=-2)
|
||||
self._send_webhook_msg(
|
||||
ip, port, 'dummy-payload',
|
||||
content_len=-2)
|
||||
self.assertEqual(ctx.exception.code, 403)
|
||||
|
||||
# TODO: prevent urllib or the underlying from adding content-length
|
||||
|
@ -539,7 +555,9 @@ class UpdaterTest(BaseTest, unittest.TestCase):
|
|||
# self.assertEqual(ctx.exception.code, 411)
|
||||
|
||||
with self.assertRaises(HTTPError) as ctx:
|
||||
self._send_webhook_msg(ip, port, 'dummy-payload',
|
||||
self._send_webhook_msg(ip,
|
||||
port,
|
||||
'dummy-payload',
|
||||
content_len='not-a-number')
|
||||
self.assertEqual(ctx.exception.code, 403)
|
||||
|
||||
|
@ -547,12 +565,15 @@ class UpdaterTest(BaseTest, unittest.TestCase):
|
|||
self.updater._stop_httpd()
|
||||
thr.join()
|
||||
|
||||
def _send_webhook_msg(self, ip, port, payload_str, url_path='',
|
||||
content_len=-1, content_type='application/json',
|
||||
def _send_webhook_msg(self,
|
||||
ip,
|
||||
port,
|
||||
payload_str,
|
||||
url_path='',
|
||||
content_len=-1,
|
||||
content_type='application/json',
|
||||
get_method=None):
|
||||
headers = {
|
||||
'content-type': content_type,
|
||||
}
|
||||
headers = {'content-type': content_type, }
|
||||
|
||||
if not payload_str:
|
||||
content_len = None
|
||||
|
@ -566,8 +587,8 @@ class UpdaterTest(BaseTest, unittest.TestCase):
|
|||
if content_len is not None:
|
||||
headers['content-length'] = str(content_len)
|
||||
|
||||
url = 'http://{ip}:{port}/{path}'.format(ip=ip, port=port,
|
||||
path=url_path)
|
||||
url = 'http://{ip}:{port}/{path}'.format(
|
||||
ip=ip, port=port, path=url_path)
|
||||
|
||||
req = Request(url, data=payload, headers=headers)
|
||||
|
||||
|
@ -602,8 +623,12 @@ class UpdaterTest(BaseTest, unittest.TestCase):
|
|||
|
||||
|
||||
class MockBot(object):
|
||||
def __init__(self, text, messages=1, raise_error=False,
|
||||
bootstrap_retries=None, bootstrap_err=TelegramError('test')):
|
||||
def __init__(self,
|
||||
text,
|
||||
messages=1,
|
||||
raise_error=False,
|
||||
bootstrap_retries=None,
|
||||
bootstrap_err=TelegramError('test')):
|
||||
self.text = text
|
||||
self.send_messages = messages
|
||||
self.raise_error = raise_error
|
||||
|
@ -628,11 +653,7 @@ class MockBot(object):
|
|||
self.bootstrap_attempts += 1
|
||||
raise self.bootstrap_err
|
||||
|
||||
def getUpdates(self,
|
||||
offset=None,
|
||||
limit=100,
|
||||
timeout=0,
|
||||
network_delay=2.):
|
||||
def getUpdates(self, offset=None, limit=100, timeout=0, network_delay=2.):
|
||||
|
||||
if self.raise_error:
|
||||
raise TelegramError('Test Error 2')
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram User"""
|
||||
|
||||
import sys
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram Video"""
|
||||
|
||||
import sys
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
"""This module contains a object that represents Tests for Telegram Voice"""
|
||||
|
||||
import sys
|
||||
|
@ -52,8 +51,7 @@ class VoiceTest(BaseTest, unittest.TestCase):
|
|||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
def test_send_voice_required_args_only(self):
|
||||
message = self._bot.sendVoice(self._chat_id,
|
||||
self.voice_file)
|
||||
message = self._bot.sendVoice(self._chat_id, self.voice_file)
|
||||
|
||||
voice = message.voice
|
||||
|
||||
|
|
Loading…
Reference in a new issue