From d80e0b4b8cde648bffde39c35e1a27e68d8ccbb7 Mon Sep 17 00:00:00 2001 From: Leandro Toledo Date: Tue, 26 Apr 2016 22:48:02 -0300 Subject: [PATCH] Add more test cases --- tests/test_forcereply.py | 5 ++++ tests/test_inlinekeyboardbutton.py | 10 +++++++ tests/test_inlinekeyboardmarkup.py | 5 ++++ tests/test_keyboardbutton.py | 10 +++++++ tests/test_replykeyboardhide.py | 5 ++++ tests/test_replykeyboardmarkup.py | 5 ++++ tests/test_replymarkup.py | 45 ++++++++++++++++++++++++++++++ tests/test_update.py | 5 ++++ 8 files changed, 90 insertions(+) create mode 100644 tests/test_replymarkup.py diff --git a/tests/test_forcereply.py b/tests/test_forcereply.py index 3b3382f84..73f51edd4 100644 --- a/tests/test_forcereply.py +++ b/tests/test_forcereply.py @@ -56,6 +56,11 @@ class ForceReplyTest(BaseTest, unittest.TestCase): self.assertEqual(force_reply.force_reply, self.force_reply) self.assertEqual(force_reply.selective, self.selective) + def test_force_reply_de_json_empty(self): + force_reply = telegram.ForceReply.de_json(None) + + self.assertFalse(force_reply) + def test_force_reply_to_json(self): force_reply = telegram.ForceReply.de_json(self.json_dict) diff --git a/tests/test_inlinekeyboardbutton.py b/tests/test_inlinekeyboardbutton.py index 22a142f9b..0ef3d99a3 100644 --- a/tests/test_inlinekeyboardbutton.py +++ b/tests/test_inlinekeyboardbutton.py @@ -59,6 +59,16 @@ class InlineKeyboardButtonTest(BaseTest, unittest.TestCase): self.assertEqual(inline_keyboard_button.switch_inline_query, self.switch_inline_query) + def test_inline_keyboard_button_de_json_empty(self): + inline_keyboard_button = telegram.InlineKeyboardButton.de_json(None) + + self.assertFalse(inline_keyboard_button) + + def test_inline_keyboard_button_de_list_empty(self): + inline_keyboard_button = telegram.InlineKeyboardButton.de_list(None) + + self.assertFalse(inline_keyboard_button) + def test_inline_keyboard_button_to_json(self): inline_keyboard_button = telegram.InlineKeyboardButton.de_json( self.json_dict) diff --git a/tests/test_inlinekeyboardmarkup.py b/tests/test_inlinekeyboardmarkup.py index a7b47bf96..aa8e13949 100644 --- a/tests/test_inlinekeyboardmarkup.py +++ b/tests/test_inlinekeyboardmarkup.py @@ -51,6 +51,11 @@ class InlineKeyboardMarkupTest(BaseTest, unittest.TestCase): self.assertTrue(self.is_json(message.to_json())) self.assertEqual(message.text, 'Testing InlineKeyboardMarkup') + def test_inline_keyboard_markup_de_json_empty(self): + inline_keyboard_markup = telegram.InlineKeyboardMarkup.de_json(None) + + self.assertFalse(inline_keyboard_markup) + def test_inline_keyboard_markup_de_json(self): inline_keyboard_markup = telegram.InlineKeyboardMarkup.de_json( self.json_dict) diff --git a/tests/test_keyboardbutton.py b/tests/test_keyboardbutton.py index 2eb92f1bd..2af27ae4c 100644 --- a/tests/test_keyboardbutton.py +++ b/tests/test_keyboardbutton.py @@ -55,6 +55,16 @@ class KeyboardButtonTest(BaseTest, unittest.TestCase): self.request_location) self.assertEqual(keyboard_button.request_contact, self.request_contact) + def test_keyboard_button_de_json_empty(self): + keyboard_button = telegram.KeyboardButton.de_json(None) + + self.assertFalse(keyboard_button) + + def test_keyboard_button_de_list_empty(self): + keyboard_button = telegram.KeyboardButton.de_list(None) + + self.assertFalse(keyboard_button) + def test_keyboard_button_to_json(self): keyboard_button = telegram.KeyboardButton.de_json(self.json_dict) diff --git a/tests/test_replykeyboardhide.py b/tests/test_replykeyboardhide.py index 63180a890..b6d35fd07 100644 --- a/tests/test_replykeyboardhide.py +++ b/tests/test_replykeyboardhide.py @@ -57,6 +57,11 @@ class ReplyKeyboardHideTest(BaseTest, unittest.TestCase): self.assertEqual(reply_keyboard_hide.hide_keyboard, self.hide_keyboard) self.assertEqual(reply_keyboard_hide.selective, self.selective) + def test_reply_keyboard_hide_de_json_empty(self): + reply_keyboard_hide = telegram.ReplyKeyboardHide.de_json(None) + + self.assertFalse(reply_keyboard_hide) + def test_reply_keyboard_hide_to_json(self): reply_keyboard_hide = telegram.ReplyKeyboardHide.de_json( self.json_dict) diff --git a/tests/test_replykeyboardmarkup.py b/tests/test_replykeyboardmarkup.py index e8c6c71cb..1209a3dee 100644 --- a/tests/test_replykeyboardmarkup.py +++ b/tests/test_replykeyboardmarkup.py @@ -56,6 +56,11 @@ class ReplyKeyboardMarkupTest(BaseTest, unittest.TestCase): self.assertEqual(message.text, u'Моё судно на воздушной подушке полно угрей') + def test_reply_markup_empty_de_json_empty(self): + reply_markup_empty = telegram.ReplyKeyboardMarkup.de_json(None) + + self.assertFalse(reply_markup_empty) + def test_reply_keyboard_markup_de_json(self): reply_keyboard_markup = telegram.ReplyKeyboardMarkup.de_json( self.json_dict) diff --git a/tests/test_replymarkup.py b/tests/test_replymarkup.py new file mode 100644 index 000000000..b24b886ea --- /dev/null +++ b/tests/test_replymarkup.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python +# +# 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 +ReplyMarkup""" + +import sys + +if sys.version_info[0:2] == (2, 6): + import unittest2 as unittest +else: + import unittest + +sys.path.append('.') + +import telegram +from tests.base import BaseTest + + +class ReplyMarkupTest(BaseTest, unittest.TestCase): + """This object represents Tests for Telegram ReplyMarkup.""" + + def test_reply_markup_de_json_empty(self): + reply_markup = telegram.ReplyMarkup.de_json(None) + + self.assertFalse(reply_markup) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/test_update.py b/tests/test_update.py index ec6628cb5..fdc8f0d11 100644 --- a/tests/test_update.py +++ b/tests/test_update.py @@ -53,6 +53,11 @@ class UpdateTest(BaseTest, unittest.TestCase): self.assertEqual(update.update_id, self.update_id) self.assertTrue(isinstance(update.message, telegram.Message)) + def test_update_de_json_empty(self): + update = telegram.Update.de_json(None) + + self.assertFalse(update) + def test_update_to_json(self): update = telegram.Update.de_json(self.json_dict)