From 35f6de326b84527196f7ee97eefd23b0b0b98426 Mon Sep 17 00:00:00 2001 From: Leandro Toledo Date: Tue, 26 Apr 2016 18:23:15 -0300 Subject: [PATCH] Add InlineKeyboardButtonTest and reformatting. --- tests/base.py | 5 +- tests/test_audio.py | 4 +- tests/test_bot.py | 21 ++--- tests/test_botan.py | 1 - tests/test_chat.py | 1 - tests/test_choseninlineresult.py | 1 - tests/test_contact.py | 1 - tests/test_document.py | 7 +- tests/test_emoji.py | 1 - tests/test_file.py | 7 +- tests/test_forcereply.py | 9 +- tests/test_inlinekeyboardbutton.py | 73 ++++++++++++++++ tests/test_inlinekeyboardmarkup.py | 33 ++++--- tests/test_inlinequery.py | 1 - tests/test_inlinequeryresultarticle.py | 8 +- tests/test_inlinequeryresultaudio.py | 8 +- tests/test_inlinequeryresultcachedaudio.py | 9 +- tests/test_inlinequeryresultcacheddocument.py | 9 +- tests/test_inlinequeryresultcachedgif.py | 4 +- tests/test_inlinequeryresultcachedmpeg4gif.py | 9 +- tests/test_inlinequeryresultcachedphoto.py | 9 +- tests/test_inlinequeryresultcachedsticker.py | 9 +- tests/test_inlinequeryresultcachedvideo.py | 9 +- tests/test_inlinequeryresultcachedvoice.py | 9 +- tests/test_inlinequeryresultcontact.py | 9 +- tests/test_inlinequeryresultdocument.py | 9 +- tests/test_inlinequeryresultgif.py | 4 +- tests/test_inlinequeryresultlocation.py | 9 +- tests/test_inlinequeryresultmpeg4gif.py | 9 +- tests/test_inlinequeryresultphoto.py | 8 +- tests/test_inlinequeryresultvenue.py | 4 +- tests/test_inlinequeryresultvideo.py | 8 +- tests/test_inlinequeryresultvoice.py | 8 +- tests/test_inputcontactmessagecontent.py | 1 - tests/test_inputlocationmessagecontent.py | 1 - tests/test_inputmessagecontent.py | 1 - tests/test_inputtextmessagecontent.py | 1 - tests/test_inputvenuemessagecontent.py | 1 - tests/test_jobqueue.py | 1 - tests/test_location.py | 4 +- tests/test_parsemode.py | 1 - tests/test_photo.py | 18 ++-- tests/test_replykeyboardhide.py | 9 +- tests/test_replykeyboardmarkup.py | 9 +- tests/test_sticker.py | 1 - tests/test_update.py | 6 +- tests/test_updater.py | 85 ++++++++++++------- tests/test_user.py | 1 - tests/test_video.py | 1 - tests/test_voice.py | 4 +- 50 files changed, 255 insertions(+), 206 deletions(-) create mode 100644 tests/test_inlinekeyboardbutton.py diff --git a/tests/base.py b/tests/base.py index 6ec4c077c..388c301d5 100644 --- a/tests/base.py +++ b/tests/base.py @@ -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 diff --git a/tests/test_audio.py b/tests/test_audio.py index f1603853e..e011eb8ec 100644 --- a/tests/test_audio.py +++ b/tests/test_audio.py @@ -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 diff --git a/tests/test_bot.py b/tests/test_bot.py index 222368130..43cf4de88 100644 --- a/tests/test_bot.py +++ b/tests/test_bot.py @@ -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) diff --git a/tests/test_botan.py b/tests/test_botan.py index 6d5f2a0ea..e78c10128 100644 --- a/tests/test_botan.py +++ b/tests/test_botan.py @@ -1,5 +1,4 @@ #!/usr/bin/env python - """This module contains a object that represents Tests for Botan analytics integration""" import sys diff --git a/tests/test_chat.py b/tests/test_chat.py index 1d6eb1493..41aa34f96 100644 --- a/tests/test_chat.py +++ b/tests/test_chat.py @@ -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 diff --git a/tests/test_choseninlineresult.py b/tests/test_choseninlineresult.py index 6ebc40086..401049aa4 100644 --- a/tests/test_choseninlineresult.py +++ b/tests/test_choseninlineresult.py @@ -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""" diff --git a/tests/test_contact.py b/tests/test_contact.py index 61853a9de..4d93cb224 100644 --- a/tests/test_contact.py +++ b/tests/test_contact.py @@ -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 diff --git a/tests/test_document.py b/tests/test_document.py index 61bebf4d8..c8c7c099d 100644 --- a/tests/test_document.py +++ b/tests/test_document.py @@ -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 diff --git a/tests/test_emoji.py b/tests/test_emoji.py index 69700f299..d717f9caf 100644 --- a/tests/test_emoji.py +++ b/tests/test_emoji.py @@ -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 diff --git a/tests/test_file.py b/tests/test_file.py index aa54eaf72..651dfbde5 100644 --- a/tests/test_file.py +++ b/tests/test_file.py @@ -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__': diff --git a/tests/test_forcereply.py b/tests/test_forcereply.py index b1ff08421..3b3382f84 100644 --- a/tests/test_forcereply.py +++ b/tests/test_forcereply.py @@ -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, diff --git a/tests/test_inlinekeyboardbutton.py b/tests/test_inlinekeyboardbutton.py new file mode 100644 index 000000000..8fe39956f --- /dev/null +++ b/tests/test_inlinekeyboardbutton.py @@ -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 +# +# 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() diff --git a/tests/test_inlinekeyboardmarkup.py b/tests/test_inlinekeyboardmarkup.py index 0813b3d19..a7b47bf96 100644 --- a/tests/test_inlinekeyboardmarkup.py +++ b/tests/test_inlinekeyboardmarkup.py @@ -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__': diff --git a/tests/test_inlinequery.py b/tests/test_inlinequery.py index a8152625b..41af69756 100644 --- a/tests/test_inlinequery.py +++ b/tests/test_inlinequery.py @@ -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""" diff --git a/tests/test_inlinequeryresultarticle.py b/tests/test_inlinequeryresultarticle.py index 3ea1bcb19..032b96567 100644 --- a/tests/test_inlinequeryresultarticle.py +++ b/tests/test_inlinequeryresultarticle.py @@ -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) diff --git a/tests/test_inlinequeryresultaudio.py b/tests/test_inlinequeryresultaudio.py index 4dab0fea8..f2696cf5e 100644 --- a/tests/test_inlinequeryresultaudio.py +++ b/tests/test_inlinequeryresultaudio.py @@ -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) diff --git a/tests/test_inlinequeryresultcachedaudio.py b/tests/test_inlinequeryresultcachedaudio.py index 01659a1d8..1ebeba514 100644 --- a/tests/test_inlinequeryresultcachedaudio.py +++ b/tests/test_inlinequeryresultcachedaudio.py @@ -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) diff --git a/tests/test_inlinequeryresultcacheddocument.py b/tests/test_inlinequeryresultcacheddocument.py index 2172c9f53..77e1f836c 100644 --- a/tests/test_inlinequeryresultcacheddocument.py +++ b/tests/test_inlinequeryresultcacheddocument.py @@ -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) diff --git a/tests/test_inlinequeryresultcachedgif.py b/tests/test_inlinequeryresultcachedgif.py index 3de5fc90b..b15c1eb47 100644 --- a/tests/test_inlinequeryresultcachedgif.py +++ b/tests/test_inlinequeryresultcachedgif.py @@ -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, diff --git a/tests/test_inlinequeryresultcachedmpeg4gif.py b/tests/test_inlinequeryresultcachedmpeg4gif.py index 55c9d10c8..968a32df6 100644 --- a/tests/test_inlinequeryresultcachedmpeg4gif.py +++ b/tests/test_inlinequeryresultcachedmpeg4gif.py @@ -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) diff --git a/tests/test_inlinequeryresultcachedphoto.py b/tests/test_inlinequeryresultcachedphoto.py index 2ee4697a1..1542197bf 100644 --- a/tests/test_inlinequeryresultcachedphoto.py +++ b/tests/test_inlinequeryresultcachedphoto.py @@ -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) diff --git a/tests/test_inlinequeryresultcachedsticker.py b/tests/test_inlinequeryresultcachedsticker.py index 0e3aa2e4a..04bbcf44f 100644 --- a/tests/test_inlinequeryresultcachedsticker.py +++ b/tests/test_inlinequeryresultcachedsticker.py @@ -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) diff --git a/tests/test_inlinequeryresultcachedvideo.py b/tests/test_inlinequeryresultcachedvideo.py index d48de2c92..3b0c43628 100644 --- a/tests/test_inlinequeryresultcachedvideo.py +++ b/tests/test_inlinequeryresultcachedvideo.py @@ -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) diff --git a/tests/test_inlinequeryresultcachedvoice.py b/tests/test_inlinequeryresultcachedvoice.py index fd1002b91..56615aabb 100644 --- a/tests/test_inlinequeryresultcachedvoice.py +++ b/tests/test_inlinequeryresultcachedvoice.py @@ -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) diff --git a/tests/test_inlinequeryresultcontact.py b/tests/test_inlinequeryresultcontact.py index 92c6ae8ca..d0f15458c 100644 --- a/tests/test_inlinequeryresultcontact.py +++ b/tests/test_inlinequeryresultcontact.py @@ -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) diff --git a/tests/test_inlinequeryresultdocument.py b/tests/test_inlinequeryresultdocument.py index 772b77d3b..eb0007928 100644 --- a/tests/test_inlinequeryresultdocument.py +++ b/tests/test_inlinequeryresultdocument.py @@ -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) diff --git a/tests/test_inlinequeryresultgif.py b/tests/test_inlinequeryresultgif.py index ed4baf85e..27c5b52e0 100644 --- a/tests/test_inlinequeryresultgif.py +++ b/tests/test_inlinequeryresultgif.py @@ -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, diff --git a/tests/test_inlinequeryresultlocation.py b/tests/test_inlinequeryresultlocation.py index 0c9512c9d..e85cd5cad 100644 --- a/tests/test_inlinequeryresultlocation.py +++ b/tests/test_inlinequeryresultlocation.py @@ -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) diff --git a/tests/test_inlinequeryresultmpeg4gif.py b/tests/test_inlinequeryresultmpeg4gif.py index e11d19aee..b6777f654 100644 --- a/tests/test_inlinequeryresultmpeg4gif.py +++ b/tests/test_inlinequeryresultmpeg4gif.py @@ -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) diff --git a/tests/test_inlinequeryresultphoto.py b/tests/test_inlinequeryresultphoto.py index f8459e2bf..c7d259858 100644 --- a/tests/test_inlinequeryresultphoto.py +++ b/tests/test_inlinequeryresultphoto.py @@ -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) diff --git a/tests/test_inlinequeryresultvenue.py b/tests/test_inlinequeryresultvenue.py index 4ceed0ca0..a2c177b1c 100644 --- a/tests/test_inlinequeryresultvenue.py +++ b/tests/test_inlinequeryresultvenue.py @@ -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, diff --git a/tests/test_inlinequeryresultvideo.py b/tests/test_inlinequeryresultvideo.py index 836919aa0..a72ba52ba 100644 --- a/tests/test_inlinequeryresultvideo.py +++ b/tests/test_inlinequeryresultvideo.py @@ -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) diff --git a/tests/test_inlinequeryresultvoice.py b/tests/test_inlinequeryresultvoice.py index 12d2b68cf..6b47ffdcd 100644 --- a/tests/test_inlinequeryresultvoice.py +++ b/tests/test_inlinequeryresultvoice.py @@ -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) diff --git a/tests/test_inputcontactmessagecontent.py b/tests/test_inputcontactmessagecontent.py index 231759cfd..da90ada01 100644 --- a/tests/test_inputcontactmessagecontent.py +++ b/tests/test_inputcontactmessagecontent.py @@ -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""" diff --git a/tests/test_inputlocationmessagecontent.py b/tests/test_inputlocationmessagecontent.py index 73374ab75..2a8856b9c 100644 --- a/tests/test_inputlocationmessagecontent.py +++ b/tests/test_inputlocationmessagecontent.py @@ -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""" diff --git a/tests/test_inputmessagecontent.py b/tests/test_inputmessagecontent.py index 11e303fb2..af91261ee 100644 --- a/tests/test_inputmessagecontent.py +++ b/tests/test_inputmessagecontent.py @@ -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""" diff --git a/tests/test_inputtextmessagecontent.py b/tests/test_inputtextmessagecontent.py index b34536fe2..d9311fa0b 100644 --- a/tests/test_inputtextmessagecontent.py +++ b/tests/test_inputtextmessagecontent.py @@ -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""" diff --git a/tests/test_inputvenuemessagecontent.py b/tests/test_inputvenuemessagecontent.py index ad37e0e3f..d1613cc43 100644 --- a/tests/test_inputvenuemessagecontent.py +++ b/tests/test_inputvenuemessagecontent.py @@ -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""" diff --git a/tests/test_jobqueue.py b/tests/test_jobqueue.py index e8bf7aab5..5bad9820a 100644 --- a/tests/test_jobqueue.py +++ b/tests/test_jobqueue.py @@ -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 """ diff --git a/tests/test_location.py b/tests/test_location.py index b192fe1a0..49f2be19a 100644 --- a/tests/test_location.py +++ b/tests/test_location.py @@ -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 diff --git a/tests/test_parsemode.py b/tests/test_parsemode.py index b426e4a7e..f967349ce 100644 --- a/tests/test_parsemode.py +++ b/tests/test_parsemode.py @@ -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 diff --git a/tests/test_photo.py b/tests/test_photo.py index 4c4d9a16c..964dccf24 100644 --- a/tests/test_photo.py +++ b/tests/test_photo.py @@ -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 diff --git a/tests/test_replykeyboardhide.py b/tests/test_replykeyboardhide.py index 1ebf8aade..63180a890 100644 --- a/tests/test_replykeyboardhide.py +++ b/tests/test_replykeyboardhide.py @@ -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, diff --git a/tests/test_replykeyboardmarkup.py b/tests/test_replykeyboardmarkup.py index 90304706a..e8c6c71cb 100644 --- a/tests/test_replykeyboardmarkup.py +++ b/tests/test_replykeyboardmarkup.py @@ -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, diff --git a/tests/test_sticker.py b/tests/test_sticker.py index 9172ec66c..0a5e4bc37 100644 --- a/tests/test_sticker.py +++ b/tests/test_sticker.py @@ -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 diff --git a/tests/test_update.py b/tests/test_update.py index ac9d628df..ec6628cb5 100644 --- a/tests/test_update.py +++ b/tests/test_update.py @@ -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) diff --git a/tests/test_updater.py b/tests/test_updater.py index 2ce372ce7..1be9d234d 100644 --- a/tests/test_updater.py +++ b/tests/test_updater.py @@ -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).*?(?Pregex 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, 'data', 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') diff --git a/tests/test_user.py b/tests/test_user.py index 40bd9c160..5bd4a941a 100644 --- a/tests/test_user.py +++ b/tests/test_user.py @@ -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 diff --git a/tests/test_video.py b/tests/test_video.py index 6fcffcdbb..e9960708f 100644 --- a/tests/test_video.py +++ b/tests/test_video.py @@ -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 diff --git a/tests/test_voice.py b/tests/test_voice.py index 935a57514..919d7dfbc 100644 --- a/tests/test_voice.py +++ b/tests/test_voice.py @@ -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