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