Add more test cases

This commit is contained in:
Leandro Toledo 2016-04-26 22:48:02 -03:00
parent 96d98084c7
commit d80e0b4b8c
8 changed files with 90 additions and 0 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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)

45
tests/test_replymarkup.py Normal file
View file

@ -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 <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
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()

View file

@ -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)