mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-03-16 12:25:45 +01:00
Merge branch 'unittest-bot2.0' of https://github.com/python-telegram-bot/python-telegram-bot into unittest-bot2.0
This commit is contained in:
commit
1f29093027
59 changed files with 2111 additions and 178 deletions
|
@ -1164,6 +1164,7 @@ class Bot(TelegramObject):
|
|||
return result
|
||||
|
||||
@log
|
||||
@message
|
||||
def editMessageText(self,
|
||||
text,
|
||||
chat_id=None,
|
||||
|
@ -1171,7 +1172,6 @@ class Bot(TelegramObject):
|
|||
inline_message_id=None,
|
||||
parse_mode=None,
|
||||
disable_web_page_preview=None,
|
||||
reply_markup=None,
|
||||
**kwargs):
|
||||
"""Use this method to edit text messages sent by the bot or via the bot
|
||||
(for inline bots).
|
||||
|
@ -1194,10 +1194,10 @@ class Bot(TelegramObject):
|
|||
italic, fixed-width text or inline URLs in your bot's message.
|
||||
disable_web_page_preview:
|
||||
Disables link previews for links in this message.
|
||||
reply_markup:
|
||||
A JSON-serialized object for an inline keyboard.
|
||||
|
||||
Keyword Args:
|
||||
reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]):
|
||||
A JSON-serialized object for an inline keyboard.
|
||||
timeout (Optional[float]): If this value is specified, use it as
|
||||
the definitive timeout (in seconds) for urlopen() operations.
|
||||
network_delay (Optional[float]): If using the timeout (which is
|
||||
|
@ -1229,17 +1229,8 @@ class Bot(TelegramObject):
|
|||
data['parse_mode'] = parse_mode
|
||||
if disable_web_page_preview:
|
||||
data['disable_web_page_preview'] = disable_web_page_preview
|
||||
if reply_markup:
|
||||
if isinstance(reply_markup, ReplyMarkup):
|
||||
data['reply_markup'] = reply_markup.to_json()
|
||||
else:
|
||||
data['reply_markup'] = reply_markup
|
||||
|
||||
result = request.post(url, data,
|
||||
timeout=kwargs.get('timeout'),
|
||||
network_delay=kwargs.get('network_delay'))
|
||||
|
||||
return Message.de_json(result)
|
||||
return url, data
|
||||
|
||||
@log
|
||||
@message
|
||||
|
|
|
@ -41,6 +41,8 @@ class InlineKeyboardMarkup(ReplyMarkup):
|
|||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
data = super(InlineKeyboardMarkup, InlineKeyboardMarkup).de_json(data)
|
||||
|
||||
if not data:
|
||||
return None
|
||||
|
||||
|
|
|
@ -25,6 +25,35 @@ from telegram import InlineQueryResult, InlineKeyboardMarkup, \
|
|||
|
||||
|
||||
class InlineQueryResultCachedAudio(InlineQueryResult):
|
||||
"""Represents a link to an mp3 audio file stored on the Telegram
|
||||
servers. By default, this audio file will be sent by the user.
|
||||
Alternatively, you can use input_message_content to send a message with
|
||||
the specified content instead of the audio.
|
||||
|
||||
Attributes:
|
||||
id (str):
|
||||
audio_file_id (str):
|
||||
reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]):
|
||||
input_message_content (Optional[
|
||||
:class:`telegram.input_message_content`]):
|
||||
|
||||
Deprecated: 4.0
|
||||
message_text (str): Use :class:`InputTextMessageContent` instead.
|
||||
|
||||
parse_mode (str): Use :class:`InputTextMessageContent` instead.
|
||||
|
||||
disable_web_page_preview (bool): Use :class:`InputTextMessageContent`
|
||||
instead.
|
||||
|
||||
Args:
|
||||
audio_file_id (str):
|
||||
**kwargs: Arbitrary keyword arguments.
|
||||
|
||||
Keyword Args:
|
||||
reply_markup (Optional[:class:`telegram.InlineKeyboardMarkup`]):
|
||||
input_message_content (Optional[
|
||||
:class:`telegram.input_message_content`]):
|
||||
"""
|
||||
def __init__(self,
|
||||
id,
|
||||
audio_file_id,
|
||||
|
|
|
@ -24,4 +24,18 @@ from telegram import InputMessageContent
|
|||
|
||||
|
||||
class InputContactMessageContent(InputMessageContent):
|
||||
pass
|
||||
"""Base class for Telegram InputContactMessageContent Objects"""
|
||||
|
||||
def __init__(self,
|
||||
phone_number,
|
||||
first_name,
|
||||
last_name=None):
|
||||
# Required
|
||||
self.phone_number = phone_number
|
||||
self.first_name = first_name
|
||||
# Optionals
|
||||
self.last_name = last_name
|
||||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
return InputContactMessageContent(**data)
|
||||
|
|
|
@ -35,7 +35,4 @@ class InputLocationMessageContent(InputMessageContent):
|
|||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
data = super(InputLocationMessageContent,
|
||||
InputLocationMessageContent).de_json(data)
|
||||
|
||||
return InputLocationMessageContent(**data)
|
||||
|
|
|
@ -28,4 +28,33 @@ class InputMessageContent(TelegramObject):
|
|||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
pass
|
||||
data = super(InputMessageContent, InputMessageContent).de_json(data)
|
||||
|
||||
if not data:
|
||||
return None
|
||||
|
||||
try:
|
||||
from telegram import InputTextMessageContent
|
||||
return InputTextMessageContent.de_json(data)
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
try:
|
||||
from telegram import InputLocationMessageContent
|
||||
return InputLocationMessageContent.de_json(data)
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
try:
|
||||
from telegram import InputVenueMessageContent
|
||||
return InputVenueMessageContent.de_json(data)
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
try:
|
||||
from telegram import InputContactMessageContent
|
||||
return InputContactMessageContent.de_json(data)
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
return None
|
||||
|
|
|
@ -38,7 +38,4 @@ class InputTextMessageContent(InputMessageContent):
|
|||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
data = super(InputTextMessageContent,
|
||||
InputTextMessageContent).de_json(data)
|
||||
|
||||
return InputTextMessageContent(**data)
|
||||
|
|
|
@ -42,7 +42,4 @@ class InputVenueMessageContent(InputMessageContent):
|
|||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
data = super(InputVenueMessageContent,
|
||||
InputVenueMessageContent).de_json(data)
|
||||
|
||||
return InputVenueMessageContent(**data)
|
||||
|
|
|
@ -27,4 +27,9 @@ class ReplyMarkup(TelegramObject):
|
|||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
pass
|
||||
data = super(ReplyMarkup, ReplyMarkup).de_json(data)
|
||||
|
||||
if not data:
|
||||
return None
|
||||
|
||||
return data
|
||||
|
|
|
@ -47,11 +47,11 @@ class Venue(TelegramObject):
|
|||
|
||||
@staticmethod
|
||||
def de_json(data):
|
||||
data = super(Venue, Venue).de_json(data)
|
||||
|
||||
if not data:
|
||||
return None
|
||||
|
||||
data = super(Venue, Venue).de_json(data)
|
||||
|
||||
data['location'] = Location.de_json(data.get('location'))
|
||||
|
||||
return Venue(**data)
|
||||
|
|
|
@ -19,11 +19,10 @@
|
|||
|
||||
"""This module contains a object that represents a Base class for tests"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import signal
|
||||
import traceback
|
||||
import sys
|
||||
|
||||
import os
|
||||
from nose.tools import make_decorator
|
||||
|
||||
sys.path.append('.')
|
||||
|
@ -38,7 +37,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
|
||||
|
@ -62,7 +62,6 @@ class BaseTest(object):
|
|||
|
||||
|
||||
class TestTimedOut(AssertionError):
|
||||
|
||||
def __init__(self, time_limit, frame):
|
||||
super(TestTimedOut, self).__init__('time_limit={0}'.format(time_limit))
|
||||
self.time_limit = time_limit
|
||||
|
|
|
@ -19,9 +19,10 @@
|
|||
|
||||
"""This module contains a object that represents Tests for Telegram Audio"""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import os
|
||||
from flaky import flaky
|
||||
|
||||
sys.path.append('.')
|
||||
|
@ -195,7 +196,7 @@ class AudioTest(BaseTest, unittest.TestCase):
|
|||
def test_error_send_audio_empty_file(self):
|
||||
json_dict = self.json_dict
|
||||
|
||||
del(json_dict['file_id'])
|
||||
del (json_dict['file_id'])
|
||||
json_dict['audio'] = open(os.devnull, 'rb')
|
||||
|
||||
self.assertRaises(telegram.TelegramError,
|
||||
|
@ -207,7 +208,7 @@ class AudioTest(BaseTest, unittest.TestCase):
|
|||
def test_error_send_audio_empty_file_id(self):
|
||||
json_dict = self.json_dict
|
||||
|
||||
del(json_dict['file_id'])
|
||||
del (json_dict['file_id'])
|
||||
json_dict['audio'] = ''
|
||||
|
||||
self.assertRaises(telegram.TelegramError,
|
||||
|
@ -219,12 +220,13 @@ class AudioTest(BaseTest, unittest.TestCase):
|
|||
def test_error_audio_without_required_args(self):
|
||||
json_dict = self.json_dict
|
||||
|
||||
del(json_dict['file_id'])
|
||||
del(json_dict['duration'])
|
||||
del (json_dict['file_id'])
|
||||
del (json_dict['duration'])
|
||||
|
||||
self.assertRaises(TypeError,
|
||||
lambda: self._bot.sendAudio(chat_id=self._chat_id,
|
||||
**json_dict))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -20,10 +20,10 @@
|
|||
|
||||
"""This module contains a object that represents Tests for Telegram Bot"""
|
||||
|
||||
import io
|
||||
import os
|
||||
from datetime import datetime
|
||||
import sys
|
||||
from datetime import datetime
|
||||
|
||||
import io
|
||||
from flaky import flaky
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
|
@ -59,7 +59,8 @@ class BotTest(BaseTest, unittest.TestCase):
|
|||
text='Моё судно на воздушной подушке полно угрей')
|
||||
|
||||
self.assertTrue(self.is_json(message.to_json()))
|
||||
self.assertEqual(message.text, u'Моё судно на воздушной подушке полно угрей')
|
||||
self.assertEqual(message.text,
|
||||
u'Моё судно на воздушной подушке полно угрей')
|
||||
self.assertTrue(isinstance(message.date, datetime))
|
||||
|
||||
@flaky(3, 1)
|
||||
|
@ -70,7 +71,8 @@ class BotTest(BaseTest, unittest.TestCase):
|
|||
disable_notification=True)
|
||||
|
||||
self.assertTrue(self.is_json(message.to_json()))
|
||||
self.assertEqual(message.text, u'Моё судно на воздушной подушке полно угрей')
|
||||
self.assertEqual(message.text,
|
||||
u'Моё судно на воздушной подушке полно угрей')
|
||||
self.assertTrue(isinstance(message.date, datetime))
|
||||
|
||||
@flaky(3, 1)
|
||||
|
@ -97,9 +99,10 @@ class BotTest(BaseTest, unittest.TestCase):
|
|||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
def testSendPhoto(self):
|
||||
message = self._bot.sendPhoto(photo=open('tests/data/telegram.png', 'rb'),
|
||||
caption='testSendPhoto',
|
||||
chat_id=self._chat_id)
|
||||
message = self._bot.sendPhoto(
|
||||
photo=open('tests/data/telegram.png', 'rb'),
|
||||
caption='testSendPhoto',
|
||||
chat_id=self._chat_id)
|
||||
|
||||
self.assertTrue(self.is_json(message.to_json()))
|
||||
self.assertEqual(message.photo[0].file_size, 1451)
|
||||
|
@ -108,10 +111,11 @@ class BotTest(BaseTest, unittest.TestCase):
|
|||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
def testSilentSendPhoto(self):
|
||||
message = self._bot.sendPhoto(photo=open('tests/data/telegram.png', 'rb'),
|
||||
caption='testSendPhoto',
|
||||
chat_id=self._chat_id,
|
||||
disable_notification=True)
|
||||
message = self._bot.sendPhoto(
|
||||
photo=open('tests/data/telegram.png', 'rb'),
|
||||
caption='testSendPhoto',
|
||||
chat_id=self._chat_id,
|
||||
disable_notification=True)
|
||||
|
||||
self.assertTrue(self.is_json(message.to_json()))
|
||||
self.assertEqual(message.photo[0].file_size, 1451)
|
||||
|
@ -120,17 +124,20 @@ class BotTest(BaseTest, unittest.TestCase):
|
|||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
def testResendPhoto(self):
|
||||
message = self._bot.sendPhoto(photo='AgADAQADyKcxGx8j9Qdp6d-gpUsw4Gja1i8ABEVJsVqQk8LfJ3wAAgI',
|
||||
chat_id=self._chat_id)
|
||||
message = self._bot.sendPhoto(
|
||||
photo='AgADAQADyKcxGx8j9Qdp6d-gpUsw4Gja1i8ABEVJsVqQk8LfJ3wAAgI',
|
||||
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)
|
||||
def testSendJPGURLPhoto(self):
|
||||
message = self._bot.sendPhoto(photo='http://dummyimage.com/600x400/000/fff.jpg&text=telegram',
|
||||
chat_id=self._chat_id)
|
||||
message = self._bot.sendPhoto(
|
||||
photo='http://dummyimage.com/600x400/000/fff.jpg&text=telegram',
|
||||
chat_id=self._chat_id)
|
||||
|
||||
self.assertTrue(self.is_json(message.to_json()))
|
||||
self.assertEqual(message.photo[0].file_size, 822)
|
||||
|
@ -138,8 +145,9 @@ class BotTest(BaseTest, unittest.TestCase):
|
|||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
def testSendPNGURLPhoto(self):
|
||||
message = self._bot.sendPhoto(photo='http://dummyimage.com/600x400/000/fff.png&text=telegram',
|
||||
chat_id=self._chat_id)
|
||||
message = self._bot.sendPhoto(
|
||||
photo='http://dummyimage.com/600x400/000/fff.png&text=telegram',
|
||||
chat_id=self._chat_id)
|
||||
|
||||
self.assertTrue(self.is_json(message.to_json()))
|
||||
self.assertEqual(message.photo[0].file_size, 684)
|
||||
|
@ -147,8 +155,9 @@ class BotTest(BaseTest, unittest.TestCase):
|
|||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
def testSendGIFURLPhoto(self):
|
||||
message = self._bot.sendPhoto(photo='http://dummyimage.com/600x400/000/fff.gif&text=telegram',
|
||||
chat_id=self._chat_id)
|
||||
message = self._bot.sendPhoto(
|
||||
photo='http://dummyimage.com/600x400/000/fff.gif&text=telegram',
|
||||
chat_id=self._chat_id)
|
||||
|
||||
self.assertTrue(self.is_json(message.to_json()))
|
||||
self.assertEqual(message.photo[0].file_size, 684)
|
||||
|
@ -179,7 +188,8 @@ class BotTest(BaseTest, unittest.TestCase):
|
|||
self.assertEqual(upf.photos[0][0].file_size, 12421)
|
||||
|
||||
def _test_invalid_token(self, token):
|
||||
self.assertRaisesRegexp(telegram.error.InvalidToken, 'Invalid token', telegram.Bot, token)
|
||||
self.assertRaisesRegexp(telegram.error.InvalidToken, 'Invalid token',
|
||||
telegram.Bot, token)
|
||||
|
||||
def testInvalidToken1(self):
|
||||
self._test_invalid_token('123')
|
||||
|
@ -191,12 +201,14 @@ class BotTest(BaseTest, unittest.TestCase):
|
|||
self._test_invalid_token('12:')
|
||||
|
||||
def testUnauthToken(self):
|
||||
with self.assertRaisesRegexp(telegram.error.Unauthorized, 'Unauthorized'):
|
||||
with self.assertRaisesRegexp(telegram.error.Unauthorized,
|
||||
'Unauthorized'):
|
||||
bot = telegram.Bot('1234:abcd1234')
|
||||
bot.getMe()
|
||||
|
||||
def testInvalidSrvResp(self):
|
||||
with self.assertRaisesRegexp(telegram.TelegramError, 'Invalid server response'):
|
||||
with self.assertRaisesRegexp(telegram.TelegramError,
|
||||
'Invalid server response'):
|
||||
# bypass the valid token check
|
||||
bot = telegram.Bot.__new__(telegram.Bot)
|
||||
bot.base_url = 'https://api.telegram.org/bot{0}'.format('12')
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
|
||||
"""This module contains a object that represents Tests for Botan analytics integration"""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import os
|
||||
from flaky import flaky
|
||||
|
||||
sys.path.append('.')
|
||||
|
@ -56,5 +57,6 @@ class BotanTest(BaseTest, unittest.TestCase):
|
|||
result = botan.track(message, 'named event')
|
||||
self.assertFalse(result)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
# !/usr/bin/env python
|
||||
#
|
||||
# A library that provides a Python interface to the Telegram Bot API
|
||||
# Copyright (C) 2015-2016
|
||||
|
@ -19,9 +19,9 @@
|
|||
|
||||
"""This module contains a object that represents Tests for Telegram Chat"""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
import telegram
|
||||
|
@ -67,5 +67,6 @@ class ChatTest(BaseTest, unittest.TestCase):
|
|||
self.assertEqual(group_chat['title'], self.title)
|
||||
self.assertEqual(group_chat['type'], self.type)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -37,7 +37,6 @@ class ChosenInlineResultTest(BaseTest, unittest.TestCase):
|
|||
"""This object represents Tests for Telegram ChosenInlineResult."""
|
||||
|
||||
def setUp(self):
|
||||
|
||||
user = telegram.User(1, 'First name')
|
||||
|
||||
self.result_id = 'result id'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
# !/usr/bin/env python
|
||||
#
|
||||
# A library that provides a Python interface to the Telegram Bot API
|
||||
# Copyright (C) 2015-2016
|
||||
|
@ -19,9 +19,9 @@
|
|||
|
||||
"""This module contains a object that represents Tests for Telegram Contact"""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
import telegram
|
||||
|
@ -66,5 +66,6 @@ class ContactTest(BaseTest, unittest.TestCase):
|
|||
self.assertEqual(contact['last_name'], self.last_name)
|
||||
self.assertEqual(contact['user_id'], self.user_id)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -19,9 +19,10 @@
|
|||
|
||||
"""This module contains a object that represents Tests for Telegram Document"""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import os
|
||||
from flaky import flaky
|
||||
|
||||
sys.path.append('.')
|
||||
|
@ -141,7 +142,7 @@ class DocumentTest(BaseTest, unittest.TestCase):
|
|||
def test_error_send_document_empty_file(self):
|
||||
json_dict = self.json_dict
|
||||
|
||||
del(json_dict['file_id'])
|
||||
del (json_dict['file_id'])
|
||||
json_dict['document'] = open(os.devnull, 'rb')
|
||||
|
||||
self.assertRaises(telegram.TelegramError,
|
||||
|
@ -153,7 +154,7 @@ class DocumentTest(BaseTest, unittest.TestCase):
|
|||
def test_error_send_document_empty_file_id(self):
|
||||
json_dict = self.json_dict
|
||||
|
||||
del(json_dict['file_id'])
|
||||
del (json_dict['file_id'])
|
||||
json_dict['document'] = ''
|
||||
|
||||
self.assertRaises(telegram.TelegramError,
|
||||
|
@ -165,11 +166,12 @@ class DocumentTest(BaseTest, unittest.TestCase):
|
|||
def test_error_document_without_required_args(self):
|
||||
json_dict = self.json_dict
|
||||
|
||||
del(json_dict['file_id'])
|
||||
del (json_dict['file_id'])
|
||||
|
||||
self.assertRaises(TypeError,
|
||||
lambda: self._bot.sendDocument(chat_id=self._chat_id,
|
||||
**json_dict))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -19,12 +19,11 @@
|
|||
|
||||
"""This module contains a object that represents Tests for Telegram Emoji"""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
import telegram
|
||||
from telegram.emoji import Emoji
|
||||
from tests.base import BaseTest
|
||||
|
||||
|
|
|
@ -19,9 +19,11 @@
|
|||
|
||||
"""This module contains a object that represents Tests for Telegram File"""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import os
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
import telegram
|
||||
|
@ -38,7 +40,6 @@ class FileTest(BaseTest, unittest.TestCase):
|
|||
self.video_file_id = 'BAADAQADXwADHyP1BwJFTcmY2RYCAg'
|
||||
self.voice_file_id = 'AwADAQADTgADHyP1B_mbw34svXPHAg'
|
||||
|
||||
|
||||
self.json_dict = {
|
||||
'file_id': self.audio_file_id,
|
||||
'file_path': 'https://api.telegram.org/file/bot133505823:AAHZFMHno3mzVLErU5b5jJvaeG--qUyLyG0/document/file_3',
|
||||
|
@ -123,8 +124,8 @@ class FileTest(BaseTest, unittest.TestCase):
|
|||
def test_error_get_empty_file_id(self):
|
||||
json_dict = self.json_dict
|
||||
json_dict['file_id'] = ''
|
||||
del(json_dict['file_path'])
|
||||
del(json_dict['file_size'])
|
||||
del (json_dict['file_path'])
|
||||
del (json_dict['file_size'])
|
||||
|
||||
self.assertRaises(telegram.TelegramError,
|
||||
lambda: self._bot.getFile(**json_dict))
|
||||
|
@ -132,12 +133,13 @@ class FileTest(BaseTest, unittest.TestCase):
|
|||
def test_error_file_without_required_args(self):
|
||||
json_dict = self.json_dict
|
||||
|
||||
del(json_dict['file_id'])
|
||||
del(json_dict['file_path'])
|
||||
del(json_dict['file_size'])
|
||||
del (json_dict['file_id'])
|
||||
del (json_dict['file_path'])
|
||||
del (json_dict['file_size'])
|
||||
|
||||
self.assertRaises(TypeError,
|
||||
lambda: self._bot.getFile(**json_dict))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -20,8 +20,9 @@
|
|||
|
||||
"""This module contains a object that represents Tests for Telegram ForceReply"""
|
||||
|
||||
import unittest
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
import telegram
|
||||
|
@ -39,31 +40,34 @@ class ForceReplyTest(BaseTest, unittest.TestCase):
|
|||
'force_reply': self.force_reply,
|
||||
'selective': self.selective,
|
||||
}
|
||||
|
||||
|
||||
def test_send_message_with_force_reply(self):
|
||||
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.assertEqual(message.text, u'Моё судно на воздушной подушке полно угрей')
|
||||
self.assertEqual(message.text,
|
||||
u'Моё судно на воздушной подушке полно угрей')
|
||||
|
||||
def test_force_reply_de_json(self):
|
||||
force_reply = telegram.ForceReply.de_json(self.json_dict)
|
||||
|
||||
self.assertEqual(force_reply.force_reply, self.force_reply)
|
||||
self.assertEqual(force_reply.selective, self.selective)
|
||||
|
||||
|
||||
def test_force_reply_to_json(self):
|
||||
force_reply = telegram.ForceReply.de_json(self.json_dict)
|
||||
|
||||
self.assertTrue(self.is_json(force_reply.to_json()))
|
||||
|
||||
|
||||
def test_force_reply_to_dict(self):
|
||||
force_reply = telegram.ForceReply.de_json(self.json_dict)
|
||||
|
||||
self.assertEqual(force_reply['force_reply'], self.force_reply)
|
||||
self.assertEqual(force_reply['selective'], self.selective)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
81
tests/test_inlinekeyboardmarkup.py
Normal file
81
tests/test_inlinekeyboardmarkup.py
Normal file
|
@ -0,0 +1,81 @@
|
|||
#!/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 InlineKeyboardMarkup"""
|
||||
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
import telegram
|
||||
from tests.base import BaseTest
|
||||
|
||||
|
||||
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.json_dict = {
|
||||
'inline_keyboard': [[self.inline_keyboard[0][0].to_dict(),
|
||||
self.inline_keyboard[0][1].to_dict()]],
|
||||
}
|
||||
|
||||
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))
|
||||
|
||||
self.assertTrue(self.is_json(message.to_json()))
|
||||
self.assertEqual(message.text, 'Testing InlineKeyboardMarkup')
|
||||
|
||||
def test_inline_keyboard_markup_de_json(self):
|
||||
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))
|
||||
|
||||
def test_inline_keyboard_markup_to_json(self):
|
||||
inline_keyboard_markup = telegram.InlineKeyboardMarkup.de_json(
|
||||
self.json_dict)
|
||||
|
||||
self.assertTrue(self.is_json(inline_keyboard_markup.to_json()))
|
||||
|
||||
def test_inline_keyboard_markup_to_dict(self):
|
||||
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))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
|
@ -37,7 +37,6 @@ class InlineQueryTest(BaseTest, unittest.TestCase):
|
|||
"""This object represents Tests for Telegram InlineQuery."""
|
||||
|
||||
def setUp(self):
|
||||
|
||||
user = telegram.User(1, 'First name')
|
||||
|
||||
self.id = 'id'
|
||||
|
|
|
@ -40,6 +40,10 @@ class InlineQueryResultArticleTest(BaseTest, unittest.TestCase):
|
|||
self.id = 'id'
|
||||
self.type = 'article'
|
||||
self.title = 'title'
|
||||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
self.url = 'url'
|
||||
self.hide_url = True
|
||||
self.description = 'description'
|
||||
|
@ -51,6 +55,8 @@ class InlineQueryResultArticleTest(BaseTest, unittest.TestCase):
|
|||
'type': self.type,
|
||||
'id': self.id,
|
||||
'title': self.title,
|
||||
'input_message_content': self.input_message_content.to_dict(),
|
||||
'reply_markup': self.reply_markup.to_dict(),
|
||||
'url': self.url,
|
||||
'hide_url': self.hide_url,
|
||||
'description': self.description,
|
||||
|
@ -65,6 +71,10 @@ class InlineQueryResultArticleTest(BaseTest, unittest.TestCase):
|
|||
self.assertEqual(article.type, self.type)
|
||||
self.assertEqual(article.id, self.id)
|
||||
self.assertEqual(article.title, self.title)
|
||||
self.assertDictEqual(article.input_message_content.to_dict(),
|
||||
self.input_message_content.to_dict())
|
||||
self.assertDictEqual(article.reply_markup.to_dict(),
|
||||
self.reply_markup.to_dict())
|
||||
self.assertEqual(article.url, self.url)
|
||||
self.assertEqual(article.hide_url, self.hide_url)
|
||||
self.assertEqual(article.description, self.description)
|
||||
|
|
90
tests/test_inlinequeryresultaudio.py
Normal file
90
tests/test_inlinequeryresultaudio.py
Normal file
|
@ -0,0 +1,90 @@
|
|||
#!/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
|
||||
InlineQueryResultAudio"""
|
||||
|
||||
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 InlineQueryResultAudioTest(BaseTest, unittest.TestCase):
|
||||
"""This object represents Tests for Telegram InlineQueryResultAudio."""
|
||||
|
||||
def setUp(self):
|
||||
self.id = 'id'
|
||||
self.type = 'audio'
|
||||
self.audio_url = 'audio url'
|
||||
self.title = 'title'
|
||||
self.performer = 'performer'
|
||||
self.audio_duration = 'audio_duration'
|
||||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
|
||||
self.json_dict = {
|
||||
'type': self.type,
|
||||
'id': self.id,
|
||||
'audio_url': self.audio_url,
|
||||
'title': self.title,
|
||||
'performer': self.performer,
|
||||
'audio_duration': self.audio_duration,
|
||||
'input_message_content': self.input_message_content.to_dict(),
|
||||
'reply_markup': self.reply_markup.to_dict(),
|
||||
}
|
||||
|
||||
def test_audio_de_json(self):
|
||||
audio = telegram.InlineQueryResultAudio.de_json(self.json_dict)
|
||||
|
||||
self.assertEqual(audio.type, self.type)
|
||||
self.assertEqual(audio.id, self.id)
|
||||
self.assertEqual(audio.audio_url, self.audio_url)
|
||||
self.assertEqual(audio.title, self.title)
|
||||
self.assertEqual(audio.performer, self.performer)
|
||||
self.assertEqual(audio.audio_duration, self.audio_duration)
|
||||
self.assertDictEqual(audio.input_message_content.to_dict(),
|
||||
self.input_message_content.to_dict())
|
||||
self.assertDictEqual(audio.reply_markup.to_dict(),
|
||||
self.reply_markup.to_dict())
|
||||
|
||||
def test_audio_to_json(self):
|
||||
audio = telegram.InlineQueryResultAudio.de_json(self.json_dict)
|
||||
|
||||
self.assertTrue(self.is_json(audio.to_json()))
|
||||
|
||||
def test_audio_to_dict(self):
|
||||
audio = \
|
||||
telegram.InlineQueryResultAudio.de_json(self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(audio))
|
||||
self.assertDictEqual(self.json_dict, audio)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
83
tests/test_inlinequeryresultcachedaudio.py
Normal file
83
tests/test_inlinequeryresultcachedaudio.py
Normal file
|
@ -0,0 +1,83 @@
|
|||
#!/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
|
||||
InlineQueryResultCachedAudio"""
|
||||
|
||||
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 InlineQueryResultCachedAudioTest(BaseTest, unittest.TestCase):
|
||||
"""This object represents Tests for Telegram
|
||||
InlineQueryResultCachedAudio."""
|
||||
|
||||
def setUp(self):
|
||||
self.id = 'id'
|
||||
self.type = 'audio'
|
||||
self.audio_file_id = 'audio file id'
|
||||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
|
||||
self.json_dict = {
|
||||
'type': self.type,
|
||||
'id': self.id,
|
||||
'audio_file_id': self.audio_file_id,
|
||||
'input_message_content': self.input_message_content.to_dict(),
|
||||
'reply_markup': self.reply_markup.to_dict(),
|
||||
}
|
||||
|
||||
def test_audio_de_json(self):
|
||||
audio = telegram.InlineQueryResultCachedAudio.de_json(self.json_dict)
|
||||
|
||||
self.assertEqual(audio.type, self.type)
|
||||
self.assertEqual(audio.id, self.id)
|
||||
self.assertEqual(audio.audio_file_id, self.audio_file_id)
|
||||
self.assertDictEqual(audio.input_message_content.to_dict(),
|
||||
self.input_message_content.to_dict())
|
||||
self.assertDictEqual(audio.reply_markup.to_dict(),
|
||||
self.reply_markup.to_dict())
|
||||
|
||||
def test_audio_to_json(self):
|
||||
audio = telegram.InlineQueryResultCachedAudio.de_json(self.json_dict)
|
||||
|
||||
self.assertTrue(self.is_json(audio.to_json()))
|
||||
|
||||
def test_audio_to_dict(self):
|
||||
audio = \
|
||||
telegram.InlineQueryResultCachedAudio.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(audio))
|
||||
self.assertDictEqual(self.json_dict, audio)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
93
tests/test_inlinequeryresultcacheddocument.py
Normal file
93
tests/test_inlinequeryresultcacheddocument.py
Normal file
|
@ -0,0 +1,93 @@
|
|||
#!/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
|
||||
InlineQueryResultCachedDocument"""
|
||||
|
||||
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 InlineQueryResultCachedDocumentTest(BaseTest, unittest.TestCase):
|
||||
"""This object represents Tests for Telegram
|
||||
InlineQueryResultCachedDocument."""
|
||||
|
||||
def setUp(self):
|
||||
self.id = 'id'
|
||||
self.type = 'document'
|
||||
self.document_file_id = 'document file id'
|
||||
self.title = 'title'
|
||||
self.caption = 'caption'
|
||||
self.description = 'description'
|
||||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
self.json_dict = {
|
||||
'id': self.id,
|
||||
'type': self.type,
|
||||
'document_file_id': self.document_file_id,
|
||||
'title': self.title,
|
||||
'caption': self.caption,
|
||||
'description': self.description,
|
||||
'input_message_content': self.input_message_content.to_dict(),
|
||||
'reply_markup': self.reply_markup.to_dict(),
|
||||
}
|
||||
|
||||
def test_document_de_json(self):
|
||||
document = telegram.InlineQueryResultCachedDocument.de_json(
|
||||
self.json_dict)
|
||||
|
||||
self.assertEqual(document.id, self.id)
|
||||
self.assertEqual(document.type, self.type)
|
||||
self.assertEqual(document.document_file_id, self.document_file_id)
|
||||
self.assertEqual(document.title, self.title)
|
||||
self.assertEqual(document.caption, self.caption)
|
||||
self.assertEqual(document.description, self.description)
|
||||
self.assertDictEqual(document.input_message_content.to_dict(),
|
||||
self.input_message_content.to_dict())
|
||||
self.assertDictEqual(document.reply_markup.to_dict(),
|
||||
self.reply_markup.to_dict())
|
||||
|
||||
def test_document_to_json(self):
|
||||
document = telegram.InlineQueryResultCachedDocument.de_json(
|
||||
self.json_dict)
|
||||
|
||||
self.assertTrue(self.is_json(document.to_json()))
|
||||
|
||||
def test_document_to_dict(self):
|
||||
document = \
|
||||
telegram.InlineQueryResultCachedDocument.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(document))
|
||||
self.assertDictEqual(self.json_dict, document)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
87
tests/test_inlinequeryresultcachedgif.py
Normal file
87
tests/test_inlinequeryresultcachedgif.py
Normal file
|
@ -0,0 +1,87 @@
|
|||
#!/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
|
||||
InlineQueryResultCachedGif"""
|
||||
|
||||
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 InlineQueryResultCachedGifTest(BaseTest, unittest.TestCase):
|
||||
"""This object represents Tests for Telegram InlineQueryResultCachedGif."""
|
||||
|
||||
def setUp(self):
|
||||
self.id = 'id'
|
||||
self.type = 'gif'
|
||||
self.gif_file_id = 'gif file id'
|
||||
self.title = 'title'
|
||||
self.caption = 'caption'
|
||||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
|
||||
self.json_dict = {
|
||||
'type': self.type,
|
||||
'id': self.id,
|
||||
'gif_file_id': self.gif_file_id,
|
||||
'title': self.title,
|
||||
'caption': self.caption,
|
||||
'input_message_content': self.input_message_content.to_dict(),
|
||||
'reply_markup': self.reply_markup.to_dict(),
|
||||
}
|
||||
|
||||
def test_gif_de_json(self):
|
||||
gif = telegram.InlineQueryResultCachedGif.de_json(self.json_dict)
|
||||
|
||||
self.assertEqual(gif.type, self.type)
|
||||
self.assertEqual(gif.id, self.id)
|
||||
self.assertEqual(gif.gif_file_id, self.gif_file_id)
|
||||
self.assertEqual(gif.title, self.title)
|
||||
self.assertEqual(gif.caption, self.caption)
|
||||
self.assertDictEqual(gif.input_message_content.to_dict(),
|
||||
self.input_message_content.to_dict())
|
||||
self.assertDictEqual(gif.reply_markup.to_dict(),
|
||||
self.reply_markup.to_dict())
|
||||
|
||||
def test_gif_to_json(self):
|
||||
gif = telegram.InlineQueryResultCachedGif.de_json(self.json_dict)
|
||||
|
||||
self.assertTrue(self.is_json(gif.to_json()))
|
||||
|
||||
def test_gif_to_dict(self):
|
||||
gif = telegram.InlineQueryResultCachedGif.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(gif))
|
||||
self.assertDictEqual(self.json_dict, gif)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
91
tests/test_inlinequeryresultcachedmpeg4gif.py
Normal file
91
tests/test_inlinequeryresultcachedmpeg4gif.py
Normal file
|
@ -0,0 +1,91 @@
|
|||
#!/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
|
||||
InlineQueryResultCachedMpeg4Gif"""
|
||||
|
||||
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 InlineQueryResultCachedMpeg4GifTest(BaseTest, unittest.TestCase):
|
||||
"""This object represents Tests for Telegram
|
||||
InlineQueryResultCachedMpeg4Gif."""
|
||||
|
||||
def setUp(self):
|
||||
self.id = 'id'
|
||||
self.type = 'mpeg4_gif'
|
||||
self.mpeg4_file_id = 'mpeg4 file id'
|
||||
self.title = 'title'
|
||||
self.caption = 'caption'
|
||||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
|
||||
self.json_dict = {
|
||||
'type': self.type,
|
||||
'id': self.id,
|
||||
'mpeg4_file_id': self.mpeg4_file_id,
|
||||
'title': self.title,
|
||||
'caption': self.caption,
|
||||
'input_message_content': self.input_message_content.to_dict(),
|
||||
'reply_markup': self.reply_markup.to_dict(),
|
||||
}
|
||||
|
||||
def test_mpeg4_de_json(self):
|
||||
mpeg4 = telegram.InlineQueryResultCachedMpeg4Gif.de_json(
|
||||
self.json_dict)
|
||||
|
||||
self.assertEqual(mpeg4.type, self.type)
|
||||
self.assertEqual(mpeg4.id, self.id)
|
||||
self.assertEqual(mpeg4.mpeg4_file_id, self.mpeg4_file_id)
|
||||
self.assertEqual(mpeg4.title, self.title)
|
||||
self.assertEqual(mpeg4.caption, self.caption)
|
||||
self.assertDictEqual(mpeg4.input_message_content.to_dict(),
|
||||
self.input_message_content.to_dict())
|
||||
self.assertDictEqual(mpeg4.reply_markup.to_dict(),
|
||||
self.reply_markup.to_dict())
|
||||
|
||||
def test_mpeg4_to_json(self):
|
||||
mpeg4 = telegram.InlineQueryResultCachedMpeg4Gif.de_json(
|
||||
self.json_dict)
|
||||
|
||||
self.assertTrue(self.is_json(mpeg4.to_json()))
|
||||
|
||||
def test_mpeg4_to_dict(self):
|
||||
mpeg4 = \
|
||||
telegram.InlineQueryResultCachedMpeg4Gif.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(mpeg4))
|
||||
self.assertDictEqual(self.json_dict, mpeg4)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
92
tests/test_inlinequeryresultcachedphoto.py
Normal file
92
tests/test_inlinequeryresultcachedphoto.py
Normal file
|
@ -0,0 +1,92 @@
|
|||
#!/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
|
||||
InlineQueryResultCachedPhoto"""
|
||||
|
||||
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 InlineQueryResultCachedPhotoTest(BaseTest, unittest.TestCase):
|
||||
"""This object represents Tests for Telegram
|
||||
InlineQueryResultCachedPhoto."""
|
||||
|
||||
def setUp(self):
|
||||
self.id = 'id'
|
||||
self.type = 'photo'
|
||||
self.photo_file_id = 'photo file id'
|
||||
self.title = 'title'
|
||||
self.description = 'description'
|
||||
self.caption = 'caption'
|
||||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
|
||||
self.json_dict = {
|
||||
'type': self.type,
|
||||
'id': self.id,
|
||||
'photo_file_id': self.photo_file_id,
|
||||
'title': self.title,
|
||||
'description': self.description,
|
||||
'caption': self.caption,
|
||||
'input_message_content': self.input_message_content.to_dict(),
|
||||
'reply_markup': self.reply_markup.to_dict(),
|
||||
}
|
||||
|
||||
def test_photo_de_json(self):
|
||||
photo = telegram.InlineQueryResultCachedPhoto.de_json(self.json_dict)
|
||||
|
||||
self.assertEqual(photo.type, self.type)
|
||||
self.assertEqual(photo.id, self.id)
|
||||
self.assertEqual(photo.photo_file_id, self.photo_file_id)
|
||||
self.assertEqual(photo.title, self.title)
|
||||
self.assertEqual(photo.description, self.description)
|
||||
self.assertEqual(photo.caption, self.caption)
|
||||
self.assertDictEqual(photo.input_message_content.to_dict(),
|
||||
self.input_message_content.to_dict())
|
||||
self.assertDictEqual(photo.reply_markup.to_dict(),
|
||||
self.reply_markup.to_dict())
|
||||
|
||||
def test_photo_to_json(self):
|
||||
photo = telegram.InlineQueryResultCachedPhoto.de_json(self.json_dict)
|
||||
|
||||
self.assertTrue(self.is_json(photo.to_json()))
|
||||
|
||||
def test_photo_to_dict(self):
|
||||
photo = \
|
||||
telegram.InlineQueryResultCachedPhoto.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(photo))
|
||||
self.assertDictEqual(self.json_dict, photo)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
85
tests/test_inlinequeryresultcachedsticker.py
Normal file
85
tests/test_inlinequeryresultcachedsticker.py
Normal file
|
@ -0,0 +1,85 @@
|
|||
#!/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
|
||||
InlineQueryResultCachedSticker"""
|
||||
|
||||
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 InlineQueryResultCachedStickerTest(BaseTest, unittest.TestCase):
|
||||
"""This object represents Tests for Telegram
|
||||
InlineQueryResultCachedSticker."""
|
||||
|
||||
def setUp(self):
|
||||
self.id = 'id'
|
||||
self.type = 'sticker'
|
||||
self.sticker_file_id = 'sticker file id'
|
||||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
|
||||
self.json_dict = {
|
||||
'type': self.type,
|
||||
'id': self.id,
|
||||
'sticker_file_id': self.sticker_file_id,
|
||||
'input_message_content': self.input_message_content.to_dict(),
|
||||
'reply_markup': self.reply_markup.to_dict(),
|
||||
}
|
||||
|
||||
def test_sticker_de_json(self):
|
||||
sticker = telegram.InlineQueryResultCachedSticker.de_json(
|
||||
self.json_dict)
|
||||
|
||||
self.assertEqual(sticker.type, self.type)
|
||||
self.assertEqual(sticker.id, self.id)
|
||||
self.assertEqual(sticker.sticker_file_id, self.sticker_file_id)
|
||||
self.assertDictEqual(sticker.input_message_content.to_dict(),
|
||||
self.input_message_content.to_dict())
|
||||
self.assertDictEqual(sticker.reply_markup.to_dict(),
|
||||
self.reply_markup.to_dict())
|
||||
|
||||
def test_sticker_to_json(self):
|
||||
sticker = telegram.InlineQueryResultCachedSticker.de_json(
|
||||
self.json_dict)
|
||||
|
||||
self.assertTrue(self.is_json(sticker.to_json()))
|
||||
|
||||
def test_sticker_to_dict(self):
|
||||
sticker = \
|
||||
telegram.InlineQueryResultCachedSticker.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(sticker))
|
||||
self.assertDictEqual(self.json_dict, sticker)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
92
tests/test_inlinequeryresultcachedvideo.py
Normal file
92
tests/test_inlinequeryresultcachedvideo.py
Normal file
|
@ -0,0 +1,92 @@
|
|||
#!/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
|
||||
InlineQueryResultCachedVideo"""
|
||||
|
||||
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 InlineQueryResultCachedVideoTest(BaseTest, unittest.TestCase):
|
||||
"""This object represents Tests for Telegram
|
||||
InlineQueryResultCachedVideo."""
|
||||
|
||||
def setUp(self):
|
||||
self.id = 'id'
|
||||
self.type = 'video'
|
||||
self.video_file_id = 'video file id'
|
||||
self.title = 'title'
|
||||
self.caption = 'caption'
|
||||
self.description = 'description'
|
||||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
|
||||
self.json_dict = {
|
||||
'type': self.type,
|
||||
'id': self.id,
|
||||
'video_file_id': self.video_file_id,
|
||||
'title': self.title,
|
||||
'caption': self.caption,
|
||||
'description': self.description,
|
||||
'input_message_content': self.input_message_content.to_dict(),
|
||||
'reply_markup': self.reply_markup.to_dict(),
|
||||
}
|
||||
|
||||
def test_video_de_json(self):
|
||||
video = telegram.InlineQueryResultCachedVideo.de_json(self.json_dict)
|
||||
|
||||
self.assertEqual(video.type, self.type)
|
||||
self.assertEqual(video.id, self.id)
|
||||
self.assertEqual(video.video_file_id, self.video_file_id)
|
||||
self.assertEqual(video.title, self.title)
|
||||
self.assertEqual(video.description, self.description)
|
||||
self.assertEqual(video.caption, self.caption)
|
||||
self.assertDictEqual(video.input_message_content.to_dict(),
|
||||
self.input_message_content.to_dict())
|
||||
self.assertDictEqual(video.reply_markup.to_dict(),
|
||||
self.reply_markup.to_dict())
|
||||
|
||||
def test_video_to_json(self):
|
||||
video = telegram.InlineQueryResultCachedVideo.de_json(self.json_dict)
|
||||
|
||||
self.assertTrue(self.is_json(video.to_json()))
|
||||
|
||||
def test_video_to_dict(self):
|
||||
video = \
|
||||
telegram.InlineQueryResultCachedVideo.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(video))
|
||||
self.assertDictEqual(self.json_dict, video)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
89
tests/test_inlinequeryresultcachedvoice.py
Normal file
89
tests/test_inlinequeryresultcachedvoice.py
Normal file
|
@ -0,0 +1,89 @@
|
|||
#!/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
|
||||
InlineQueryResultCachedVoice"""
|
||||
|
||||
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 InlineQueryResultCachedVoiceTest(BaseTest, unittest.TestCase):
|
||||
"""This object represents Tests for Telegram
|
||||
InlineQueryResultCachedVoice."""
|
||||
|
||||
def setUp(self):
|
||||
self.id = 'id'
|
||||
self.type = 'voice'
|
||||
self.voice_file_id = 'voice file id'
|
||||
self.title = 'title'
|
||||
self.description = 'description'
|
||||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
|
||||
self.json_dict = {
|
||||
'type': self.type,
|
||||
'id': self.id,
|
||||
'voice_file_id': self.voice_file_id,
|
||||
'title': self.title,
|
||||
'description': self.description,
|
||||
'input_message_content': self.input_message_content.to_dict(),
|
||||
'reply_markup': self.reply_markup.to_dict(),
|
||||
}
|
||||
|
||||
def test_voice_de_json(self):
|
||||
voice = telegram.InlineQueryResultCachedVoice.de_json(self.json_dict)
|
||||
|
||||
self.assertEqual(voice.type, self.type)
|
||||
self.assertEqual(voice.id, self.id)
|
||||
self.assertEqual(voice.voice_file_id, self.voice_file_id)
|
||||
self.assertEqual(voice.title, self.title)
|
||||
self.assertEqual(voice.description, self.description)
|
||||
self.assertDictEqual(voice.input_message_content.to_dict(),
|
||||
self.input_message_content.to_dict())
|
||||
self.assertDictEqual(voice.reply_markup.to_dict(),
|
||||
self.reply_markup.to_dict())
|
||||
|
||||
def test_voice_to_json(self):
|
||||
voice = telegram.InlineQueryResultCachedVoice.de_json(self.json_dict)
|
||||
|
||||
self.assertTrue(self.is_json(voice.to_json()))
|
||||
|
||||
def test_voice_to_dict(self):
|
||||
voice = \
|
||||
telegram.InlineQueryResultCachedVoice.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(voice))
|
||||
self.assertDictEqual(self.json_dict, voice)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
96
tests/test_inlinequeryresultcontact.py
Normal file
96
tests/test_inlinequeryresultcontact.py
Normal file
|
@ -0,0 +1,96 @@
|
|||
#!/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
|
||||
InlineQueryResultContact"""
|
||||
|
||||
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 InlineQueryResultContactTest(BaseTest, unittest.TestCase):
|
||||
"""This object represents Tests for Telegram InlineQueryResultContact."""
|
||||
|
||||
def setUp(self):
|
||||
self.id = 'id'
|
||||
self.type = 'contact'
|
||||
self.phone_number = 'phone_number'
|
||||
self.first_name = 'first_name'
|
||||
self.last_name = 'last_name'
|
||||
self.thumb_url = 'thumb url'
|
||||
self.thumb_width = 10
|
||||
self.thumb_height = 15
|
||||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
self.json_dict = {
|
||||
'id': self.id,
|
||||
'type': self.type,
|
||||
'phone_number': self.phone_number,
|
||||
'first_name': self.first_name,
|
||||
'last_name': self.last_name,
|
||||
'thumb_url': self.thumb_url,
|
||||
'thumb_width': self.thumb_width,
|
||||
'thumb_height': self.thumb_height,
|
||||
'input_message_content': self.input_message_content.to_dict(),
|
||||
'reply_markup': self.reply_markup.to_dict(),
|
||||
}
|
||||
|
||||
def test_contact_de_json(self):
|
||||
contact = telegram.InlineQueryResultContact.de_json(self.json_dict)
|
||||
|
||||
self.assertEqual(contact.id, self.id)
|
||||
self.assertEqual(contact.type, self.type)
|
||||
self.assertEqual(contact.phone_number, self.phone_number)
|
||||
self.assertEqual(contact.first_name, self.first_name)
|
||||
self.assertEqual(contact.last_name, self.last_name)
|
||||
self.assertEqual(contact.thumb_url, self.thumb_url)
|
||||
self.assertEqual(contact.thumb_width, self.thumb_width)
|
||||
self.assertEqual(contact.thumb_height, self.thumb_height)
|
||||
self.assertDictEqual(contact.input_message_content.to_dict(),
|
||||
self.input_message_content.to_dict())
|
||||
self.assertDictEqual(contact.reply_markup.to_dict(),
|
||||
self.reply_markup.to_dict())
|
||||
|
||||
def test_contact_to_json(self):
|
||||
contact = telegram.InlineQueryResultContact.de_json(self.json_dict)
|
||||
|
||||
self.assertTrue(self.is_json(contact.to_json()))
|
||||
|
||||
def test_contact_to_dict(self):
|
||||
contact = \
|
||||
telegram.InlineQueryResultContact.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(contact))
|
||||
self.assertDictEqual(self.json_dict, contact)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
102
tests/test_inlinequeryresultdocument.py
Normal file
102
tests/test_inlinequeryresultdocument.py
Normal file
|
@ -0,0 +1,102 @@
|
|||
#!/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
|
||||
InlineQueryResultDocument"""
|
||||
|
||||
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 InlineQueryResultDocumentTest(BaseTest, unittest.TestCase):
|
||||
"""This object represents Tests for Telegram InlineQueryResultDocument."""
|
||||
|
||||
def setUp(self):
|
||||
self.id = 'id'
|
||||
self.type = 'document'
|
||||
self.document_url = 'document url'
|
||||
self.title = 'title'
|
||||
self.caption = 'caption'
|
||||
self.mime_type = 'mime type'
|
||||
self.description = 'description'
|
||||
self.thumb_url = 'thumb url'
|
||||
self.thumb_width = 10
|
||||
self.thumb_height = 15
|
||||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
self.json_dict = {
|
||||
'id': self.id,
|
||||
'type': self.type,
|
||||
'document_url': self.document_url,
|
||||
'title': self.title,
|
||||
'caption': self.caption,
|
||||
'mime_type': self.mime_type,
|
||||
'description': self.description,
|
||||
'thumb_url': self.thumb_url,
|
||||
'thumb_width': self.thumb_width,
|
||||
'thumb_height': self.thumb_height,
|
||||
'input_message_content': self.input_message_content.to_dict(),
|
||||
'reply_markup': self.reply_markup.to_dict(),
|
||||
}
|
||||
|
||||
def test_document_de_json(self):
|
||||
document = telegram.InlineQueryResultDocument.de_json(self.json_dict)
|
||||
|
||||
self.assertEqual(document.id, self.id)
|
||||
self.assertEqual(document.type, self.type)
|
||||
self.assertEqual(document.document_url, self.document_url)
|
||||
self.assertEqual(document.title, self.title)
|
||||
self.assertEqual(document.caption, self.caption)
|
||||
self.assertEqual(document.mime_type, self.mime_type)
|
||||
self.assertEqual(document.description, self.description)
|
||||
self.assertEqual(document.thumb_url, self.thumb_url)
|
||||
self.assertEqual(document.thumb_width, self.thumb_width)
|
||||
self.assertEqual(document.thumb_height, self.thumb_height)
|
||||
self.assertDictEqual(document.input_message_content.to_dict(),
|
||||
self.input_message_content.to_dict())
|
||||
self.assertDictEqual(document.reply_markup.to_dict(),
|
||||
self.reply_markup.to_dict())
|
||||
|
||||
def test_document_to_json(self):
|
||||
document = telegram.InlineQueryResultDocument.de_json(self.json_dict)
|
||||
|
||||
self.assertTrue(self.is_json(document.to_json()))
|
||||
|
||||
def test_document_to_dict(self):
|
||||
document = \
|
||||
telegram.InlineQueryResultDocument.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(document))
|
||||
self.assertDictEqual(self.json_dict, document)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
|
@ -45,6 +45,10 @@ class InlineQueryResultGifTest(BaseTest, unittest.TestCase):
|
|||
self.thumb_url = 'thumb url'
|
||||
self.title = 'title'
|
||||
self.caption = 'caption'
|
||||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
|
||||
self.json_dict = {
|
||||
'type': self.type,
|
||||
|
@ -55,6 +59,8 @@ class InlineQueryResultGifTest(BaseTest, unittest.TestCase):
|
|||
'thumb_url': self.thumb_url,
|
||||
'title': self.title,
|
||||
'caption': self.caption,
|
||||
'input_message_content': self.input_message_content.to_dict(),
|
||||
'reply_markup': self.reply_markup.to_dict(),
|
||||
}
|
||||
|
||||
def test_gif_de_json(self):
|
||||
|
@ -68,6 +74,10 @@ class InlineQueryResultGifTest(BaseTest, unittest.TestCase):
|
|||
self.assertEqual(gif.thumb_url, self.thumb_url)
|
||||
self.assertEqual(gif.title, self.title)
|
||||
self.assertEqual(gif.caption, self.caption)
|
||||
self.assertDictEqual(gif.input_message_content.to_dict(),
|
||||
self.input_message_content.to_dict())
|
||||
self.assertDictEqual(gif.reply_markup.to_dict(),
|
||||
self.reply_markup.to_dict())
|
||||
|
||||
def test_gif_to_json(self):
|
||||
gif = telegram.InlineQueryResultGif.de_json(self.json_dict)
|
||||
|
|
96
tests/test_inlinequeryresultlocation.py
Normal file
96
tests/test_inlinequeryresultlocation.py
Normal file
|
@ -0,0 +1,96 @@
|
|||
#!/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
|
||||
InlineQueryResultLocation"""
|
||||
|
||||
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 InlineQueryResultLocationTest(BaseTest, unittest.TestCase):
|
||||
"""This object represents Tests for Telegram InlineQueryResultLocation."""
|
||||
|
||||
def setUp(self):
|
||||
self.id = 'id'
|
||||
self.type = 'location'
|
||||
self.latitude = 'latitude'
|
||||
self.longitude = 'longitude'
|
||||
self.title = 'title'
|
||||
self.thumb_url = 'thumb url'
|
||||
self.thumb_width = 10
|
||||
self.thumb_height = 15
|
||||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
self.json_dict = {
|
||||
'id': self.id,
|
||||
'type': self.type,
|
||||
'latitude': self.latitude,
|
||||
'longitude': self.longitude,
|
||||
'title': self.title,
|
||||
'thumb_url': self.thumb_url,
|
||||
'thumb_width': self.thumb_width,
|
||||
'thumb_height': self.thumb_height,
|
||||
'input_message_content': self.input_message_content.to_dict(),
|
||||
'reply_markup': self.reply_markup.to_dict(),
|
||||
}
|
||||
|
||||
def test_location_de_json(self):
|
||||
location = telegram.InlineQueryResultLocation.de_json(self.json_dict)
|
||||
|
||||
self.assertEqual(location.id, self.id)
|
||||
self.assertEqual(location.type, self.type)
|
||||
self.assertEqual(location.latitude, self.latitude)
|
||||
self.assertEqual(location.longitude, self.longitude)
|
||||
self.assertEqual(location.title, self.title)
|
||||
self.assertEqual(location.thumb_url, self.thumb_url)
|
||||
self.assertEqual(location.thumb_width, self.thumb_width)
|
||||
self.assertEqual(location.thumb_height, self.thumb_height)
|
||||
self.assertDictEqual(location.input_message_content.to_dict(),
|
||||
self.input_message_content.to_dict())
|
||||
self.assertDictEqual(location.reply_markup.to_dict(),
|
||||
self.reply_markup.to_dict())
|
||||
|
||||
def test_location_to_json(self):
|
||||
location = telegram.InlineQueryResultLocation.de_json(self.json_dict)
|
||||
|
||||
self.assertTrue(self.is_json(location.to_json()))
|
||||
|
||||
def test_location_to_dict(self):
|
||||
location = \
|
||||
telegram.InlineQueryResultLocation.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(location))
|
||||
self.assertDictEqual(self.json_dict, location)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
|
@ -45,6 +45,10 @@ class InlineQueryResultMpeg4GifTest(BaseTest, unittest.TestCase):
|
|||
self.thumb_url = 'thumb url'
|
||||
self.title = 'title'
|
||||
self.caption = 'caption'
|
||||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
|
||||
self.json_dict = {
|
||||
'type': self.type,
|
||||
|
@ -55,6 +59,8 @@ class InlineQueryResultMpeg4GifTest(BaseTest, unittest.TestCase):
|
|||
'thumb_url': self.thumb_url,
|
||||
'title': self.title,
|
||||
'caption': self.caption,
|
||||
'input_message_content': self.input_message_content.to_dict(),
|
||||
'reply_markup': self.reply_markup.to_dict(),
|
||||
}
|
||||
|
||||
def test_mpeg4_de_json(self):
|
||||
|
@ -68,6 +74,10 @@ class InlineQueryResultMpeg4GifTest(BaseTest, unittest.TestCase):
|
|||
self.assertEqual(mpeg4.thumb_url, self.thumb_url)
|
||||
self.assertEqual(mpeg4.title, self.title)
|
||||
self.assertEqual(mpeg4.caption, self.caption)
|
||||
self.assertDictEqual(mpeg4.input_message_content.to_dict(),
|
||||
self.input_message_content.to_dict())
|
||||
self.assertDictEqual(mpeg4.reply_markup.to_dict(),
|
||||
self.reply_markup.to_dict())
|
||||
|
||||
def test_mpeg4_to_json(self):
|
||||
mpeg4 = telegram.InlineQueryResultMpeg4Gif.de_json(self.json_dict)
|
||||
|
@ -76,7 +86,8 @@ class InlineQueryResultMpeg4GifTest(BaseTest, unittest.TestCase):
|
|||
|
||||
def test_mpeg4_to_dict(self):
|
||||
mpeg4 = \
|
||||
telegram.InlineQueryResultMpeg4Gif.de_json(self.json_dict).to_dict()
|
||||
telegram.InlineQueryResultMpeg4Gif.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(mpeg4))
|
||||
self.assertDictEqual(self.json_dict, mpeg4)
|
||||
|
|
|
@ -44,7 +44,12 @@ class InlineQueryResultPhotoTest(BaseTest, unittest.TestCase):
|
|||
self.photo_height = 15
|
||||
self.thumb_url = 'thumb url'
|
||||
self.title = 'title'
|
||||
self.description = 'description'
|
||||
self.caption = 'caption'
|
||||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
|
||||
self.json_dict = {
|
||||
'type': self.type,
|
||||
|
@ -54,7 +59,10 @@ class InlineQueryResultPhotoTest(BaseTest, unittest.TestCase):
|
|||
'photo_height': self.photo_height,
|
||||
'thumb_url': self.thumb_url,
|
||||
'title': self.title,
|
||||
'description': self.description,
|
||||
'caption': self.caption,
|
||||
'input_message_content': self.input_message_content.to_dict(),
|
||||
'reply_markup': self.reply_markup.to_dict(),
|
||||
}
|
||||
|
||||
def test_photo_de_json(self):
|
||||
|
@ -67,7 +75,12 @@ class InlineQueryResultPhotoTest(BaseTest, unittest.TestCase):
|
|||
self.assertEqual(photo.photo_height, self.photo_height)
|
||||
self.assertEqual(photo.thumb_url, self.thumb_url)
|
||||
self.assertEqual(photo.title, self.title)
|
||||
self.assertEqual(photo.description, self.description)
|
||||
self.assertEqual(photo.caption, self.caption)
|
||||
self.assertDictEqual(photo.input_message_content.to_dict(),
|
||||
self.input_message_content.to_dict())
|
||||
self.assertDictEqual(photo.reply_markup.to_dict(),
|
||||
self.reply_markup.to_dict())
|
||||
|
||||
def test_photo_to_json(self):
|
||||
photo = telegram.InlineQueryResultPhoto.de_json(self.json_dict)
|
||||
|
|
101
tests/test_inlinequeryresultvenue.py
Normal file
101
tests/test_inlinequeryresultvenue.py
Normal file
|
@ -0,0 +1,101 @@
|
|||
#!/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
|
||||
InlineQueryResultVenue"""
|
||||
|
||||
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 InlineQueryResultVenueTest(BaseTest, unittest.TestCase):
|
||||
"""This object represents Tests for Telegram InlineQueryResultVenue."""
|
||||
|
||||
def setUp(self):
|
||||
self.id = 'id'
|
||||
self.type = 'venue'
|
||||
self.latitude = 'latitude'
|
||||
self.longitude = 'longitude'
|
||||
self.title = 'title'
|
||||
self._address = 'address' # nose binds self.address for testing
|
||||
self.foursquare_id = 'foursquare id'
|
||||
self.thumb_url = 'thumb url'
|
||||
self.thumb_width = 10
|
||||
self.thumb_height = 15
|
||||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
self.json_dict = {
|
||||
'id': self.id,
|
||||
'type': self.type,
|
||||
'latitude': self.latitude,
|
||||
'longitude': self.longitude,
|
||||
'title': self.title,
|
||||
'address': self._address,
|
||||
'foursquare_id': self.foursquare_id,
|
||||
'thumb_url': self.thumb_url,
|
||||
'thumb_width': self.thumb_width,
|
||||
'thumb_height': self.thumb_height,
|
||||
'input_message_content': self.input_message_content.to_dict(),
|
||||
'reply_markup': self.reply_markup.to_dict(),
|
||||
}
|
||||
|
||||
def test_venue_de_json(self):
|
||||
venue = telegram.InlineQueryResultVenue.de_json(self.json_dict)
|
||||
|
||||
self.assertEqual(venue.id, self.id)
|
||||
self.assertEqual(venue.type, self.type)
|
||||
self.assertEqual(venue.latitude, self.latitude)
|
||||
self.assertEqual(venue.longitude, self.longitude)
|
||||
self.assertEqual(venue.title, self.title)
|
||||
self.assertEqual(venue.address, self._address)
|
||||
self.assertEqual(venue.foursquare_id, self.foursquare_id)
|
||||
self.assertEqual(venue.thumb_url, self.thumb_url)
|
||||
self.assertEqual(venue.thumb_width, self.thumb_width)
|
||||
self.assertEqual(venue.thumb_height, self.thumb_height)
|
||||
self.assertDictEqual(venue.input_message_content.to_dict(),
|
||||
self.input_message_content.to_dict())
|
||||
self.assertDictEqual(venue.reply_markup.to_dict(),
|
||||
self.reply_markup.to_dict())
|
||||
|
||||
def test_venue_to_json(self):
|
||||
venue = telegram.InlineQueryResultVenue.de_json(self.json_dict)
|
||||
|
||||
self.assertTrue(self.is_json(venue.to_json()))
|
||||
|
||||
def test_venue_to_dict(self):
|
||||
venue = telegram.InlineQueryResultVenue.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(venue))
|
||||
self.assertDictEqual(self.json_dict, venue)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
|
@ -48,6 +48,10 @@ class InlineQueryResultVideoTest(BaseTest, unittest.TestCase):
|
|||
self.title = 'title'
|
||||
self.caption = 'caption'
|
||||
self.description = 'description'
|
||||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
|
||||
self.json_dict = {
|
||||
'type': self.type,
|
||||
|
@ -61,6 +65,8 @@ class InlineQueryResultVideoTest(BaseTest, unittest.TestCase):
|
|||
'title': self.title,
|
||||
'caption': self.caption,
|
||||
'description': self.description,
|
||||
'input_message_content': self.input_message_content.to_dict(),
|
||||
'reply_markup': self.reply_markup.to_dict(),
|
||||
}
|
||||
|
||||
def test_video_de_json(self):
|
||||
|
@ -77,6 +83,10 @@ class InlineQueryResultVideoTest(BaseTest, unittest.TestCase):
|
|||
self.assertEqual(video.title, self.title)
|
||||
self.assertEqual(video.description, self.description)
|
||||
self.assertEqual(video.caption, self.caption)
|
||||
self.assertDictEqual(video.input_message_content.to_dict(),
|
||||
self.input_message_content.to_dict())
|
||||
self.assertDictEqual(video.reply_markup.to_dict(),
|
||||
self.reply_markup.to_dict())
|
||||
|
||||
def test_video_to_json(self):
|
||||
video = telegram.InlineQueryResultVideo.de_json(self.json_dict)
|
||||
|
|
87
tests/test_inlinequeryresultvoice.py
Normal file
87
tests/test_inlinequeryresultvoice.py
Normal file
|
@ -0,0 +1,87 @@
|
|||
#!/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
|
||||
InlineQueryResultVoice"""
|
||||
|
||||
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 InlineQueryResultVoiceTest(BaseTest, unittest.TestCase):
|
||||
"""This object represents Tests for Telegram InlineQueryResultVoice."""
|
||||
|
||||
def setUp(self):
|
||||
self.id = 'id'
|
||||
self.type = 'voice'
|
||||
self.voice_url = 'voice url'
|
||||
self.title = 'title'
|
||||
self.voice_duration = 'voice_duration'
|
||||
self.input_message_content = telegram.InputTextMessageContent(
|
||||
'input_message_content')
|
||||
self.reply_markup = telegram.InlineKeyboardMarkup([[
|
||||
telegram.InlineKeyboardButton('reply_markup')]])
|
||||
|
||||
self.json_dict = {
|
||||
'type': self.type,
|
||||
'id': self.id,
|
||||
'voice_url': self.voice_url,
|
||||
'title': self.title,
|
||||
'voice_duration': self.voice_duration,
|
||||
'input_message_content': self.input_message_content.to_dict(),
|
||||
'reply_markup': self.reply_markup.to_dict(),
|
||||
}
|
||||
|
||||
def test_voice_de_json(self):
|
||||
voice = telegram.InlineQueryResultVoice.de_json(self.json_dict)
|
||||
|
||||
self.assertEqual(voice.type, self.type)
|
||||
self.assertEqual(voice.id, self.id)
|
||||
self.assertEqual(voice.voice_url, self.voice_url)
|
||||
self.assertEqual(voice.title, self.title)
|
||||
self.assertEqual(voice.voice_duration, self.voice_duration)
|
||||
self.assertDictEqual(voice.input_message_content.to_dict(),
|
||||
self.input_message_content.to_dict())
|
||||
self.assertDictEqual(voice.reply_markup.to_dict(),
|
||||
self.reply_markup.to_dict())
|
||||
|
||||
def test_voice_to_json(self):
|
||||
voice = telegram.InlineQueryResultVoice.de_json(self.json_dict)
|
||||
|
||||
self.assertTrue(self.is_json(voice.to_json()))
|
||||
|
||||
def test_voice_to_dict(self):
|
||||
voice = \
|
||||
telegram.InlineQueryResultVoice.de_json(self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(voice))
|
||||
self.assertDictEqual(self.json_dict, voice)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
86
tests/test_inputcontactmessagecontent.py
Normal file
86
tests/test_inputcontactmessagecontent.py
Normal file
|
@ -0,0 +1,86 @@
|
|||
#!/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
|
||||
InputContactMessageContent"""
|
||||
|
||||
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 InputContactMessageContentTest(BaseTest, unittest.TestCase):
|
||||
"""This object represents Tests for Telegram InputContactMessageContent."""
|
||||
|
||||
def setUp(self):
|
||||
self.phone_number = 'phone number'
|
||||
self.first_name = 'first name'
|
||||
self.last_name = 'last name'
|
||||
|
||||
self.json_dict = {
|
||||
'first_name': self.first_name,
|
||||
'phone_number': self.phone_number,
|
||||
'last_name': self.last_name,
|
||||
}
|
||||
|
||||
def test_icmc_de_json(self):
|
||||
icmc = telegram.InputContactMessageContent.de_json(self.json_dict)
|
||||
|
||||
self.assertEqual(icmc.first_name, self.first_name)
|
||||
self.assertEqual(icmc.phone_number, self.phone_number)
|
||||
self.assertEqual(icmc.last_name, self.last_name)
|
||||
|
||||
def test_icmc_de_json_factory(self):
|
||||
icmc = telegram.InputMessageContent.de_json(self.json_dict)
|
||||
|
||||
self.assertTrue(isinstance(icmc, telegram.InputContactMessageContent))
|
||||
|
||||
def test_icmc_de_json_factory_without_required_args(self):
|
||||
json_dict = self.json_dict
|
||||
|
||||
del (json_dict['phone_number'])
|
||||
del (json_dict['first_name'])
|
||||
|
||||
icmc = telegram.InputMessageContent.de_json(json_dict)
|
||||
|
||||
self.assertFalse(icmc)
|
||||
|
||||
def test_icmc_to_json(self):
|
||||
icmc = telegram.InputContactMessageContent.de_json(self.json_dict)
|
||||
|
||||
self.assertTrue(self.is_json(icmc.to_json()))
|
||||
|
||||
def test_icmc_to_dict(self):
|
||||
icmc = telegram.InputContactMessageContent.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(icmc))
|
||||
self.assertDictEqual(self.json_dict, icmc)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
84
tests/test_inputlocationmessagecontent.py
Normal file
84
tests/test_inputlocationmessagecontent.py
Normal file
|
@ -0,0 +1,84 @@
|
|||
#!/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
|
||||
InputLocationMessageContent"""
|
||||
|
||||
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 InputLocationMessageContentTest(BaseTest, unittest.TestCase):
|
||||
"""This object represents Tests for Telegram InputLocationMessageContent."""
|
||||
|
||||
def setUp(self):
|
||||
self.latitude = 1.
|
||||
self.longitude = 2.
|
||||
|
||||
self.json_dict = {
|
||||
'longitude': self.longitude,
|
||||
'latitude': self.latitude,
|
||||
}
|
||||
|
||||
def test_ilmc_de_json(self):
|
||||
ilmc = telegram.InputLocationMessageContent.de_json(self.json_dict)
|
||||
|
||||
self.assertEqual(ilmc.longitude, self.longitude)
|
||||
self.assertEqual(ilmc.latitude, self.latitude)
|
||||
|
||||
def test_ilmc_de_json_factory(self):
|
||||
ilmc = telegram.InputMessageContent.de_json(self.json_dict)
|
||||
|
||||
self.assertTrue(isinstance(ilmc, telegram.InputLocationMessageContent))
|
||||
|
||||
def test_ilmc_de_json_factory_without_required_args(self):
|
||||
json_dict = self.json_dict
|
||||
|
||||
del (json_dict['longitude'])
|
||||
# If none args are sent it will fall in a different condition
|
||||
# del (json_dict['latitude'])
|
||||
|
||||
ilmc = telegram.InputMessageContent.de_json(json_dict)
|
||||
|
||||
self.assertFalse(ilmc)
|
||||
|
||||
def test_ilmc_to_json(self):
|
||||
ilmc = telegram.InputLocationMessageContent.de_json(self.json_dict)
|
||||
|
||||
self.assertTrue(self.is_json(ilmc.to_json()))
|
||||
|
||||
def test_ilmc_to_dict(self):
|
||||
ilmc = telegram.InputLocationMessageContent.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(ilmc))
|
||||
self.assertDictEqual(self.json_dict, ilmc)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
46
tests/test_inputmessagecontent.py
Normal file
46
tests/test_inputmessagecontent.py
Normal file
|
@ -0,0 +1,46 @@
|
|||
#!/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
|
||||
InputMessageContent"""
|
||||
|
||||
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 InputMessageContentTest(BaseTest, unittest.TestCase):
|
||||
"""This object represents Tests for Telegram InputMessageContent."""
|
||||
|
||||
def test_imc_de_json(self):
|
||||
imc = telegram.InputMessageContent.de_json(None)
|
||||
|
||||
self.assertFalse(imc)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
86
tests/test_inputtextmessagecontent.py
Normal file
86
tests/test_inputtextmessagecontent.py
Normal file
|
@ -0,0 +1,86 @@
|
|||
#!/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
|
||||
InputTextMessageContent"""
|
||||
|
||||
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 InputTextMessageContentTest(BaseTest, unittest.TestCase):
|
||||
"""This object represents Tests for Telegram InputTextMessageContent."""
|
||||
|
||||
def setUp(self):
|
||||
self.message_text = '*message text*'
|
||||
self.parse_mode = telegram.ParseMode.MARKDOWN
|
||||
self.disable_web_page_preview = True
|
||||
|
||||
self.json_dict = {
|
||||
'parse_mode': self.parse_mode,
|
||||
'message_text': self.message_text,
|
||||
'disable_web_page_preview': self.disable_web_page_preview,
|
||||
}
|
||||
|
||||
def test_itmc_de_json(self):
|
||||
itmc = telegram.InputTextMessageContent.de_json(self.json_dict)
|
||||
|
||||
self.assertEqual(itmc.parse_mode, self.parse_mode)
|
||||
self.assertEqual(itmc.message_text, self.message_text)
|
||||
self.assertEqual(itmc.disable_web_page_preview,
|
||||
self.disable_web_page_preview)
|
||||
|
||||
def test_itmc_de_json_factory(self):
|
||||
itmc = telegram.InputMessageContent.de_json(self.json_dict)
|
||||
|
||||
self.assertTrue(isinstance(itmc, telegram.InputTextMessageContent))
|
||||
|
||||
def test_itmc_de_json_factory_without_required_args(self):
|
||||
json_dict = self.json_dict
|
||||
|
||||
del (json_dict['message_text'])
|
||||
|
||||
itmc = telegram.InputMessageContent.de_json(json_dict)
|
||||
|
||||
self.assertFalse(itmc)
|
||||
|
||||
def test_itmc_to_json(self):
|
||||
itmc = telegram.InputTextMessageContent.de_json(self.json_dict)
|
||||
|
||||
self.assertTrue(self.is_json(itmc.to_json()))
|
||||
|
||||
def test_itmc_to_dict(self):
|
||||
itmc = telegram.InputTextMessageContent.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(itmc))
|
||||
self.assertDictEqual(self.json_dict, itmc)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
94
tests/test_inputvenuemessagecontent.py
Normal file
94
tests/test_inputvenuemessagecontent.py
Normal file
|
@ -0,0 +1,94 @@
|
|||
#!/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
|
||||
InputVenueMessageContent"""
|
||||
|
||||
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 InputVenueMessageContentTest(BaseTest, unittest.TestCase):
|
||||
"""This object represents Tests for Telegram InputVenueMessageContent."""
|
||||
|
||||
def setUp(self):
|
||||
self.latitude = 1.
|
||||
self.longitude = 2.
|
||||
self.title = 'title'
|
||||
self._address = 'address' # nose binds self.address for testing
|
||||
self.foursquare_id = 'foursquare id'
|
||||
|
||||
self.json_dict = {
|
||||
'longitude': self.longitude,
|
||||
'latitude': self.latitude,
|
||||
'title': self.title,
|
||||
'address': self._address,
|
||||
'foursquare_id': self.foursquare_id,
|
||||
}
|
||||
|
||||
def test_ivmc_de_json(self):
|
||||
ivmc = telegram.InputVenueMessageContent.de_json(self.json_dict)
|
||||
|
||||
self.assertEqual(ivmc.longitude, self.longitude)
|
||||
self.assertEqual(ivmc.latitude, self.latitude)
|
||||
self.assertEqual(ivmc.title, self.title)
|
||||
self.assertEqual(ivmc.address, self._address)
|
||||
self.assertEqual(ivmc.foursquare_id, self.foursquare_id)
|
||||
|
||||
def test_ivmc_de_json_factory(self):
|
||||
ivmc = telegram.InputMessageContent.de_json(self.json_dict)
|
||||
|
||||
self.assertTrue(isinstance(ivmc, telegram.InputVenueMessageContent))
|
||||
|
||||
def test_ivmc_de_json_factory_without_required_args(self):
|
||||
json_dict = self.json_dict
|
||||
|
||||
del (json_dict['longitude'])
|
||||
del (json_dict['latitude'])
|
||||
del (json_dict['title'])
|
||||
del (json_dict['address'])
|
||||
|
||||
ivmc = telegram.InputMessageContent.de_json(json_dict)
|
||||
|
||||
self.assertFalse(ivmc)
|
||||
|
||||
def test_ivmc_to_json(self):
|
||||
ivmc = telegram.InputVenueMessageContent.de_json(self.json_dict)
|
||||
|
||||
self.assertTrue(self.is_json(ivmc.to_json()))
|
||||
|
||||
def test_ivmc_to_dict(self):
|
||||
ivmc = telegram.InputVenueMessageContent.de_json(
|
||||
self.json_dict).to_dict()
|
||||
|
||||
self.assertTrue(self.is_dict(ivmc))
|
||||
self.assertDictEqual(self.json_dict, ivmc)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
|
@ -46,7 +46,8 @@ root.setLevel(logging.INFO)
|
|||
|
||||
ch = logging.StreamHandler(sys.stdout)
|
||||
ch.setLevel(logging.WARN)
|
||||
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
formatter = logging.Formatter(
|
||||
'%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
ch.setFormatter(formatter)
|
||||
root.addHandler(ch)
|
||||
|
||||
|
@ -111,5 +112,6 @@ class JobQueueTest(BaseTest, unittest.TestCase):
|
|||
sleep(2)
|
||||
self.assertEqual(1, self.result)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
"""This module contains a object that represents Tests for Telegram Location"""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
import telegram
|
||||
|
@ -90,12 +90,13 @@ class LocationTest(BaseTest, unittest.TestCase):
|
|||
def test_error_location_without_required_args(self):
|
||||
json_dict = self.json_dict
|
||||
|
||||
del(json_dict['latitude'])
|
||||
del(json_dict['longitude'])
|
||||
del (json_dict['latitude'])
|
||||
del (json_dict['longitude'])
|
||||
|
||||
self.assertRaises(TypeError,
|
||||
lambda: self._bot.sendLocation(chat_id=self._chat_id,
|
||||
**json_dict))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -20,13 +20,15 @@
|
|||
|
||||
"""This module contains a object that represents Tests for Telegram ParseMode"""
|
||||
|
||||
import unittest
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
import telegram
|
||||
from tests.base import BaseTest
|
||||
|
||||
|
||||
class ParseMode(BaseTest, unittest.TestCase):
|
||||
"""This object represents Tests for Telegram ParseMode."""
|
||||
|
||||
|
@ -34,22 +36,23 @@ class ParseMode(BaseTest, unittest.TestCase):
|
|||
self.markdown_text = "*bold* _italic_ [link](http://google.com)."
|
||||
self.html_text = '<b>bold</b> <i>italic</i> <a href="http://google.com">link</a>.'
|
||||
self.formatted_text_formatted = u'bold italic link.'
|
||||
|
||||
|
||||
def test_send_message_with_parse_mode_markdown(self):
|
||||
message = self._bot.sendMessage(chat_id=self._chat_id,
|
||||
text=self.markdown_text,
|
||||
parse_mode=telegram.ParseMode.MARKDOWN)
|
||||
|
||||
|
||||
self.assertTrue(self.is_json(message.to_json()))
|
||||
self.assertEqual(message.text, self.formatted_text_formatted)
|
||||
|
||||
|
||||
def test_send_message_with_parse_mode_html(self):
|
||||
message = self._bot.sendMessage(chat_id=self._chat_id,
|
||||
text=self.html_text,
|
||||
parse_mode=telegram.ParseMode.HTML)
|
||||
|
||||
|
||||
self.assertTrue(self.is_json(message.to_json()))
|
||||
self.assertEqual(message.text, self.formatted_text_formatted)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -19,9 +19,10 @@
|
|||
|
||||
"""This module contains a object that represents Tests for Telegram Photo"""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import os
|
||||
from flaky import flaky
|
||||
|
||||
sys.path.append('.')
|
||||
|
@ -171,7 +172,7 @@ class PhotoTest(BaseTest, unittest.TestCase):
|
|||
def test_error_send_photo_empty_file(self):
|
||||
json_dict = self.json_dict
|
||||
|
||||
del(json_dict['file_id'])
|
||||
del (json_dict['file_id'])
|
||||
json_dict['photo'] = open(os.devnull, 'rb')
|
||||
|
||||
self.assertRaises(telegram.TelegramError,
|
||||
|
@ -183,7 +184,7 @@ class PhotoTest(BaseTest, unittest.TestCase):
|
|||
def test_error_send_photo_empty_file_id(self):
|
||||
json_dict = self.json_dict
|
||||
|
||||
del(json_dict['file_id'])
|
||||
del (json_dict['file_id'])
|
||||
json_dict['photo'] = ''
|
||||
|
||||
self.assertRaises(telegram.TelegramError,
|
||||
|
@ -195,13 +196,14 @@ class PhotoTest(BaseTest, unittest.TestCase):
|
|||
def test_error_photo_without_required_args(self):
|
||||
json_dict = self.json_dict
|
||||
|
||||
del(json_dict['file_id'])
|
||||
del(json_dict['width'])
|
||||
del(json_dict['height'])
|
||||
del (json_dict['file_id'])
|
||||
del (json_dict['width'])
|
||||
del (json_dict['height'])
|
||||
|
||||
self.assertRaises(TypeError,
|
||||
lambda: self._bot.sendPhoto(chat_id=self._chat_id,
|
||||
**json_dict))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -20,8 +20,9 @@
|
|||
|
||||
"""This module contains a object that represents Tests for Telegram ReplyKeyboardHide"""
|
||||
|
||||
import unittest
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
import telegram
|
||||
|
@ -39,31 +40,38 @@ class ReplyKeyboardHideTest(BaseTest, unittest.TestCase):
|
|||
'hide_keyboard': self.hide_keyboard,
|
||||
'selective': self.selective,
|
||||
}
|
||||
|
||||
|
||||
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))
|
||||
|
||||
reply_markup=telegram.ReplyKeyboardHide.de_json(
|
||||
self.json_dict))
|
||||
|
||||
self.assertTrue(self.is_json(message.to_json()))
|
||||
self.assertEqual(message.text, u'Моё судно на воздушной подушке полно угрей')
|
||||
self.assertEqual(message.text,
|
||||
u'Моё судно на воздушной подушке полно угрей')
|
||||
|
||||
def test_reply_keyboard_hide_de_json(self):
|
||||
reply_keyboard_hide = telegram.ReplyKeyboardHide.de_json(self.json_dict)
|
||||
reply_keyboard_hide = telegram.ReplyKeyboardHide.de_json(
|
||||
self.json_dict)
|
||||
|
||||
self.assertEqual(reply_keyboard_hide.hide_keyboard, self.hide_keyboard)
|
||||
self.assertEqual(reply_keyboard_hide.selective, self.selective)
|
||||
|
||||
|
||||
def test_reply_keyboard_hide_to_json(self):
|
||||
reply_keyboard_hide = telegram.ReplyKeyboardHide.de_json(self.json_dict)
|
||||
reply_keyboard_hide = telegram.ReplyKeyboardHide.de_json(
|
||||
self.json_dict)
|
||||
|
||||
self.assertTrue(self.is_json(reply_keyboard_hide.to_json()))
|
||||
|
||||
def test_reply_keyboard_hide_to_dict(self):
|
||||
reply_keyboard_hide = telegram.ReplyKeyboardHide.de_json(self.json_dict)
|
||||
|
||||
self.assertEqual(reply_keyboard_hide['hide_keyboard'], self.hide_keyboard)
|
||||
def test_reply_keyboard_hide_to_dict(self):
|
||||
reply_keyboard_hide = telegram.ReplyKeyboardHide.de_json(
|
||||
self.json_dict)
|
||||
|
||||
self.assertEqual(reply_keyboard_hide['hide_keyboard'],
|
||||
self.hide_keyboard)
|
||||
self.assertEqual(reply_keyboard_hide['selective'], self.selective)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -20,8 +20,9 @@
|
|||
|
||||
"""This module contains a object that represents Tests for Telegram ReplyKeyboardMarkup"""
|
||||
|
||||
import unittest
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
import telegram
|
||||
|
@ -49,35 +50,45 @@ 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))
|
||||
reply_markup=telegram.ReplyKeyboardMarkup.de_json(
|
||||
self.json_dict))
|
||||
|
||||
self.assertTrue(self.is_json(message.to_json()))
|
||||
self.assertEqual(message.text, u'Моё судно на воздушной подушке полно угрей')
|
||||
self.assertEqual(message.text,
|
||||
u'Моё судно на воздушной подушке полно угрей')
|
||||
|
||||
def test_reply_keyboard_markup_de_json(self):
|
||||
reply_keyboard_markup = telegram.ReplyKeyboardMarkup.de_json(self.json_dict)
|
||||
reply_keyboard_markup = telegram.ReplyKeyboardMarkup.de_json(
|
||||
self.json_dict)
|
||||
|
||||
self.assertTrue(isinstance(reply_keyboard_markup.keyboard, list))
|
||||
self.assertTrue(isinstance(reply_keyboard_markup.keyboard[0][0],
|
||||
telegram.KeyboardButton))
|
||||
self.assertEqual(reply_keyboard_markup.resize_keyboard, self.resize_keyboard)
|
||||
self.assertEqual(reply_keyboard_markup.one_time_keyboard, self.one_time_keyboard)
|
||||
telegram.KeyboardButton))
|
||||
self.assertEqual(reply_keyboard_markup.resize_keyboard,
|
||||
self.resize_keyboard)
|
||||
self.assertEqual(reply_keyboard_markup.one_time_keyboard,
|
||||
self.one_time_keyboard)
|
||||
self.assertEqual(reply_keyboard_markup.selective, self.selective)
|
||||
|
||||
def test_reply_keyboard_markup_to_json(self):
|
||||
reply_keyboard_markup = telegram.ReplyKeyboardMarkup.de_json(self.json_dict)
|
||||
reply_keyboard_markup = telegram.ReplyKeyboardMarkup.de_json(
|
||||
self.json_dict)
|
||||
|
||||
self.assertTrue(self.is_json(reply_keyboard_markup.to_json()))
|
||||
|
||||
def test_reply_keyboard_markup_to_dict(self):
|
||||
reply_keyboard_markup = telegram.ReplyKeyboardMarkup.de_json(self.json_dict)
|
||||
reply_keyboard_markup = telegram.ReplyKeyboardMarkup.de_json(
|
||||
self.json_dict)
|
||||
|
||||
self.assertTrue(isinstance(reply_keyboard_markup.keyboard, list))
|
||||
self.assertTrue(isinstance(reply_keyboard_markup.keyboard[0][0],
|
||||
telegram.KeyboardButton))
|
||||
self.assertEqual(reply_keyboard_markup['resize_keyboard'], self.resize_keyboard)
|
||||
self.assertEqual(reply_keyboard_markup['one_time_keyboard'], self.one_time_keyboard)
|
||||
telegram.KeyboardButton))
|
||||
self.assertEqual(reply_keyboard_markup['resize_keyboard'],
|
||||
self.resize_keyboard)
|
||||
self.assertEqual(reply_keyboard_markup['one_time_keyboard'],
|
||||
self.one_time_keyboard)
|
||||
self.assertEqual(reply_keyboard_markup['selective'], self.selective)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -19,9 +19,10 @@
|
|||
|
||||
"""This module contains a object that represents Tests for Telegram Sticker"""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import os
|
||||
from flaky import flaky
|
||||
|
||||
sys.path.append('.')
|
||||
|
@ -60,7 +61,7 @@ class StickerTest(BaseTest, unittest.TestCase):
|
|||
@timeout(10)
|
||||
def test_send_sticker_resend(self):
|
||||
message = self._bot.sendSticker(chat_id=self._chat_id,
|
||||
sticker=self.sticker_file_id)
|
||||
sticker=self.sticker_file_id)
|
||||
|
||||
sticker = message.sticker
|
||||
|
||||
|
@ -98,7 +99,7 @@ class StickerTest(BaseTest, unittest.TestCase):
|
|||
def test_error_send_sticker_empty_file(self):
|
||||
json_dict = self.json_dict
|
||||
|
||||
del(json_dict['file_id'])
|
||||
del (json_dict['file_id'])
|
||||
json_dict['sticker'] = open(os.devnull, 'rb')
|
||||
|
||||
self.assertRaises(telegram.TelegramError,
|
||||
|
@ -110,23 +111,24 @@ class StickerTest(BaseTest, unittest.TestCase):
|
|||
def test_error_send_sticker_empty_file_id(self):
|
||||
json_dict = self.json_dict
|
||||
|
||||
del(json_dict['file_id'])
|
||||
del (json_dict['file_id'])
|
||||
json_dict['sticker'] = ''
|
||||
|
||||
self.assertRaises(telegram.TelegramError,
|
||||
lambda: self._bot.sendSticker(chat_id=self._chat_id,
|
||||
**json_dict))
|
||||
**json_dict))
|
||||
|
||||
@flaky(3, 1)
|
||||
@timeout(10)
|
||||
def test_error_sticker_without_required_args(self):
|
||||
json_dict = self.json_dict
|
||||
|
||||
del(json_dict['file_id'])
|
||||
del (json_dict['file_id'])
|
||||
|
||||
self.assertRaises(TypeError,
|
||||
lambda: self._bot.sendSticker(chat_id=self._chat_id,
|
||||
**json_dict))
|
||||
**json_dict))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
# !/usr/bin/env python
|
||||
#
|
||||
# A library that provides a Python interface to the Telegram Bot API
|
||||
# Copyright (C) 2015-2016
|
||||
|
@ -19,9 +19,9 @@
|
|||
|
||||
"""This module contains a object that represents Tests for Telegram Update"""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
import telegram
|
||||
|
@ -69,5 +69,6 @@ class UpdateTest(BaseTest, unittest.TestCase):
|
|||
self.assertEqual(update['update_id'], self.update_id)
|
||||
self.assertTrue(isinstance(update['message'], telegram.Message))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -23,14 +23,15 @@ This module contains a object that represents Tests for Updater, Dispatcher,
|
|||
WebhookServer and WebhookHandler
|
||||
"""
|
||||
import logging
|
||||
import sys
|
||||
import re
|
||||
import os
|
||||
import signal
|
||||
from random import randrange
|
||||
from time import sleep
|
||||
import sys
|
||||
from datetime import datetime
|
||||
from time import sleep
|
||||
|
||||
import os
|
||||
import re
|
||||
from future.builtins import bytes
|
||||
from random import randrange
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
|
@ -570,7 +571,6 @@ class UpdaterTest(BaseTest, unittest.TestCase):
|
|||
|
||||
req = Request(url, data=payload, headers=headers)
|
||||
|
||||
|
||||
if get_method is not None:
|
||||
req.get_method = get_method
|
||||
|
||||
|
@ -602,7 +602,6 @@ class UpdaterTest(BaseTest, unittest.TestCase):
|
|||
|
||||
|
||||
class MockBot(object):
|
||||
|
||||
def __init__(self, text, messages=1, raise_error=False,
|
||||
bootstrap_retries=None, bootstrap_err=TelegramError('test')):
|
||||
self.text = text
|
||||
|
@ -646,5 +645,6 @@ class MockBot(object):
|
|||
else:
|
||||
return []
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
# !/usr/bin/env python
|
||||
#
|
||||
# A library that provides a Python interface to the Telegram Bot API
|
||||
# Copyright (C) 2015-2016
|
||||
|
@ -19,9 +19,9 @@
|
|||
|
||||
"""This module contains a object that represents Tests for Telegram User"""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
import telegram
|
||||
|
@ -60,7 +60,7 @@ class UserTest(BaseTest, unittest.TestCase):
|
|||
def test_user_de_json_without_username(self):
|
||||
json_dict = self.json_dict
|
||||
|
||||
del(json_dict['username'])
|
||||
del (json_dict['username'])
|
||||
|
||||
user = telegram.User.de_json(self.json_dict)
|
||||
|
||||
|
@ -69,14 +69,14 @@ class UserTest(BaseTest, unittest.TestCase):
|
|||
self.assertEqual(user.last_name, self.last_name)
|
||||
self.assertEqual(user.type, self.type)
|
||||
|
||||
self.assertEqual(user.name, '%s %s' % (self.first_name, self.last_name))
|
||||
|
||||
self.assertEqual(user.name,
|
||||
'%s %s' % (self.first_name, self.last_name))
|
||||
|
||||
def test_user_de_json_without_username_and_lastname(self):
|
||||
json_dict = self.json_dict
|
||||
|
||||
del(json_dict['username'])
|
||||
del(json_dict['last_name'])
|
||||
del (json_dict['username'])
|
||||
del (json_dict['last_name'])
|
||||
|
||||
user = telegram.User.de_json(self.json_dict)
|
||||
|
||||
|
@ -100,5 +100,6 @@ class UserTest(BaseTest, unittest.TestCase):
|
|||
self.assertEqual(user['username'], self.username)
|
||||
self.assertEqual(user['type'], self.type)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -19,9 +19,10 @@
|
|||
|
||||
"""This module contains a object that represents Tests for Telegram Video"""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import os
|
||||
from flaky import flaky
|
||||
|
||||
sys.path.append('.')
|
||||
|
@ -217,7 +218,7 @@ class VideoTest(BaseTest, unittest.TestCase):
|
|||
def test_error_send_video_empty_file(self):
|
||||
json_dict = self.json_dict
|
||||
|
||||
del(json_dict['file_id'])
|
||||
del (json_dict['file_id'])
|
||||
json_dict['video'] = open(os.devnull, 'rb')
|
||||
|
||||
self.assertRaises(telegram.TelegramError,
|
||||
|
@ -230,7 +231,7 @@ class VideoTest(BaseTest, unittest.TestCase):
|
|||
def test_error_send_video_empty_file_id(self):
|
||||
json_dict = self.json_dict
|
||||
|
||||
del(json_dict['file_id'])
|
||||
del (json_dict['file_id'])
|
||||
json_dict['video'] = ''
|
||||
|
||||
self.assertRaises(telegram.TelegramError,
|
||||
|
@ -243,13 +244,14 @@ class VideoTest(BaseTest, unittest.TestCase):
|
|||
def test_error_video_without_required_args(self):
|
||||
json_dict = self.json_dict
|
||||
|
||||
del(json_dict['file_id'])
|
||||
del(json_dict['duration'])
|
||||
del (json_dict['file_id'])
|
||||
del (json_dict['duration'])
|
||||
|
||||
self.assertRaises(TypeError,
|
||||
lambda: self._bot.sendVideo(chat_id=self._chat_id,
|
||||
timeout=10,
|
||||
**json_dict))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -19,9 +19,10 @@
|
|||
|
||||
"""This module contains a object that represents Tests for Telegram Voice"""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import os
|
||||
from flaky import flaky
|
||||
|
||||
sys.path.append('.')
|
||||
|
@ -165,7 +166,7 @@ class VoiceTest(BaseTest, unittest.TestCase):
|
|||
def test_error_send_voice_empty_file(self):
|
||||
json_dict = self.json_dict
|
||||
|
||||
del(json_dict['file_id'])
|
||||
del (json_dict['file_id'])
|
||||
json_dict['voice'] = open(os.devnull, 'rb')
|
||||
|
||||
self.assertRaises(telegram.TelegramError,
|
||||
|
@ -177,7 +178,7 @@ class VoiceTest(BaseTest, unittest.TestCase):
|
|||
def test_error_send_voice_empty_file_id(self):
|
||||
json_dict = self.json_dict
|
||||
|
||||
del(json_dict['file_id'])
|
||||
del (json_dict['file_id'])
|
||||
json_dict['voice'] = ''
|
||||
|
||||
self.assertRaises(telegram.TelegramError,
|
||||
|
@ -189,12 +190,13 @@ class VoiceTest(BaseTest, unittest.TestCase):
|
|||
def test_error_voice_without_required_args(self):
|
||||
json_dict = self.json_dict
|
||||
|
||||
del(json_dict['file_id'])
|
||||
del(json_dict['duration'])
|
||||
del (json_dict['file_id'])
|
||||
del (json_dict['duration'])
|
||||
|
||||
self.assertRaises(TypeError,
|
||||
lambda: self._bot.sendVoice(chat_id=self._chat_id,
|
||||
**json_dict))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Reference in a new issue