mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-12-22 06:25:12 +01:00
flake8 revamp
- Use pre-commit v1.2.0 flake8 - Make sure we're running flake8 on examples and tests - Fix what had to be fixed
This commit is contained in:
parent
746ae0caf3
commit
baec1bb554
44 changed files with 577 additions and 562 deletions
|
@ -6,10 +6,10 @@
|
|||
args:
|
||||
- --diff
|
||||
- repo: git://github.com/pre-commit/pre-commit-hooks
|
||||
sha: 78818b90cd694c29333ba54d38f9e60b6359ccfc
|
||||
sha: v1.2.0
|
||||
hooks:
|
||||
- id: flake8
|
||||
files: ^telegram/.*\.py$
|
||||
exclude: ^(setup.py|docs/source/conf.py)$
|
||||
- repo: git://github.com/pre-commit/mirrors-pylint
|
||||
sha: v1.7.1
|
||||
hooks:
|
||||
|
|
|
@ -18,8 +18,6 @@ bot.
|
|||
"""
|
||||
from uuid import uuid4
|
||||
|
||||
import re
|
||||
|
||||
from telegram.utils.helpers import escape_markdown
|
||||
|
||||
from telegram import InlineQueryResultArticle, ParseMode, \
|
||||
|
|
|
@ -283,7 +283,7 @@ class JobQueue(object):
|
|||
self.logger.debug('Running job %s', job.name)
|
||||
job.run(self.bot)
|
||||
|
||||
except:
|
||||
except Exception:
|
||||
self.logger.exception('An uncaught error was raised while executing job %s',
|
||||
job.name)
|
||||
else:
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
import os
|
||||
import time
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime
|
||||
from platform import python_implementation
|
||||
|
||||
import pytest
|
||||
|
@ -552,7 +552,6 @@ class TestBot(object):
|
|||
def test_restrict_chat_member(self, bot, channel_id):
|
||||
# TODO: Add bot to supergroup so this can be tested properly
|
||||
with pytest.raises(BadRequest, match='Method is available only for supergroups'):
|
||||
until = datetime.now() + timedelta(seconds=30)
|
||||
assert bot.restrict_chat_member(channel_id,
|
||||
95205500,
|
||||
until_date=datetime.now(),
|
||||
|
|
|
@ -44,4 +44,4 @@ class TestConstants(object):
|
|||
bad_caption = good_caption + 'Z'
|
||||
with pytest.raises(BadRequest, message="Media_caption_too_long"):
|
||||
with open('tests/data/telegram.png', 'rb') as f:
|
||||
bad_message = bot.send_photo(photo=f, caption=bad_caption, chat_id=chat_id)
|
||||
bot.send_photo(photo=f, caption=bad_caption, chat_id=chat_id)
|
||||
|
|
|
@ -88,8 +88,8 @@ class TestConversationHandler(object):
|
|||
# Tests
|
||||
def test_per_all_false(self):
|
||||
with pytest.raises(ValueError, match="can't all be 'False'"):
|
||||
handler = ConversationHandler(self.entry_points, self.states, self.fallbacks,
|
||||
per_chat=False, per_user=False, per_message=False)
|
||||
ConversationHandler(self.entry_points, self.states, self.fallbacks,
|
||||
per_chat=False, per_user=False, per_message=False)
|
||||
|
||||
def test_conversation_handler(self, dp, bot, user1, user2):
|
||||
handler = ConversationHandler(entry_points=self.entry_points, states=self.states,
|
||||
|
|
|
@ -35,7 +35,8 @@ def dp2(bot):
|
|||
|
||||
|
||||
class TestDispatcher(object):
|
||||
message_update = Update(1, message=Message(1, User(1, '', False), None, Chat(1, ''), text='Text'))
|
||||
message_update = Update(1,
|
||||
message=Message(1, User(1, '', False), None, Chat(1, ''), text='Text'))
|
||||
received = None
|
||||
count = 0
|
||||
|
||||
|
|
|
@ -48,8 +48,8 @@ class TestInlineKeyboardButton(object):
|
|||
assert inline_keyboard_button.url == self.url
|
||||
assert inline_keyboard_button.callback_data == self.callback_data
|
||||
assert inline_keyboard_button.switch_inline_query == self.switch_inline_query
|
||||
assert inline_keyboard_button.switch_inline_query_current_chat == \
|
||||
self.switch_inline_query_current_chat
|
||||
assert (inline_keyboard_button.switch_inline_query_current_chat ==
|
||||
self.switch_inline_query_current_chat)
|
||||
assert inline_keyboard_button.callback_game == self.callback_game
|
||||
assert inline_keyboard_button.pay == self.pay
|
||||
|
||||
|
@ -60,9 +60,9 @@ class TestInlineKeyboardButton(object):
|
|||
assert inline_keyboard_button_dict['text'] == inline_keyboard_button.text
|
||||
assert inline_keyboard_button_dict['url'] == inline_keyboard_button.url
|
||||
assert inline_keyboard_button_dict['callback_data'] == inline_keyboard_button.callback_data
|
||||
assert inline_keyboard_button_dict['switch_inline_query'] == \
|
||||
inline_keyboard_button.switch_inline_query
|
||||
assert inline_keyboard_button_dict['switch_inline_query_current_chat'] == \
|
||||
inline_keyboard_button.switch_inline_query_current_chat
|
||||
assert (inline_keyboard_button_dict['switch_inline_query'] ==
|
||||
inline_keyboard_button.switch_inline_query)
|
||||
assert (inline_keyboard_button_dict['switch_inline_query_current_chat'] ==
|
||||
inline_keyboard_button.switch_inline_query_current_chat)
|
||||
assert inline_keyboard_button_dict['callback_game'] == inline_keyboard_button.callback_game
|
||||
assert inline_keyboard_button_dict['pay'] == inline_keyboard_button.pay
|
||||
|
|
|
@ -25,16 +25,17 @@ from telegram import (InlineKeyboardMarkup, InlineQueryResultAudio, InlineQueryR
|
|||
|
||||
@pytest.fixture(scope='class')
|
||||
def inline_query_result_article():
|
||||
return InlineQueryResultArticle(TestInlineQueryResultArticle.id,
|
||||
TestInlineQueryResultArticle.title,
|
||||
input_message_content=TestInlineQueryResultArticle.input_message_content,
|
||||
reply_markup=TestInlineQueryResultArticle.reply_markup,
|
||||
url=TestInlineQueryResultArticle.url,
|
||||
hide_url=TestInlineQueryResultArticle.hide_url,
|
||||
description=TestInlineQueryResultArticle.description,
|
||||
thumb_url=TestInlineQueryResultArticle.thumb_url,
|
||||
thumb_height=TestInlineQueryResultArticle.thumb_height,
|
||||
thumb_width=TestInlineQueryResultArticle.thumb_width)
|
||||
return InlineQueryResultArticle(
|
||||
TestInlineQueryResultArticle.id,
|
||||
TestInlineQueryResultArticle.title,
|
||||
input_message_content=TestInlineQueryResultArticle.input_message_content,
|
||||
reply_markup=TestInlineQueryResultArticle.reply_markup,
|
||||
url=TestInlineQueryResultArticle.url,
|
||||
hide_url=TestInlineQueryResultArticle.hide_url,
|
||||
description=TestInlineQueryResultArticle.description,
|
||||
thumb_url=TestInlineQueryResultArticle.thumb_url,
|
||||
thumb_height=TestInlineQueryResultArticle.thumb_height,
|
||||
thumb_width=TestInlineQueryResultArticle.thumb_width)
|
||||
|
||||
|
||||
class TestInlineQueryResultArticle(object):
|
||||
|
@ -54,8 +55,8 @@ class TestInlineQueryResultArticle(object):
|
|||
assert inline_query_result_article.type == self.type
|
||||
assert inline_query_result_article.id == self.id
|
||||
assert inline_query_result_article.title == self.title
|
||||
assert inline_query_result_article.input_message_content.to_dict() == \
|
||||
self.input_message_content.to_dict()
|
||||
assert (inline_query_result_article.input_message_content.to_dict() ==
|
||||
self.input_message_content.to_dict())
|
||||
assert inline_query_result_article.reply_markup.to_dict() == self.reply_markup.to_dict()
|
||||
assert inline_query_result_article.url == self.url
|
||||
assert inline_query_result_article.hide_url == self.hide_url
|
||||
|
@ -71,20 +72,20 @@ class TestInlineQueryResultArticle(object):
|
|||
assert inline_query_result_article_dict['type'] == inline_query_result_article.type
|
||||
assert inline_query_result_article_dict['id'] == inline_query_result_article.id
|
||||
assert inline_query_result_article_dict['title'] == inline_query_result_article.title
|
||||
assert inline_query_result_article_dict['input_message_content'] == \
|
||||
inline_query_result_article.input_message_content.to_dict()
|
||||
assert inline_query_result_article_dict['reply_markup'] == \
|
||||
inline_query_result_article.reply_markup.to_dict()
|
||||
assert (inline_query_result_article_dict['input_message_content'] ==
|
||||
inline_query_result_article.input_message_content.to_dict())
|
||||
assert (inline_query_result_article_dict['reply_markup'] ==
|
||||
inline_query_result_article.reply_markup.to_dict())
|
||||
assert inline_query_result_article_dict['url'] == inline_query_result_article.url
|
||||
assert inline_query_result_article_dict['hide_url'] == inline_query_result_article.hide_url
|
||||
assert inline_query_result_article_dict['description'] == \
|
||||
inline_query_result_article.description
|
||||
assert inline_query_result_article_dict['thumb_url'] == \
|
||||
inline_query_result_article.thumb_url
|
||||
assert inline_query_result_article_dict['thumb_height'] == \
|
||||
inline_query_result_article.thumb_height
|
||||
assert inline_query_result_article_dict['thumb_width'] == \
|
||||
inline_query_result_article.thumb_width
|
||||
assert (inline_query_result_article_dict['description'] ==
|
||||
inline_query_result_article.description)
|
||||
assert (inline_query_result_article_dict['thumb_url'] ==
|
||||
inline_query_result_article.thumb_url)
|
||||
assert (inline_query_result_article_dict['thumb_height'] ==
|
||||
inline_query_result_article.thumb_height)
|
||||
assert (inline_query_result_article_dict['thumb_width'] ==
|
||||
inline_query_result_article.thumb_width)
|
||||
|
||||
def test_equality(self):
|
||||
a = InlineQueryResultArticle(self.id, self.title, self.input_message_content)
|
||||
|
|
|
@ -25,15 +25,16 @@ from telegram import (InlineKeyboardMarkup, InlineKeyboardButton, InlineQueryRes
|
|||
|
||||
@pytest.fixture(scope='class')
|
||||
def inline_query_result_audio():
|
||||
return InlineQueryResultAudio(TestInlineQueryResultAudio.id,
|
||||
TestInlineQueryResultAudio.audio_url,
|
||||
TestInlineQueryResultAudio.title,
|
||||
performer=TestInlineQueryResultAudio.performer,
|
||||
audio_duration=TestInlineQueryResultAudio.audio_duration,
|
||||
caption=TestInlineQueryResultAudio.caption,
|
||||
parse_mode=TestInlineQueryResultAudio.parse_mode,
|
||||
input_message_content=TestInlineQueryResultAudio.input_message_content,
|
||||
reply_markup=TestInlineQueryResultAudio.reply_markup)
|
||||
return InlineQueryResultAudio(
|
||||
TestInlineQueryResultAudio.id,
|
||||
TestInlineQueryResultAudio.audio_url,
|
||||
TestInlineQueryResultAudio.title,
|
||||
performer=TestInlineQueryResultAudio.performer,
|
||||
audio_duration=TestInlineQueryResultAudio.audio_duration,
|
||||
caption=TestInlineQueryResultAudio.caption,
|
||||
parse_mode=TestInlineQueryResultAudio.parse_mode,
|
||||
input_message_content=TestInlineQueryResultAudio.input_message_content,
|
||||
reply_markup=TestInlineQueryResultAudio.reply_markup)
|
||||
|
||||
|
||||
class TestInlineQueryResultAudio(object):
|
||||
|
@ -57,8 +58,8 @@ class TestInlineQueryResultAudio(object):
|
|||
assert inline_query_result_audio.audio_duration == self.audio_duration
|
||||
assert inline_query_result_audio.caption == self.caption
|
||||
assert inline_query_result_audio.parse_mode == self.parse_mode
|
||||
assert inline_query_result_audio.input_message_content.to_dict() == \
|
||||
self.input_message_content.to_dict()
|
||||
assert (inline_query_result_audio.input_message_content.to_dict() ==
|
||||
self.input_message_content.to_dict())
|
||||
assert inline_query_result_audio.reply_markup.to_dict() == self.reply_markup.to_dict()
|
||||
|
||||
def test_to_dict(self, inline_query_result_audio):
|
||||
|
@ -70,14 +71,14 @@ class TestInlineQueryResultAudio(object):
|
|||
assert inline_query_result_audio_dict['audio_url'] == inline_query_result_audio.audio_url
|
||||
assert inline_query_result_audio_dict['title'] == inline_query_result_audio.title
|
||||
assert inline_query_result_audio_dict['performer'] == inline_query_result_audio.performer
|
||||
assert inline_query_result_audio_dict['audio_duration'] == \
|
||||
inline_query_result_audio.audio_duration
|
||||
assert (inline_query_result_audio_dict['audio_duration'] ==
|
||||
inline_query_result_audio.audio_duration)
|
||||
assert inline_query_result_audio_dict['caption'] == inline_query_result_audio.caption
|
||||
assert inline_query_result_audio_dict['parse_mode'] == inline_query_result_audio.parse_mode
|
||||
assert inline_query_result_audio_dict['input_message_content'] == \
|
||||
inline_query_result_audio.input_message_content.to_dict()
|
||||
assert inline_query_result_audio_dict['reply_markup'] == \
|
||||
inline_query_result_audio.reply_markup.to_dict()
|
||||
assert (inline_query_result_audio_dict['input_message_content'] ==
|
||||
inline_query_result_audio.input_message_content.to_dict())
|
||||
assert (inline_query_result_audio_dict['reply_markup'] ==
|
||||
inline_query_result_audio.reply_markup.to_dict())
|
||||
|
||||
def test_equality(self):
|
||||
a = InlineQueryResultAudio(self.id, self.audio_url, self.title)
|
||||
|
|
|
@ -25,12 +25,13 @@ from telegram import (InputTextMessageContent, InlineQueryResultCachedAudio, Inl
|
|||
|
||||
@pytest.fixture(scope='class')
|
||||
def inline_query_result_cached_audio():
|
||||
return InlineQueryResultCachedAudio(TestInlineQueryResultCachedAudio.id,
|
||||
TestInlineQueryResultCachedAudio.audio_file_id,
|
||||
caption=TestInlineQueryResultCachedAudio.caption,
|
||||
parse_mode=TestInlineQueryResultCachedAudio.parse_mode,
|
||||
input_message_content=TestInlineQueryResultCachedAudio.input_message_content,
|
||||
reply_markup=TestInlineQueryResultCachedAudio.reply_markup)
|
||||
return InlineQueryResultCachedAudio(
|
||||
TestInlineQueryResultCachedAudio.id,
|
||||
TestInlineQueryResultCachedAudio.audio_file_id,
|
||||
caption=TestInlineQueryResultCachedAudio.caption,
|
||||
parse_mode=TestInlineQueryResultCachedAudio.parse_mode,
|
||||
input_message_content=TestInlineQueryResultCachedAudio.input_message_content,
|
||||
reply_markup=TestInlineQueryResultCachedAudio.reply_markup)
|
||||
|
||||
|
||||
class TestInlineQueryResultCachedAudio(object):
|
||||
|
@ -48,28 +49,28 @@ class TestInlineQueryResultCachedAudio(object):
|
|||
assert inline_query_result_cached_audio.audio_file_id == self.audio_file_id
|
||||
assert inline_query_result_cached_audio.caption == self.caption
|
||||
assert inline_query_result_cached_audio.parse_mode == self.parse_mode
|
||||
assert inline_query_result_cached_audio.input_message_content.to_dict() == \
|
||||
self.input_message_content.to_dict()
|
||||
assert inline_query_result_cached_audio.reply_markup.to_dict() == \
|
||||
self.reply_markup.to_dict()
|
||||
assert (inline_query_result_cached_audio.input_message_content.to_dict() ==
|
||||
self.input_message_content.to_dict())
|
||||
assert (inline_query_result_cached_audio.reply_markup.to_dict() ==
|
||||
self.reply_markup.to_dict())
|
||||
|
||||
def test_to_dict(self, inline_query_result_cached_audio):
|
||||
inline_query_result_cached_audio_dict = inline_query_result_cached_audio.to_dict()
|
||||
|
||||
assert isinstance(inline_query_result_cached_audio_dict, dict)
|
||||
assert inline_query_result_cached_audio_dict['type'] == \
|
||||
inline_query_result_cached_audio.type
|
||||
assert (inline_query_result_cached_audio_dict['type'] ==
|
||||
inline_query_result_cached_audio.type)
|
||||
assert inline_query_result_cached_audio_dict['id'] == inline_query_result_cached_audio.id
|
||||
assert inline_query_result_cached_audio_dict['audio_file_id'] == \
|
||||
inline_query_result_cached_audio.audio_file_id
|
||||
assert inline_query_result_cached_audio_dict['caption'] == \
|
||||
inline_query_result_cached_audio.caption
|
||||
assert inline_query_result_cached_audio_dict['parse_mode'] == \
|
||||
inline_query_result_cached_audio.parse_mode
|
||||
assert inline_query_result_cached_audio_dict['input_message_content'] == \
|
||||
inline_query_result_cached_audio.input_message_content.to_dict()
|
||||
assert inline_query_result_cached_audio_dict['reply_markup'] == \
|
||||
inline_query_result_cached_audio.reply_markup.to_dict()
|
||||
assert (inline_query_result_cached_audio_dict['audio_file_id'] ==
|
||||
inline_query_result_cached_audio.audio_file_id)
|
||||
assert (inline_query_result_cached_audio_dict['caption'] ==
|
||||
inline_query_result_cached_audio.caption)
|
||||
assert (inline_query_result_cached_audio_dict['parse_mode'] ==
|
||||
inline_query_result_cached_audio.parse_mode)
|
||||
assert (inline_query_result_cached_audio_dict['input_message_content'] ==
|
||||
inline_query_result_cached_audio.input_message_content.to_dict())
|
||||
assert (inline_query_result_cached_audio_dict['reply_markup'] ==
|
||||
inline_query_result_cached_audio.reply_markup.to_dict())
|
||||
|
||||
def test_equality(self):
|
||||
a = InlineQueryResultCachedAudio(self.id, self.audio_file_id)
|
||||
|
|
|
@ -25,14 +25,15 @@ from telegram import (InlineQueryResultCachedDocument, InlineKeyboardButton, Inl
|
|||
|
||||
@pytest.fixture(scope='class')
|
||||
def inline_query_result_cached_document():
|
||||
return InlineQueryResultCachedDocument(TestInlineQueryResultCachedDocument.id,
|
||||
TestInlineQueryResultCachedDocument.title,
|
||||
TestInlineQueryResultCachedDocument.document_file_id,
|
||||
caption=TestInlineQueryResultCachedDocument.caption,
|
||||
parse_mode=TestInlineQueryResultCachedDocument.parse_mode,
|
||||
description=TestInlineQueryResultCachedDocument.description,
|
||||
input_message_content=TestInlineQueryResultCachedDocument.input_message_content,
|
||||
reply_markup=TestInlineQueryResultCachedDocument.reply_markup)
|
||||
return InlineQueryResultCachedDocument(
|
||||
TestInlineQueryResultCachedDocument.id,
|
||||
TestInlineQueryResultCachedDocument.title,
|
||||
TestInlineQueryResultCachedDocument.document_file_id,
|
||||
caption=TestInlineQueryResultCachedDocument.caption,
|
||||
parse_mode=TestInlineQueryResultCachedDocument.parse_mode,
|
||||
description=TestInlineQueryResultCachedDocument.description,
|
||||
input_message_content=TestInlineQueryResultCachedDocument.input_message_content,
|
||||
reply_markup=TestInlineQueryResultCachedDocument.reply_markup)
|
||||
|
||||
|
||||
class TestInlineQueryResultCachedDocument(object):
|
||||
|
@ -54,33 +55,33 @@ class TestInlineQueryResultCachedDocument(object):
|
|||
assert inline_query_result_cached_document.caption == self.caption
|
||||
assert inline_query_result_cached_document.parse_mode == self.parse_mode
|
||||
assert inline_query_result_cached_document.description == self.description
|
||||
assert inline_query_result_cached_document.input_message_content.to_dict() == \
|
||||
self.input_message_content.to_dict()
|
||||
assert inline_query_result_cached_document.reply_markup.to_dict() == \
|
||||
self.reply_markup.to_dict()
|
||||
assert (inline_query_result_cached_document.input_message_content.to_dict() ==
|
||||
self.input_message_content.to_dict())
|
||||
assert (inline_query_result_cached_document.reply_markup.to_dict() ==
|
||||
self.reply_markup.to_dict())
|
||||
|
||||
def test_to_dict(self, inline_query_result_cached_document):
|
||||
inline_query_result_cached_document_dict = inline_query_result_cached_document.to_dict()
|
||||
|
||||
assert isinstance(inline_query_result_cached_document_dict, dict)
|
||||
assert inline_query_result_cached_document_dict['id'] == \
|
||||
inline_query_result_cached_document.id
|
||||
assert inline_query_result_cached_document_dict['type'] == \
|
||||
inline_query_result_cached_document.type
|
||||
assert inline_query_result_cached_document_dict['document_file_id'] == \
|
||||
inline_query_result_cached_document.document_file_id
|
||||
assert inline_query_result_cached_document_dict['title'] == \
|
||||
inline_query_result_cached_document.title
|
||||
assert inline_query_result_cached_document_dict['caption'] == \
|
||||
inline_query_result_cached_document.caption
|
||||
assert inline_query_result_cached_document_dict['parse_mode'] == \
|
||||
inline_query_result_cached_document.parse_mode
|
||||
assert inline_query_result_cached_document_dict['description'] == \
|
||||
inline_query_result_cached_document.description
|
||||
assert inline_query_result_cached_document_dict['input_message_content'] == \
|
||||
inline_query_result_cached_document.input_message_content.to_dict()
|
||||
assert inline_query_result_cached_document_dict['reply_markup'] == \
|
||||
inline_query_result_cached_document.reply_markup.to_dict()
|
||||
assert (inline_query_result_cached_document_dict['id'] ==
|
||||
inline_query_result_cached_document.id)
|
||||
assert (inline_query_result_cached_document_dict['type'] ==
|
||||
inline_query_result_cached_document.type)
|
||||
assert (inline_query_result_cached_document_dict['document_file_id'] ==
|
||||
inline_query_result_cached_document.document_file_id)
|
||||
assert (inline_query_result_cached_document_dict['title'] ==
|
||||
inline_query_result_cached_document.title)
|
||||
assert (inline_query_result_cached_document_dict['caption'] ==
|
||||
inline_query_result_cached_document.caption)
|
||||
assert (inline_query_result_cached_document_dict['parse_mode'] ==
|
||||
inline_query_result_cached_document.parse_mode)
|
||||
assert (inline_query_result_cached_document_dict['description'] ==
|
||||
inline_query_result_cached_document.description)
|
||||
assert (inline_query_result_cached_document_dict['input_message_content'] ==
|
||||
inline_query_result_cached_document.input_message_content.to_dict())
|
||||
assert (inline_query_result_cached_document_dict['reply_markup'] ==
|
||||
inline_query_result_cached_document.reply_markup.to_dict())
|
||||
|
||||
def test_equality(self):
|
||||
a = InlineQueryResultCachedDocument(self.id, self.title, self.document_file_id)
|
||||
|
|
|
@ -25,13 +25,14 @@ from telegram import (InlineKeyboardButton, InputTextMessageContent, InlineQuery
|
|||
|
||||
@pytest.fixture(scope='class')
|
||||
def inline_query_result_cached_gif():
|
||||
return InlineQueryResultCachedGif(TestInlineQueryResultCachedGif.id,
|
||||
TestInlineQueryResultCachedGif.gif_file_id,
|
||||
title=TestInlineQueryResultCachedGif.title,
|
||||
caption=TestInlineQueryResultCachedGif.caption,
|
||||
parse_mode=TestInlineQueryResultCachedGif.parse_mode,
|
||||
input_message_content=TestInlineQueryResultCachedGif.input_message_content,
|
||||
reply_markup=TestInlineQueryResultCachedGif.reply_markup)
|
||||
return InlineQueryResultCachedGif(
|
||||
TestInlineQueryResultCachedGif.id,
|
||||
TestInlineQueryResultCachedGif.gif_file_id,
|
||||
title=TestInlineQueryResultCachedGif.title,
|
||||
caption=TestInlineQueryResultCachedGif.caption,
|
||||
parse_mode=TestInlineQueryResultCachedGif.parse_mode,
|
||||
input_message_content=TestInlineQueryResultCachedGif.input_message_content,
|
||||
reply_markup=TestInlineQueryResultCachedGif.reply_markup)
|
||||
|
||||
|
||||
class TestInlineQueryResultCachedGif(object):
|
||||
|
@ -51,8 +52,8 @@ class TestInlineQueryResultCachedGif(object):
|
|||
assert inline_query_result_cached_gif.title == self.title
|
||||
assert inline_query_result_cached_gif.caption == self.caption
|
||||
assert inline_query_result_cached_gif.parse_mode == self.parse_mode
|
||||
assert inline_query_result_cached_gif.input_message_content.to_dict() == \
|
||||
self.input_message_content.to_dict()
|
||||
assert (inline_query_result_cached_gif.input_message_content.to_dict() ==
|
||||
self.input_message_content.to_dict())
|
||||
assert inline_query_result_cached_gif.reply_markup.to_dict() == self.reply_markup.to_dict()
|
||||
|
||||
def test_to_dict(self, inline_query_result_cached_gif):
|
||||
|
@ -61,17 +62,17 @@ class TestInlineQueryResultCachedGif(object):
|
|||
assert isinstance(inline_query_result_cached_gif_dict, dict)
|
||||
assert inline_query_result_cached_gif_dict['type'] == inline_query_result_cached_gif.type
|
||||
assert inline_query_result_cached_gif_dict['id'] == inline_query_result_cached_gif.id
|
||||
assert inline_query_result_cached_gif_dict['gif_file_id'] == \
|
||||
inline_query_result_cached_gif.gif_file_id
|
||||
assert (inline_query_result_cached_gif_dict['gif_file_id'] ==
|
||||
inline_query_result_cached_gif.gif_file_id)
|
||||
assert inline_query_result_cached_gif_dict['title'] == inline_query_result_cached_gif.title
|
||||
assert inline_query_result_cached_gif_dict['caption'] == \
|
||||
inline_query_result_cached_gif.caption
|
||||
assert inline_query_result_cached_gif_dict['parse_mode'] == \
|
||||
inline_query_result_cached_gif.parse_mode
|
||||
assert inline_query_result_cached_gif_dict['input_message_content'] == \
|
||||
inline_query_result_cached_gif.input_message_content.to_dict()
|
||||
assert inline_query_result_cached_gif_dict['reply_markup'] == \
|
||||
inline_query_result_cached_gif.reply_markup.to_dict()
|
||||
assert (inline_query_result_cached_gif_dict['caption'] ==
|
||||
inline_query_result_cached_gif.caption)
|
||||
assert (inline_query_result_cached_gif_dict['parse_mode'] ==
|
||||
inline_query_result_cached_gif.parse_mode)
|
||||
assert (inline_query_result_cached_gif_dict['input_message_content'] ==
|
||||
inline_query_result_cached_gif.input_message_content.to_dict())
|
||||
assert (inline_query_result_cached_gif_dict['reply_markup'] ==
|
||||
inline_query_result_cached_gif.reply_markup.to_dict())
|
||||
|
||||
def test_equality(self):
|
||||
a = InlineQueryResultCachedGif(self.id, self.gif_file_id)
|
||||
|
|
|
@ -25,13 +25,14 @@ from telegram import (InlineQueryResultCachedMpeg4Gif, InlineKeyboardButton,
|
|||
|
||||
@pytest.fixture(scope='class')
|
||||
def inline_query_result_cached_mpeg4_gif():
|
||||
return InlineQueryResultCachedMpeg4Gif(TestInlineQueryResultCachedMpeg4Gif.id,
|
||||
TestInlineQueryResultCachedMpeg4Gif.mpeg4_file_id,
|
||||
title=TestInlineQueryResultCachedMpeg4Gif.title,
|
||||
caption=TestInlineQueryResultCachedMpeg4Gif.caption,
|
||||
parse_mode=TestInlineQueryResultCachedMpeg4Gif.parse_mode,
|
||||
input_message_content=TestInlineQueryResultCachedMpeg4Gif.input_message_content,
|
||||
reply_markup=TestInlineQueryResultCachedMpeg4Gif.reply_markup)
|
||||
return InlineQueryResultCachedMpeg4Gif(
|
||||
TestInlineQueryResultCachedMpeg4Gif.id,
|
||||
TestInlineQueryResultCachedMpeg4Gif.mpeg4_file_id,
|
||||
title=TestInlineQueryResultCachedMpeg4Gif.title,
|
||||
caption=TestInlineQueryResultCachedMpeg4Gif.caption,
|
||||
parse_mode=TestInlineQueryResultCachedMpeg4Gif.parse_mode,
|
||||
input_message_content=TestInlineQueryResultCachedMpeg4Gif.input_message_content,
|
||||
reply_markup=TestInlineQueryResultCachedMpeg4Gif.reply_markup)
|
||||
|
||||
|
||||
class TestInlineQueryResultCachedMpeg4Gif(object):
|
||||
|
@ -51,31 +52,31 @@ class TestInlineQueryResultCachedMpeg4Gif(object):
|
|||
assert inline_query_result_cached_mpeg4_gif.title == self.title
|
||||
assert inline_query_result_cached_mpeg4_gif.caption == self.caption
|
||||
assert inline_query_result_cached_mpeg4_gif.parse_mode == self.parse_mode
|
||||
assert inline_query_result_cached_mpeg4_gif.input_message_content.to_dict() == \
|
||||
self.input_message_content.to_dict()
|
||||
assert inline_query_result_cached_mpeg4_gif.reply_markup.to_dict() == \
|
||||
self.reply_markup.to_dict()
|
||||
assert (inline_query_result_cached_mpeg4_gif.input_message_content.to_dict() ==
|
||||
self.input_message_content.to_dict())
|
||||
assert (inline_query_result_cached_mpeg4_gif.reply_markup.to_dict() ==
|
||||
self.reply_markup.to_dict())
|
||||
|
||||
def test_to_dict(self, inline_query_result_cached_mpeg4_gif):
|
||||
inline_query_result_cached_mpeg4_gif_dict = inline_query_result_cached_mpeg4_gif.to_dict()
|
||||
|
||||
assert isinstance(inline_query_result_cached_mpeg4_gif_dict, dict)
|
||||
assert inline_query_result_cached_mpeg4_gif_dict['type'] == \
|
||||
inline_query_result_cached_mpeg4_gif.type
|
||||
assert inline_query_result_cached_mpeg4_gif_dict['id'] == \
|
||||
inline_query_result_cached_mpeg4_gif.id
|
||||
assert inline_query_result_cached_mpeg4_gif_dict['mpeg4_file_id'] == \
|
||||
inline_query_result_cached_mpeg4_gif.mpeg4_file_id
|
||||
assert inline_query_result_cached_mpeg4_gif_dict['title'] == \
|
||||
inline_query_result_cached_mpeg4_gif.title
|
||||
assert inline_query_result_cached_mpeg4_gif_dict['caption'] == \
|
||||
inline_query_result_cached_mpeg4_gif.caption
|
||||
assert inline_query_result_cached_mpeg4_gif_dict['parse_mode'] == \
|
||||
inline_query_result_cached_mpeg4_gif.parse_mode
|
||||
assert inline_query_result_cached_mpeg4_gif_dict['input_message_content'] == \
|
||||
inline_query_result_cached_mpeg4_gif.input_message_content.to_dict()
|
||||
assert inline_query_result_cached_mpeg4_gif_dict['reply_markup'] == \
|
||||
inline_query_result_cached_mpeg4_gif.reply_markup.to_dict()
|
||||
assert (inline_query_result_cached_mpeg4_gif_dict['type'] ==
|
||||
inline_query_result_cached_mpeg4_gif.type)
|
||||
assert (inline_query_result_cached_mpeg4_gif_dict['id'] ==
|
||||
inline_query_result_cached_mpeg4_gif.id)
|
||||
assert (inline_query_result_cached_mpeg4_gif_dict['mpeg4_file_id'] ==
|
||||
inline_query_result_cached_mpeg4_gif.mpeg4_file_id)
|
||||
assert (inline_query_result_cached_mpeg4_gif_dict['title'] ==
|
||||
inline_query_result_cached_mpeg4_gif.title)
|
||||
assert (inline_query_result_cached_mpeg4_gif_dict['caption'] ==
|
||||
inline_query_result_cached_mpeg4_gif.caption)
|
||||
assert (inline_query_result_cached_mpeg4_gif_dict['parse_mode'] ==
|
||||
inline_query_result_cached_mpeg4_gif.parse_mode)
|
||||
assert (inline_query_result_cached_mpeg4_gif_dict['input_message_content'] ==
|
||||
inline_query_result_cached_mpeg4_gif.input_message_content.to_dict())
|
||||
assert (inline_query_result_cached_mpeg4_gif_dict['reply_markup'] ==
|
||||
inline_query_result_cached_mpeg4_gif.reply_markup.to_dict())
|
||||
|
||||
def test_equality(self):
|
||||
a = InlineQueryResultCachedMpeg4Gif(self.id, self.mpeg4_file_id)
|
||||
|
|
|
@ -25,14 +25,15 @@ from telegram import (InputTextMessageContent, InlineQueryResultCachedPhoto, Inl
|
|||
|
||||
@pytest.fixture(scope='class')
|
||||
def inline_query_result_cached_photo():
|
||||
return InlineQueryResultCachedPhoto(TestInlineQueryResultCachedPhoto.id,
|
||||
TestInlineQueryResultCachedPhoto.photo_file_id,
|
||||
title=TestInlineQueryResultCachedPhoto.title,
|
||||
description=TestInlineQueryResultCachedPhoto.description,
|
||||
caption=TestInlineQueryResultCachedPhoto.caption,
|
||||
parse_mode=TestInlineQueryResultCachedPhoto.parse_mode,
|
||||
input_message_content=TestInlineQueryResultCachedPhoto.input_message_content,
|
||||
reply_markup=TestInlineQueryResultCachedPhoto.reply_markup)
|
||||
return InlineQueryResultCachedPhoto(
|
||||
TestInlineQueryResultCachedPhoto.id,
|
||||
TestInlineQueryResultCachedPhoto.photo_file_id,
|
||||
title=TestInlineQueryResultCachedPhoto.title,
|
||||
description=TestInlineQueryResultCachedPhoto.description,
|
||||
caption=TestInlineQueryResultCachedPhoto.caption,
|
||||
parse_mode=TestInlineQueryResultCachedPhoto.parse_mode,
|
||||
input_message_content=TestInlineQueryResultCachedPhoto.input_message_content,
|
||||
reply_markup=TestInlineQueryResultCachedPhoto.reply_markup)
|
||||
|
||||
|
||||
class TestInlineQueryResultCachedPhoto(object):
|
||||
|
@ -54,32 +55,32 @@ class TestInlineQueryResultCachedPhoto(object):
|
|||
assert inline_query_result_cached_photo.description == self.description
|
||||
assert inline_query_result_cached_photo.caption == self.caption
|
||||
assert inline_query_result_cached_photo.parse_mode == self.parse_mode
|
||||
assert inline_query_result_cached_photo.input_message_content.to_dict() == \
|
||||
self.input_message_content.to_dict()
|
||||
assert inline_query_result_cached_photo.reply_markup.to_dict() == \
|
||||
self.reply_markup.to_dict()
|
||||
assert (inline_query_result_cached_photo.input_message_content.to_dict() ==
|
||||
self.input_message_content.to_dict())
|
||||
assert (inline_query_result_cached_photo.reply_markup.to_dict() ==
|
||||
self.reply_markup.to_dict())
|
||||
|
||||
def test_to_dict(self, inline_query_result_cached_photo):
|
||||
inline_query_result_cached_photo_dict = inline_query_result_cached_photo.to_dict()
|
||||
|
||||
assert isinstance(inline_query_result_cached_photo_dict, dict)
|
||||
assert inline_query_result_cached_photo_dict['type'] == \
|
||||
inline_query_result_cached_photo.type
|
||||
assert (inline_query_result_cached_photo_dict['type'] ==
|
||||
inline_query_result_cached_photo.type)
|
||||
assert inline_query_result_cached_photo_dict['id'] == inline_query_result_cached_photo.id
|
||||
assert inline_query_result_cached_photo_dict['photo_file_id'] == \
|
||||
inline_query_result_cached_photo.photo_file_id
|
||||
assert inline_query_result_cached_photo_dict['title'] == \
|
||||
inline_query_result_cached_photo.title
|
||||
assert inline_query_result_cached_photo_dict['description'] == \
|
||||
inline_query_result_cached_photo.description
|
||||
assert inline_query_result_cached_photo_dict['caption'] == \
|
||||
inline_query_result_cached_photo.caption
|
||||
assert inline_query_result_cached_photo_dict['parse_mode'] == \
|
||||
inline_query_result_cached_photo.parse_mode
|
||||
assert inline_query_result_cached_photo_dict['input_message_content'] == \
|
||||
inline_query_result_cached_photo.input_message_content.to_dict()
|
||||
assert inline_query_result_cached_photo_dict['reply_markup'] == \
|
||||
inline_query_result_cached_photo.reply_markup.to_dict()
|
||||
assert (inline_query_result_cached_photo_dict['photo_file_id'] ==
|
||||
inline_query_result_cached_photo.photo_file_id)
|
||||
assert (inline_query_result_cached_photo_dict['title'] ==
|
||||
inline_query_result_cached_photo.title)
|
||||
assert (inline_query_result_cached_photo_dict['description'] ==
|
||||
inline_query_result_cached_photo.description)
|
||||
assert (inline_query_result_cached_photo_dict['caption'] ==
|
||||
inline_query_result_cached_photo.caption)
|
||||
assert (inline_query_result_cached_photo_dict['parse_mode'] ==
|
||||
inline_query_result_cached_photo.parse_mode)
|
||||
assert (inline_query_result_cached_photo_dict['input_message_content'] ==
|
||||
inline_query_result_cached_photo.input_message_content.to_dict())
|
||||
assert (inline_query_result_cached_photo_dict['reply_markup'] ==
|
||||
inline_query_result_cached_photo.reply_markup.to_dict())
|
||||
|
||||
def test_equality(self):
|
||||
a = InlineQueryResultCachedPhoto(self.id, self.photo_file_id)
|
||||
|
|
|
@ -26,10 +26,11 @@ from telegram import (InputTextMessageContent, InlineKeyboardButton,
|
|||
|
||||
@pytest.fixture(scope='class')
|
||||
def inline_query_result_cached_sticker():
|
||||
return InlineQueryResultCachedSticker(TestInlineQueryResultCachedSticker.id,
|
||||
TestInlineQueryResultCachedSticker.sticker_file_id,
|
||||
input_message_content=TestInlineQueryResultCachedSticker.input_message_content,
|
||||
reply_markup=TestInlineQueryResultCachedSticker.reply_markup)
|
||||
return InlineQueryResultCachedSticker(
|
||||
TestInlineQueryResultCachedSticker.id,
|
||||
TestInlineQueryResultCachedSticker.sticker_file_id,
|
||||
input_message_content=TestInlineQueryResultCachedSticker.input_message_content,
|
||||
reply_markup=TestInlineQueryResultCachedSticker.reply_markup)
|
||||
|
||||
|
||||
class TestInlineQueryResultCachedSticker(object):
|
||||
|
@ -43,25 +44,25 @@ class TestInlineQueryResultCachedSticker(object):
|
|||
assert inline_query_result_cached_sticker.type == self.type
|
||||
assert inline_query_result_cached_sticker.id == self.id
|
||||
assert inline_query_result_cached_sticker.sticker_file_id == self.sticker_file_id
|
||||
assert inline_query_result_cached_sticker.input_message_content.to_dict() == \
|
||||
self.input_message_content.to_dict()
|
||||
assert inline_query_result_cached_sticker.reply_markup.to_dict() == \
|
||||
self.reply_markup.to_dict()
|
||||
assert (inline_query_result_cached_sticker.input_message_content.to_dict() ==
|
||||
self.input_message_content.to_dict())
|
||||
assert (inline_query_result_cached_sticker.reply_markup.to_dict() ==
|
||||
self.reply_markup.to_dict())
|
||||
|
||||
def test_to_dict(self, inline_query_result_cached_sticker):
|
||||
inline_query_result_cached_sticker_dict = inline_query_result_cached_sticker.to_dict()
|
||||
|
||||
assert isinstance(inline_query_result_cached_sticker_dict, dict)
|
||||
assert inline_query_result_cached_sticker_dict['type'] == \
|
||||
inline_query_result_cached_sticker.type
|
||||
assert inline_query_result_cached_sticker_dict['id'] == \
|
||||
inline_query_result_cached_sticker.id
|
||||
assert inline_query_result_cached_sticker_dict['sticker_file_id'] == \
|
||||
inline_query_result_cached_sticker.sticker_file_id
|
||||
assert inline_query_result_cached_sticker_dict['input_message_content'] == \
|
||||
inline_query_result_cached_sticker.input_message_content.to_dict()
|
||||
assert inline_query_result_cached_sticker_dict['reply_markup'] == \
|
||||
inline_query_result_cached_sticker.reply_markup.to_dict()
|
||||
assert (inline_query_result_cached_sticker_dict['type'] ==
|
||||
inline_query_result_cached_sticker.type)
|
||||
assert (inline_query_result_cached_sticker_dict['id'] ==
|
||||
inline_query_result_cached_sticker.id)
|
||||
assert (inline_query_result_cached_sticker_dict['sticker_file_id'] ==
|
||||
inline_query_result_cached_sticker.sticker_file_id)
|
||||
assert (inline_query_result_cached_sticker_dict['input_message_content'] ==
|
||||
inline_query_result_cached_sticker.input_message_content.to_dict())
|
||||
assert (inline_query_result_cached_sticker_dict['reply_markup'] ==
|
||||
inline_query_result_cached_sticker.reply_markup.to_dict())
|
||||
|
||||
def test_equality(self):
|
||||
a = InlineQueryResultCachedSticker(self.id, self.sticker_file_id)
|
||||
|
|
|
@ -25,14 +25,15 @@ from telegram import (InlineKeyboardMarkup, InlineKeyboardButton, InputTextMessa
|
|||
|
||||
@pytest.fixture(scope='class')
|
||||
def inline_query_result_cached_video():
|
||||
return InlineQueryResultCachedVideo(TestInlineQueryResultCachedVideo.id,
|
||||
TestInlineQueryResultCachedVideo.video_file_id,
|
||||
TestInlineQueryResultCachedVideo.title,
|
||||
caption=TestInlineQueryResultCachedVideo.caption,
|
||||
parse_mode=TestInlineQueryResultCachedVideo.parse_mode,
|
||||
description=TestInlineQueryResultCachedVideo.description,
|
||||
input_message_content=TestInlineQueryResultCachedVideo.input_message_content,
|
||||
reply_markup=TestInlineQueryResultCachedVideo.reply_markup)
|
||||
return InlineQueryResultCachedVideo(
|
||||
TestInlineQueryResultCachedVideo.id,
|
||||
TestInlineQueryResultCachedVideo.video_file_id,
|
||||
TestInlineQueryResultCachedVideo.title,
|
||||
caption=TestInlineQueryResultCachedVideo.caption,
|
||||
parse_mode=TestInlineQueryResultCachedVideo.parse_mode,
|
||||
description=TestInlineQueryResultCachedVideo.description,
|
||||
input_message_content=TestInlineQueryResultCachedVideo.input_message_content,
|
||||
reply_markup=TestInlineQueryResultCachedVideo.reply_markup)
|
||||
|
||||
|
||||
class TestInlineQueryResultCachedVideo(object):
|
||||
|
@ -54,32 +55,32 @@ class TestInlineQueryResultCachedVideo(object):
|
|||
assert inline_query_result_cached_video.description == self.description
|
||||
assert inline_query_result_cached_video.caption == self.caption
|
||||
assert inline_query_result_cached_video.parse_mode == self.parse_mode
|
||||
assert inline_query_result_cached_video.input_message_content.to_dict() == \
|
||||
self.input_message_content.to_dict()
|
||||
assert inline_query_result_cached_video.reply_markup.to_dict() == \
|
||||
self.reply_markup.to_dict()
|
||||
assert (inline_query_result_cached_video.input_message_content.to_dict() ==
|
||||
self.input_message_content.to_dict())
|
||||
assert (inline_query_result_cached_video.reply_markup.to_dict() ==
|
||||
self.reply_markup.to_dict())
|
||||
|
||||
def test_to_dict(self, inline_query_result_cached_video):
|
||||
inline_query_result_cached_video_dict = inline_query_result_cached_video.to_dict()
|
||||
|
||||
assert isinstance(inline_query_result_cached_video_dict, dict)
|
||||
assert inline_query_result_cached_video_dict['type'] == \
|
||||
inline_query_result_cached_video.type
|
||||
assert (inline_query_result_cached_video_dict['type'] ==
|
||||
inline_query_result_cached_video.type)
|
||||
assert inline_query_result_cached_video_dict['id'] == inline_query_result_cached_video.id
|
||||
assert inline_query_result_cached_video_dict['video_file_id'] == \
|
||||
inline_query_result_cached_video.video_file_id
|
||||
assert inline_query_result_cached_video_dict['title'] == \
|
||||
inline_query_result_cached_video.title
|
||||
assert inline_query_result_cached_video_dict['description'] == \
|
||||
inline_query_result_cached_video.description
|
||||
assert inline_query_result_cached_video_dict['caption'] == \
|
||||
inline_query_result_cached_video.caption
|
||||
assert inline_query_result_cached_video_dict['parse_mode'] == \
|
||||
inline_query_result_cached_video.parse_mode
|
||||
assert inline_query_result_cached_video_dict['input_message_content'] == \
|
||||
inline_query_result_cached_video.input_message_content.to_dict()
|
||||
assert inline_query_result_cached_video_dict['reply_markup'] == \
|
||||
inline_query_result_cached_video.reply_markup.to_dict()
|
||||
assert (inline_query_result_cached_video_dict['video_file_id'] ==
|
||||
inline_query_result_cached_video.video_file_id)
|
||||
assert (inline_query_result_cached_video_dict['title'] ==
|
||||
inline_query_result_cached_video.title)
|
||||
assert (inline_query_result_cached_video_dict['description'] ==
|
||||
inline_query_result_cached_video.description)
|
||||
assert (inline_query_result_cached_video_dict['caption'] ==
|
||||
inline_query_result_cached_video.caption)
|
||||
assert (inline_query_result_cached_video_dict['parse_mode'] ==
|
||||
inline_query_result_cached_video.parse_mode)
|
||||
assert (inline_query_result_cached_video_dict['input_message_content'] ==
|
||||
inline_query_result_cached_video.input_message_content.to_dict())
|
||||
assert (inline_query_result_cached_video_dict['reply_markup'] ==
|
||||
inline_query_result_cached_video.reply_markup.to_dict())
|
||||
|
||||
def test_equality(self):
|
||||
a = InlineQueryResultCachedVideo(self.id, self.video_file_id, self.title)
|
||||
|
|
|
@ -25,13 +25,14 @@ from telegram import (InlineQueryResultCachedVoice, InlineKeyboardButton, Inline
|
|||
|
||||
@pytest.fixture(scope='class')
|
||||
def inline_query_result_cached_voice():
|
||||
return InlineQueryResultCachedVoice(TestInlineQueryResultCachedVoice.id,
|
||||
TestInlineQueryResultCachedVoice.voice_file_id,
|
||||
TestInlineQueryResultCachedVoice.title,
|
||||
caption=TestInlineQueryResultCachedVoice.caption,
|
||||
parse_mode=TestInlineQueryResultCachedVoice.parse_mode,
|
||||
input_message_content=TestInlineQueryResultCachedVoice.input_message_content,
|
||||
reply_markup=TestInlineQueryResultCachedVoice.reply_markup)
|
||||
return InlineQueryResultCachedVoice(
|
||||
TestInlineQueryResultCachedVoice.id,
|
||||
TestInlineQueryResultCachedVoice.voice_file_id,
|
||||
TestInlineQueryResultCachedVoice.title,
|
||||
caption=TestInlineQueryResultCachedVoice.caption,
|
||||
parse_mode=TestInlineQueryResultCachedVoice.parse_mode,
|
||||
input_message_content=TestInlineQueryResultCachedVoice.input_message_content,
|
||||
reply_markup=TestInlineQueryResultCachedVoice.reply_markup)
|
||||
|
||||
|
||||
class TestInlineQueryResultCachedVoice(object):
|
||||
|
@ -51,30 +52,30 @@ class TestInlineQueryResultCachedVoice(object):
|
|||
assert inline_query_result_cached_voice.title == self.title
|
||||
assert inline_query_result_cached_voice.caption == self.caption
|
||||
assert inline_query_result_cached_voice.parse_mode == self.parse_mode
|
||||
assert inline_query_result_cached_voice.input_message_content.to_dict() == \
|
||||
self.input_message_content.to_dict()
|
||||
assert inline_query_result_cached_voice.reply_markup.to_dict() == \
|
||||
self.reply_markup.to_dict()
|
||||
assert (inline_query_result_cached_voice.input_message_content.to_dict() ==
|
||||
self.input_message_content.to_dict())
|
||||
assert (inline_query_result_cached_voice.reply_markup.to_dict() ==
|
||||
self.reply_markup.to_dict())
|
||||
|
||||
def test_to_dict(self, inline_query_result_cached_voice):
|
||||
inline_query_result_cached_voice_dict = inline_query_result_cached_voice.to_dict()
|
||||
|
||||
assert isinstance(inline_query_result_cached_voice_dict, dict)
|
||||
assert inline_query_result_cached_voice_dict['type'] == \
|
||||
inline_query_result_cached_voice.type
|
||||
assert (inline_query_result_cached_voice_dict['type'] ==
|
||||
inline_query_result_cached_voice.type)
|
||||
assert inline_query_result_cached_voice_dict['id'] == inline_query_result_cached_voice.id
|
||||
assert inline_query_result_cached_voice_dict['voice_file_id'] == \
|
||||
inline_query_result_cached_voice.voice_file_id
|
||||
assert inline_query_result_cached_voice_dict['title'] == \
|
||||
inline_query_result_cached_voice.title
|
||||
assert inline_query_result_cached_voice_dict['caption'] == \
|
||||
inline_query_result_cached_voice.caption
|
||||
assert inline_query_result_cached_voice_dict['parse_mode'] == \
|
||||
inline_query_result_cached_voice.parse_mode
|
||||
assert inline_query_result_cached_voice_dict['input_message_content'] == \
|
||||
inline_query_result_cached_voice.input_message_content.to_dict()
|
||||
assert inline_query_result_cached_voice_dict['reply_markup'] == \
|
||||
inline_query_result_cached_voice.reply_markup.to_dict()
|
||||
assert (inline_query_result_cached_voice_dict['voice_file_id'] ==
|
||||
inline_query_result_cached_voice.voice_file_id)
|
||||
assert (inline_query_result_cached_voice_dict['title'] ==
|
||||
inline_query_result_cached_voice.title)
|
||||
assert (inline_query_result_cached_voice_dict['caption'] ==
|
||||
inline_query_result_cached_voice.caption)
|
||||
assert (inline_query_result_cached_voice_dict['parse_mode'] ==
|
||||
inline_query_result_cached_voice.parse_mode)
|
||||
assert (inline_query_result_cached_voice_dict['input_message_content'] ==
|
||||
inline_query_result_cached_voice.input_message_content.to_dict())
|
||||
assert (inline_query_result_cached_voice_dict['reply_markup'] ==
|
||||
inline_query_result_cached_voice.reply_markup.to_dict())
|
||||
|
||||
def test_equality(self):
|
||||
a = InlineQueryResultCachedVoice(self.id, self.voice_file_id, self.title)
|
||||
|
|
|
@ -25,15 +25,16 @@ from telegram import (InlineQueryResultVoice, InputTextMessageContent, InlineKey
|
|||
|
||||
@pytest.fixture(scope='class')
|
||||
def inline_query_result_contact():
|
||||
return InlineQueryResultContact(TestInlineQueryResultContact.id,
|
||||
TestInlineQueryResultContact.phone_number,
|
||||
TestInlineQueryResultContact.first_name,
|
||||
last_name=TestInlineQueryResultContact.last_name,
|
||||
thumb_url=TestInlineQueryResultContact.thumb_url,
|
||||
thumb_width=TestInlineQueryResultContact.thumb_width,
|
||||
thumb_height=TestInlineQueryResultContact.thumb_height,
|
||||
input_message_content=TestInlineQueryResultContact.input_message_content,
|
||||
reply_markup=TestInlineQueryResultContact.reply_markup)
|
||||
return InlineQueryResultContact(
|
||||
TestInlineQueryResultContact.id,
|
||||
TestInlineQueryResultContact.phone_number,
|
||||
TestInlineQueryResultContact.first_name,
|
||||
last_name=TestInlineQueryResultContact.last_name,
|
||||
thumb_url=TestInlineQueryResultContact.thumb_url,
|
||||
thumb_width=TestInlineQueryResultContact.thumb_width,
|
||||
thumb_height=TestInlineQueryResultContact.thumb_height,
|
||||
input_message_content=TestInlineQueryResultContact.input_message_content,
|
||||
reply_markup=TestInlineQueryResultContact.reply_markup)
|
||||
|
||||
|
||||
class TestInlineQueryResultContact(object):
|
||||
|
@ -57,8 +58,8 @@ class TestInlineQueryResultContact(object):
|
|||
assert inline_query_result_contact.thumb_url == self.thumb_url
|
||||
assert inline_query_result_contact.thumb_width == self.thumb_width
|
||||
assert inline_query_result_contact.thumb_height == self.thumb_height
|
||||
assert inline_query_result_contact.input_message_content.to_dict() == \
|
||||
self.input_message_content.to_dict()
|
||||
assert (inline_query_result_contact.input_message_content.to_dict() ==
|
||||
self.input_message_content.to_dict())
|
||||
assert inline_query_result_contact.reply_markup.to_dict() == self.reply_markup.to_dict()
|
||||
|
||||
def test_to_dict(self, inline_query_result_contact):
|
||||
|
@ -67,22 +68,22 @@ class TestInlineQueryResultContact(object):
|
|||
assert isinstance(inline_query_result_contact_dict, dict)
|
||||
assert inline_query_result_contact_dict['id'] == inline_query_result_contact.id
|
||||
assert inline_query_result_contact_dict['type'] == inline_query_result_contact.type
|
||||
assert inline_query_result_contact_dict['phone_number'] == \
|
||||
inline_query_result_contact.phone_number
|
||||
assert inline_query_result_contact_dict['first_name'] == \
|
||||
inline_query_result_contact.first_name
|
||||
assert inline_query_result_contact_dict['last_name'] == \
|
||||
inline_query_result_contact.last_name
|
||||
assert inline_query_result_contact_dict['thumb_url'] == \
|
||||
inline_query_result_contact.thumb_url
|
||||
assert inline_query_result_contact_dict['thumb_width'] == \
|
||||
inline_query_result_contact.thumb_width
|
||||
assert inline_query_result_contact_dict['thumb_height'] == \
|
||||
inline_query_result_contact.thumb_height
|
||||
assert inline_query_result_contact_dict['input_message_content'] == \
|
||||
inline_query_result_contact.input_message_content.to_dict()
|
||||
assert inline_query_result_contact_dict['reply_markup'] == \
|
||||
inline_query_result_contact.reply_markup.to_dict()
|
||||
assert (inline_query_result_contact_dict['phone_number'] ==
|
||||
inline_query_result_contact.phone_number)
|
||||
assert (inline_query_result_contact_dict['first_name'] ==
|
||||
inline_query_result_contact.first_name)
|
||||
assert (inline_query_result_contact_dict['last_name'] ==
|
||||
inline_query_result_contact.last_name)
|
||||
assert (inline_query_result_contact_dict['thumb_url'] ==
|
||||
inline_query_result_contact.thumb_url)
|
||||
assert (inline_query_result_contact_dict['thumb_width'] ==
|
||||
inline_query_result_contact.thumb_width)
|
||||
assert (inline_query_result_contact_dict['thumb_height'] ==
|
||||
inline_query_result_contact.thumb_height)
|
||||
assert (inline_query_result_contact_dict['input_message_content'] ==
|
||||
inline_query_result_contact.input_message_content.to_dict())
|
||||
assert (inline_query_result_contact_dict['reply_markup'] ==
|
||||
inline_query_result_contact.reply_markup.to_dict())
|
||||
|
||||
def test_equality(self):
|
||||
a = InlineQueryResultContact(self.id, self.phone_number, self.first_name)
|
||||
|
|
|
@ -25,18 +25,19 @@ from telegram import (InlineKeyboardButton, InputTextMessageContent, InlineQuery
|
|||
|
||||
@pytest.fixture(scope='class')
|
||||
def inline_query_result_document():
|
||||
return InlineQueryResultDocument(TestInlineQueryResultDocument.id,
|
||||
TestInlineQueryResultDocument.document_url,
|
||||
TestInlineQueryResultDocument.title,
|
||||
TestInlineQueryResultDocument.mime_type,
|
||||
caption=TestInlineQueryResultDocument.caption,
|
||||
parse_mode=TestInlineQueryResultDocument.parse_mode,
|
||||
description=TestInlineQueryResultDocument.description,
|
||||
thumb_url=TestInlineQueryResultDocument.thumb_url,
|
||||
thumb_width=TestInlineQueryResultDocument.thumb_width,
|
||||
thumb_height=TestInlineQueryResultDocument.thumb_height,
|
||||
input_message_content=TestInlineQueryResultDocument.input_message_content,
|
||||
reply_markup=TestInlineQueryResultDocument.reply_markup)
|
||||
return InlineQueryResultDocument(
|
||||
TestInlineQueryResultDocument.id,
|
||||
TestInlineQueryResultDocument.document_url,
|
||||
TestInlineQueryResultDocument.title,
|
||||
TestInlineQueryResultDocument.mime_type,
|
||||
caption=TestInlineQueryResultDocument.caption,
|
||||
parse_mode=TestInlineQueryResultDocument.parse_mode,
|
||||
description=TestInlineQueryResultDocument.description,
|
||||
thumb_url=TestInlineQueryResultDocument.thumb_url,
|
||||
thumb_width=TestInlineQueryResultDocument.thumb_width,
|
||||
thumb_height=TestInlineQueryResultDocument.thumb_height,
|
||||
input_message_content=TestInlineQueryResultDocument.input_message_content,
|
||||
reply_markup=TestInlineQueryResultDocument.reply_markup)
|
||||
|
||||
|
||||
class TestInlineQueryResultDocument(object):
|
||||
|
@ -66,8 +67,8 @@ class TestInlineQueryResultDocument(object):
|
|||
assert inline_query_result_document.thumb_url == self.thumb_url
|
||||
assert inline_query_result_document.thumb_width == self.thumb_width
|
||||
assert inline_query_result_document.thumb_height == self.thumb_height
|
||||
assert inline_query_result_document.input_message_content.to_dict() == \
|
||||
self.input_message_content.to_dict()
|
||||
assert (inline_query_result_document.input_message_content.to_dict() ==
|
||||
self.input_message_content.to_dict())
|
||||
assert inline_query_result_document.reply_markup.to_dict() == self.reply_markup.to_dict()
|
||||
|
||||
def test_to_dict(self, inline_query_result_document):
|
||||
|
@ -76,26 +77,26 @@ class TestInlineQueryResultDocument(object):
|
|||
assert isinstance(inline_query_result_document_dict, dict)
|
||||
assert inline_query_result_document_dict['id'] == inline_query_result_document.id
|
||||
assert inline_query_result_document_dict['type'] == inline_query_result_document.type
|
||||
assert inline_query_result_document_dict['document_url'] == \
|
||||
inline_query_result_document.document_url
|
||||
assert (inline_query_result_document_dict['document_url'] ==
|
||||
inline_query_result_document.document_url)
|
||||
assert inline_query_result_document_dict['title'] == inline_query_result_document.title
|
||||
assert inline_query_result_document_dict['caption'] == inline_query_result_document.caption
|
||||
assert inline_query_result_document_dict['parse_mode'] == \
|
||||
inline_query_result_document.parse_mode
|
||||
assert inline_query_result_document_dict['mime_type'] == \
|
||||
inline_query_result_document.mime_type
|
||||
assert inline_query_result_document_dict['description'] == \
|
||||
inline_query_result_document.description
|
||||
assert inline_query_result_document_dict['thumb_url'] == \
|
||||
inline_query_result_document.thumb_url
|
||||
assert inline_query_result_document_dict['thumb_width'] == \
|
||||
inline_query_result_document.thumb_width
|
||||
assert inline_query_result_document_dict['thumb_height'] == \
|
||||
inline_query_result_document.thumb_height
|
||||
assert inline_query_result_document_dict['input_message_content'] == \
|
||||
inline_query_result_document.input_message_content.to_dict()
|
||||
assert inline_query_result_document_dict['reply_markup'] == \
|
||||
inline_query_result_document.reply_markup.to_dict()
|
||||
assert (inline_query_result_document_dict['parse_mode'] ==
|
||||
inline_query_result_document.parse_mode)
|
||||
assert (inline_query_result_document_dict['mime_type'] ==
|
||||
inline_query_result_document.mime_type)
|
||||
assert (inline_query_result_document_dict['description'] ==
|
||||
inline_query_result_document.description)
|
||||
assert (inline_query_result_document_dict['thumb_url'] ==
|
||||
inline_query_result_document.thumb_url)
|
||||
assert (inline_query_result_document_dict['thumb_width'] ==
|
||||
inline_query_result_document.thumb_width)
|
||||
assert (inline_query_result_document_dict['thumb_height'] ==
|
||||
inline_query_result_document.thumb_height)
|
||||
assert (inline_query_result_document_dict['input_message_content'] ==
|
||||
inline_query_result_document.input_message_content.to_dict())
|
||||
assert (inline_query_result_document_dict['reply_markup'] ==
|
||||
inline_query_result_document.reply_markup.to_dict())
|
||||
|
||||
def test_equality(self):
|
||||
a = InlineQueryResultDocument(self.id, self.document_url, self.title,
|
||||
|
|
|
@ -40,8 +40,8 @@ class TestInlineQueryResultGame(object):
|
|||
assert inline_query_result_game.type == self.type
|
||||
assert inline_query_result_game.id == self.id
|
||||
assert inline_query_result_game.game_short_name == self.game_short_name
|
||||
assert inline_query_result_game.reply_markup.to_dict() == \
|
||||
self.reply_markup.to_dict()
|
||||
assert (inline_query_result_game.reply_markup.to_dict() ==
|
||||
self.reply_markup.to_dict())
|
||||
|
||||
def test_to_dict(self, inline_query_result_game):
|
||||
inline_query_result_game_dict = inline_query_result_game.to_dict()
|
||||
|
@ -49,10 +49,10 @@ class TestInlineQueryResultGame(object):
|
|||
assert isinstance(inline_query_result_game_dict, dict)
|
||||
assert inline_query_result_game_dict['type'] == inline_query_result_game.type
|
||||
assert inline_query_result_game_dict['id'] == inline_query_result_game.id
|
||||
assert inline_query_result_game_dict['game_short_name'] == \
|
||||
inline_query_result_game.game_short_name
|
||||
assert inline_query_result_game_dict['reply_markup'] == \
|
||||
inline_query_result_game.reply_markup.to_dict()
|
||||
assert (inline_query_result_game_dict['game_short_name'] ==
|
||||
inline_query_result_game.game_short_name)
|
||||
assert (inline_query_result_game_dict['reply_markup'] ==
|
||||
inline_query_result_game.reply_markup.to_dict())
|
||||
|
||||
def test_equality(self):
|
||||
a = InlineQueryResultGame(self.id, self.game_short_name)
|
||||
|
|
|
@ -25,17 +25,18 @@ from telegram import (InlineKeyboardButton, InputTextMessageContent, InlineQuery
|
|||
|
||||
@pytest.fixture(scope='class')
|
||||
def inline_query_result_gif():
|
||||
return InlineQueryResultGif(TestInlineQueryResultGif.id,
|
||||
TestInlineQueryResultGif.gif_url,
|
||||
TestInlineQueryResultGif.thumb_url,
|
||||
gif_width=TestInlineQueryResultGif.gif_width,
|
||||
gif_height=TestInlineQueryResultGif.gif_height,
|
||||
gif_duration=TestInlineQueryResultGif.gif_duration,
|
||||
title=TestInlineQueryResultGif.title,
|
||||
caption=TestInlineQueryResultGif.caption,
|
||||
parse_mode=TestInlineQueryResultGif.parse_mode,
|
||||
input_message_content=TestInlineQueryResultGif.input_message_content,
|
||||
reply_markup=TestInlineQueryResultGif.reply_markup)
|
||||
return InlineQueryResultGif(
|
||||
TestInlineQueryResultGif.id,
|
||||
TestInlineQueryResultGif.gif_url,
|
||||
TestInlineQueryResultGif.thumb_url,
|
||||
gif_width=TestInlineQueryResultGif.gif_width,
|
||||
gif_height=TestInlineQueryResultGif.gif_height,
|
||||
gif_duration=TestInlineQueryResultGif.gif_duration,
|
||||
title=TestInlineQueryResultGif.title,
|
||||
caption=TestInlineQueryResultGif.caption,
|
||||
parse_mode=TestInlineQueryResultGif.parse_mode,
|
||||
input_message_content=TestInlineQueryResultGif.input_message_content,
|
||||
reply_markup=TestInlineQueryResultGif.reply_markup)
|
||||
|
||||
|
||||
class TestInlineQueryResultGif(object):
|
||||
|
@ -63,8 +64,8 @@ class TestInlineQueryResultGif(object):
|
|||
assert inline_query_result_gif.title == self.title
|
||||
assert inline_query_result_gif.caption == self.caption
|
||||
assert inline_query_result_gif.parse_mode == self.parse_mode
|
||||
assert inline_query_result_gif.input_message_content.to_dict() == \
|
||||
self.input_message_content.to_dict()
|
||||
assert (inline_query_result_gif.input_message_content.to_dict() ==
|
||||
self.input_message_content.to_dict())
|
||||
assert inline_query_result_gif.reply_markup.to_dict() == self.reply_markup.to_dict()
|
||||
|
||||
def test_to_dict(self, inline_query_result_gif):
|
||||
|
@ -81,10 +82,10 @@ class TestInlineQueryResultGif(object):
|
|||
assert inline_query_result_gif_dict['title'] == inline_query_result_gif.title
|
||||
assert inline_query_result_gif_dict['caption'] == inline_query_result_gif.caption
|
||||
assert inline_query_result_gif_dict['parse_mode'] == inline_query_result_gif.parse_mode
|
||||
assert inline_query_result_gif_dict['input_message_content'] == \
|
||||
inline_query_result_gif.input_message_content.to_dict()
|
||||
assert inline_query_result_gif_dict['reply_markup'] == \
|
||||
inline_query_result_gif.reply_markup.to_dict()
|
||||
assert (inline_query_result_gif_dict['input_message_content'] ==
|
||||
inline_query_result_gif.input_message_content.to_dict())
|
||||
assert (inline_query_result_gif_dict['reply_markup'] ==
|
||||
inline_query_result_gif.reply_markup.to_dict())
|
||||
|
||||
def test_equality(self):
|
||||
a = InlineQueryResultGif(self.id, self.gif_url, self.thumb_url)
|
||||
|
|
|
@ -25,16 +25,17 @@ from telegram import (InputTextMessageContent, InlineQueryResultLocation, Inline
|
|||
|
||||
@pytest.fixture(scope='class')
|
||||
def inline_query_result_location():
|
||||
return InlineQueryResultLocation(TestInlineQueryResultLocation.id,
|
||||
TestInlineQueryResultLocation.latitude,
|
||||
TestInlineQueryResultLocation.longitude,
|
||||
TestInlineQueryResultLocation.title,
|
||||
live_period=TestInlineQueryResultLocation.live_period,
|
||||
thumb_url=TestInlineQueryResultLocation.thumb_url,
|
||||
thumb_width=TestInlineQueryResultLocation.thumb_width,
|
||||
thumb_height=TestInlineQueryResultLocation.thumb_height,
|
||||
input_message_content=TestInlineQueryResultLocation.input_message_content,
|
||||
reply_markup=TestInlineQueryResultLocation.reply_markup)
|
||||
return InlineQueryResultLocation(
|
||||
TestInlineQueryResultLocation.id,
|
||||
TestInlineQueryResultLocation.latitude,
|
||||
TestInlineQueryResultLocation.longitude,
|
||||
TestInlineQueryResultLocation.title,
|
||||
live_period=TestInlineQueryResultLocation.live_period,
|
||||
thumb_url=TestInlineQueryResultLocation.thumb_url,
|
||||
thumb_width=TestInlineQueryResultLocation.thumb_width,
|
||||
thumb_height=TestInlineQueryResultLocation.thumb_height,
|
||||
input_message_content=TestInlineQueryResultLocation.input_message_content,
|
||||
reply_markup=TestInlineQueryResultLocation.reply_markup)
|
||||
|
||||
|
||||
class TestInlineQueryResultLocation(object):
|
||||
|
@ -60,8 +61,8 @@ class TestInlineQueryResultLocation(object):
|
|||
assert inline_query_result_location.thumb_url == self.thumb_url
|
||||
assert inline_query_result_location.thumb_width == self.thumb_width
|
||||
assert inline_query_result_location.thumb_height == self.thumb_height
|
||||
assert inline_query_result_location.input_message_content.to_dict() == \
|
||||
self.input_message_content.to_dict()
|
||||
assert (inline_query_result_location.input_message_content.to_dict() ==
|
||||
self.input_message_content.to_dict())
|
||||
assert inline_query_result_location.reply_markup.to_dict() == self.reply_markup.to_dict()
|
||||
|
||||
def test_to_dict(self, inline_query_result_location):
|
||||
|
@ -70,23 +71,23 @@ class TestInlineQueryResultLocation(object):
|
|||
assert isinstance(inline_query_result_location_dict, dict)
|
||||
assert inline_query_result_location_dict['id'] == inline_query_result_location.id
|
||||
assert inline_query_result_location_dict['type'] == inline_query_result_location.type
|
||||
assert inline_query_result_location_dict['latitude'] == \
|
||||
inline_query_result_location.latitude
|
||||
assert inline_query_result_location_dict['longitude'] == \
|
||||
inline_query_result_location.longitude
|
||||
assert (inline_query_result_location_dict['latitude'] ==
|
||||
inline_query_result_location.latitude)
|
||||
assert (inline_query_result_location_dict['longitude'] ==
|
||||
inline_query_result_location.longitude)
|
||||
assert inline_query_result_location_dict['title'] == inline_query_result_location.title
|
||||
assert inline_query_result_location_dict[
|
||||
'live_period'] == inline_query_result_location.live_period
|
||||
assert inline_query_result_location_dict['thumb_url'] == \
|
||||
inline_query_result_location.thumb_url
|
||||
assert inline_query_result_location_dict['thumb_width'] == \
|
||||
inline_query_result_location.thumb_width
|
||||
assert inline_query_result_location_dict['thumb_height'] == \
|
||||
inline_query_result_location.thumb_height
|
||||
assert inline_query_result_location_dict['input_message_content'] == \
|
||||
inline_query_result_location.input_message_content.to_dict()
|
||||
assert inline_query_result_location_dict['reply_markup'] == \
|
||||
inline_query_result_location.reply_markup.to_dict()
|
||||
assert (inline_query_result_location_dict['live_period'] ==
|
||||
inline_query_result_location.live_period)
|
||||
assert (inline_query_result_location_dict['thumb_url'] ==
|
||||
inline_query_result_location.thumb_url)
|
||||
assert (inline_query_result_location_dict['thumb_width'] ==
|
||||
inline_query_result_location.thumb_width)
|
||||
assert (inline_query_result_location_dict['thumb_height'] ==
|
||||
inline_query_result_location.thumb_height)
|
||||
assert (inline_query_result_location_dict['input_message_content'] ==
|
||||
inline_query_result_location.input_message_content.to_dict())
|
||||
assert (inline_query_result_location_dict['reply_markup'] ==
|
||||
inline_query_result_location.reply_markup.to_dict())
|
||||
|
||||
def test_equality(self):
|
||||
a = InlineQueryResultLocation(self.id, self.longitude, self.latitude, self.title)
|
||||
|
|
|
@ -25,17 +25,18 @@ from telegram import (InlineQueryResultMpeg4Gif, InlineKeyboardButton, InlineQue
|
|||
|
||||
@pytest.fixture(scope='class')
|
||||
def inline_query_result_mpeg4_gif():
|
||||
return InlineQueryResultMpeg4Gif(TestInlineQueryResultMpeg4Gif.id,
|
||||
TestInlineQueryResultMpeg4Gif.mpeg4_url,
|
||||
TestInlineQueryResultMpeg4Gif.thumb_url,
|
||||
mpeg4_width=TestInlineQueryResultMpeg4Gif.mpeg4_width,
|
||||
mpeg4_height=TestInlineQueryResultMpeg4Gif.mpeg4_height,
|
||||
mpeg4_duration=TestInlineQueryResultMpeg4Gif.mpeg4_duration,
|
||||
title=TestInlineQueryResultMpeg4Gif.title,
|
||||
caption=TestInlineQueryResultMpeg4Gif.caption,
|
||||
parse_mode=TestInlineQueryResultMpeg4Gif.parse_mode,
|
||||
input_message_content=TestInlineQueryResultMpeg4Gif.input_message_content,
|
||||
reply_markup=TestInlineQueryResultMpeg4Gif.reply_markup)
|
||||
return InlineQueryResultMpeg4Gif(
|
||||
TestInlineQueryResultMpeg4Gif.id,
|
||||
TestInlineQueryResultMpeg4Gif.mpeg4_url,
|
||||
TestInlineQueryResultMpeg4Gif.thumb_url,
|
||||
mpeg4_width=TestInlineQueryResultMpeg4Gif.mpeg4_width,
|
||||
mpeg4_height=TestInlineQueryResultMpeg4Gif.mpeg4_height,
|
||||
mpeg4_duration=TestInlineQueryResultMpeg4Gif.mpeg4_duration,
|
||||
title=TestInlineQueryResultMpeg4Gif.title,
|
||||
caption=TestInlineQueryResultMpeg4Gif.caption,
|
||||
parse_mode=TestInlineQueryResultMpeg4Gif.parse_mode,
|
||||
input_message_content=TestInlineQueryResultMpeg4Gif.input_message_content,
|
||||
reply_markup=TestInlineQueryResultMpeg4Gif.reply_markup)
|
||||
|
||||
|
||||
class TestInlineQueryResultMpeg4Gif(object):
|
||||
|
@ -63,8 +64,8 @@ class TestInlineQueryResultMpeg4Gif(object):
|
|||
assert inline_query_result_mpeg4_gif.title == self.title
|
||||
assert inline_query_result_mpeg4_gif.caption == self.caption
|
||||
assert inline_query_result_mpeg4_gif.parse_mode == self.parse_mode
|
||||
assert inline_query_result_mpeg4_gif.input_message_content.to_dict() == \
|
||||
self.input_message_content.to_dict()
|
||||
assert (inline_query_result_mpeg4_gif.input_message_content.to_dict() ==
|
||||
self.input_message_content.to_dict())
|
||||
assert inline_query_result_mpeg4_gif.reply_markup.to_dict() == self.reply_markup.to_dict()
|
||||
|
||||
def test_to_dict(self, inline_query_result_mpeg4_gif):
|
||||
|
@ -73,25 +74,25 @@ class TestInlineQueryResultMpeg4Gif(object):
|
|||
assert isinstance(inline_query_result_mpeg4_gif_dict, dict)
|
||||
assert inline_query_result_mpeg4_gif_dict['type'] == inline_query_result_mpeg4_gif.type
|
||||
assert inline_query_result_mpeg4_gif_dict['id'] == inline_query_result_mpeg4_gif.id
|
||||
assert inline_query_result_mpeg4_gif_dict['mpeg4_url'] == \
|
||||
inline_query_result_mpeg4_gif.mpeg4_url
|
||||
assert inline_query_result_mpeg4_gif_dict['mpeg4_width'] == \
|
||||
inline_query_result_mpeg4_gif.mpeg4_width
|
||||
assert inline_query_result_mpeg4_gif_dict['mpeg4_height'] == \
|
||||
inline_query_result_mpeg4_gif.mpeg4_height
|
||||
assert inline_query_result_mpeg4_gif_dict['mpeg4_duration'] == \
|
||||
inline_query_result_mpeg4_gif.mpeg4_duration
|
||||
assert inline_query_result_mpeg4_gif_dict['thumb_url'] == \
|
||||
inline_query_result_mpeg4_gif.thumb_url
|
||||
assert (inline_query_result_mpeg4_gif_dict['mpeg4_url'] ==
|
||||
inline_query_result_mpeg4_gif.mpeg4_url)
|
||||
assert (inline_query_result_mpeg4_gif_dict['mpeg4_width'] ==
|
||||
inline_query_result_mpeg4_gif.mpeg4_width)
|
||||
assert (inline_query_result_mpeg4_gif_dict['mpeg4_height'] ==
|
||||
inline_query_result_mpeg4_gif.mpeg4_height)
|
||||
assert (inline_query_result_mpeg4_gif_dict['mpeg4_duration'] ==
|
||||
inline_query_result_mpeg4_gif.mpeg4_duration)
|
||||
assert (inline_query_result_mpeg4_gif_dict['thumb_url'] ==
|
||||
inline_query_result_mpeg4_gif.thumb_url)
|
||||
assert inline_query_result_mpeg4_gif_dict['title'] == inline_query_result_mpeg4_gif.title
|
||||
assert inline_query_result_mpeg4_gif_dict['caption'] == \
|
||||
inline_query_result_mpeg4_gif.caption
|
||||
assert inline_query_result_mpeg4_gif_dict['parse_mode'] == \
|
||||
inline_query_result_mpeg4_gif.parse_mode
|
||||
assert inline_query_result_mpeg4_gif_dict['input_message_content'] == \
|
||||
inline_query_result_mpeg4_gif.input_message_content.to_dict()
|
||||
assert inline_query_result_mpeg4_gif_dict['reply_markup'] == \
|
||||
inline_query_result_mpeg4_gif.reply_markup.to_dict()
|
||||
assert (inline_query_result_mpeg4_gif_dict['caption'] ==
|
||||
inline_query_result_mpeg4_gif.caption)
|
||||
assert (inline_query_result_mpeg4_gif_dict['parse_mode'] ==
|
||||
inline_query_result_mpeg4_gif.parse_mode)
|
||||
assert (inline_query_result_mpeg4_gif_dict['input_message_content'] ==
|
||||
inline_query_result_mpeg4_gif.input_message_content.to_dict())
|
||||
assert (inline_query_result_mpeg4_gif_dict['reply_markup'] ==
|
||||
inline_query_result_mpeg4_gif.reply_markup.to_dict())
|
||||
|
||||
def test_equality(self):
|
||||
a = InlineQueryResultMpeg4Gif(self.id, self.mpeg4_url, self.thumb_url)
|
||||
|
|
|
@ -25,17 +25,18 @@ from telegram import (InputTextMessageContent, InlineKeyboardButton, InlineKeybo
|
|||
|
||||
@pytest.fixture(scope='class')
|
||||
def inline_query_result_photo():
|
||||
return InlineQueryResultPhoto(TestInlineQueryResultPhoto.id,
|
||||
TestInlineQueryResultPhoto.photo_url,
|
||||
TestInlineQueryResultPhoto.thumb_url,
|
||||
photo_width=TestInlineQueryResultPhoto.photo_width,
|
||||
photo_height=TestInlineQueryResultPhoto.photo_height,
|
||||
title=TestInlineQueryResultPhoto.title,
|
||||
description=TestInlineQueryResultPhoto.description,
|
||||
caption=TestInlineQueryResultPhoto.caption,
|
||||
parse_mode=TestInlineQueryResultPhoto.parse_mode,
|
||||
input_message_content=TestInlineQueryResultPhoto.input_message_content,
|
||||
reply_markup=TestInlineQueryResultPhoto.reply_markup)
|
||||
return InlineQueryResultPhoto(
|
||||
TestInlineQueryResultPhoto.id,
|
||||
TestInlineQueryResultPhoto.photo_url,
|
||||
TestInlineQueryResultPhoto.thumb_url,
|
||||
photo_width=TestInlineQueryResultPhoto.photo_width,
|
||||
photo_height=TestInlineQueryResultPhoto.photo_height,
|
||||
title=TestInlineQueryResultPhoto.title,
|
||||
description=TestInlineQueryResultPhoto.description,
|
||||
caption=TestInlineQueryResultPhoto.caption,
|
||||
parse_mode=TestInlineQueryResultPhoto.parse_mode,
|
||||
input_message_content=TestInlineQueryResultPhoto.input_message_content,
|
||||
reply_markup=TestInlineQueryResultPhoto.reply_markup)
|
||||
|
||||
|
||||
class TestInlineQueryResultPhoto(object):
|
||||
|
@ -63,8 +64,8 @@ class TestInlineQueryResultPhoto(object):
|
|||
assert inline_query_result_photo.description == self.description
|
||||
assert inline_query_result_photo.caption == self.caption
|
||||
assert inline_query_result_photo.parse_mode == self.parse_mode
|
||||
assert inline_query_result_photo.input_message_content.to_dict() == \
|
||||
self.input_message_content.to_dict()
|
||||
assert (inline_query_result_photo.input_message_content.to_dict() ==
|
||||
self.input_message_content.to_dict())
|
||||
assert inline_query_result_photo.reply_markup.to_dict() == self.reply_markup.to_dict()
|
||||
|
||||
def test_to_dict(self, inline_query_result_photo):
|
||||
|
@ -74,20 +75,20 @@ class TestInlineQueryResultPhoto(object):
|
|||
assert inline_query_result_photo_dict['type'] == inline_query_result_photo.type
|
||||
assert inline_query_result_photo_dict['id'] == inline_query_result_photo.id
|
||||
assert inline_query_result_photo_dict['photo_url'] == inline_query_result_photo.photo_url
|
||||
assert inline_query_result_photo_dict['photo_width'] == \
|
||||
inline_query_result_photo.photo_width
|
||||
assert inline_query_result_photo_dict['photo_height'] == \
|
||||
inline_query_result_photo.photo_height
|
||||
assert (inline_query_result_photo_dict['photo_width'] ==
|
||||
inline_query_result_photo.photo_width)
|
||||
assert (inline_query_result_photo_dict['photo_height'] ==
|
||||
inline_query_result_photo.photo_height)
|
||||
assert inline_query_result_photo_dict['thumb_url'] == inline_query_result_photo.thumb_url
|
||||
assert inline_query_result_photo_dict['title'] == inline_query_result_photo.title
|
||||
assert inline_query_result_photo_dict['description'] == \
|
||||
inline_query_result_photo.description
|
||||
assert (inline_query_result_photo_dict['description'] ==
|
||||
inline_query_result_photo.description)
|
||||
assert inline_query_result_photo_dict['caption'] == inline_query_result_photo.caption
|
||||
assert inline_query_result_photo_dict['parse_mode'] == inline_query_result_photo.parse_mode
|
||||
assert inline_query_result_photo_dict['input_message_content'] == \
|
||||
inline_query_result_photo.input_message_content.to_dict()
|
||||
assert inline_query_result_photo_dict['reply_markup'] == \
|
||||
inline_query_result_photo.reply_markup.to_dict()
|
||||
assert (inline_query_result_photo_dict['input_message_content'] ==
|
||||
inline_query_result_photo.input_message_content.to_dict())
|
||||
assert (inline_query_result_photo_dict['reply_markup'] ==
|
||||
inline_query_result_photo.reply_markup.to_dict())
|
||||
|
||||
def test_equality(self):
|
||||
a = InlineQueryResultPhoto(self.id, self.photo_url, self.thumb_url)
|
||||
|
|
|
@ -25,17 +25,18 @@ from telegram import (InlineQueryResultVoice, InputTextMessageContent, InlineKey
|
|||
|
||||
@pytest.fixture(scope='class')
|
||||
def inline_query_result_venue():
|
||||
return InlineQueryResultVenue(TestInlineQueryResultVenue.id,
|
||||
TestInlineQueryResultVenue.latitude,
|
||||
TestInlineQueryResultVenue.longitude,
|
||||
TestInlineQueryResultVenue.title,
|
||||
TestInlineQueryResultVenue.address,
|
||||
foursquare_id=TestInlineQueryResultVenue.foursquare_id,
|
||||
thumb_url=TestInlineQueryResultVenue.thumb_url,
|
||||
thumb_width=TestInlineQueryResultVenue.thumb_width,
|
||||
thumb_height=TestInlineQueryResultVenue.thumb_height,
|
||||
input_message_content=TestInlineQueryResultVenue.input_message_content,
|
||||
reply_markup=TestInlineQueryResultVenue.reply_markup)
|
||||
return InlineQueryResultVenue(
|
||||
TestInlineQueryResultVenue.id,
|
||||
TestInlineQueryResultVenue.latitude,
|
||||
TestInlineQueryResultVenue.longitude,
|
||||
TestInlineQueryResultVenue.title,
|
||||
TestInlineQueryResultVenue.address,
|
||||
foursquare_id=TestInlineQueryResultVenue.foursquare_id,
|
||||
thumb_url=TestInlineQueryResultVenue.thumb_url,
|
||||
thumb_width=TestInlineQueryResultVenue.thumb_width,
|
||||
thumb_height=TestInlineQueryResultVenue.thumb_height,
|
||||
input_message_content=TestInlineQueryResultVenue.input_message_content,
|
||||
reply_markup=TestInlineQueryResultVenue.reply_markup)
|
||||
|
||||
|
||||
class TestInlineQueryResultVenue(object):
|
||||
|
@ -63,8 +64,8 @@ class TestInlineQueryResultVenue(object):
|
|||
assert inline_query_result_venue.thumb_url == self.thumb_url
|
||||
assert inline_query_result_venue.thumb_width == self.thumb_width
|
||||
assert inline_query_result_venue.thumb_height == self.thumb_height
|
||||
assert inline_query_result_venue.input_message_content.to_dict() == \
|
||||
self.input_message_content.to_dict()
|
||||
assert (inline_query_result_venue.input_message_content.to_dict() ==
|
||||
self.input_message_content.to_dict())
|
||||
assert inline_query_result_venue.reply_markup.to_dict() == self.reply_markup.to_dict()
|
||||
|
||||
def test_to_dict(self, inline_query_result_venue):
|
||||
|
@ -77,17 +78,17 @@ class TestInlineQueryResultVenue(object):
|
|||
assert inline_query_result_venue_dict['longitude'] == inline_query_result_venue.longitude
|
||||
assert inline_query_result_venue_dict['title'] == inline_query_result_venue.title
|
||||
assert inline_query_result_venue_dict['address'] == inline_query_result_venue.address
|
||||
assert inline_query_result_venue_dict['foursquare_id'] == \
|
||||
inline_query_result_venue.foursquare_id
|
||||
assert (inline_query_result_venue_dict['foursquare_id'] ==
|
||||
inline_query_result_venue.foursquare_id)
|
||||
assert inline_query_result_venue_dict['thumb_url'] == inline_query_result_venue.thumb_url
|
||||
assert inline_query_result_venue_dict['thumb_width'] == \
|
||||
inline_query_result_venue.thumb_width
|
||||
assert inline_query_result_venue_dict['thumb_height'] == \
|
||||
inline_query_result_venue.thumb_height
|
||||
assert inline_query_result_venue_dict['input_message_content'] == \
|
||||
inline_query_result_venue.input_message_content.to_dict()
|
||||
assert inline_query_result_venue_dict['reply_markup'] == \
|
||||
inline_query_result_venue.reply_markup.to_dict()
|
||||
assert (inline_query_result_venue_dict['thumb_width'] ==
|
||||
inline_query_result_venue.thumb_width)
|
||||
assert (inline_query_result_venue_dict['thumb_height'] ==
|
||||
inline_query_result_venue.thumb_height)
|
||||
assert (inline_query_result_venue_dict['input_message_content'] ==
|
||||
inline_query_result_venue.input_message_content.to_dict())
|
||||
assert (inline_query_result_venue_dict['reply_markup'] ==
|
||||
inline_query_result_venue.reply_markup.to_dict())
|
||||
|
||||
def test_equality(self):
|
||||
a = InlineQueryResultVenue(self.id, self.longitude, self.latitude, self.title,
|
||||
|
|
|
@ -25,19 +25,20 @@ from telegram import (InlineKeyboardButton, InputTextMessageContent, InlineQuery
|
|||
|
||||
@pytest.fixture(scope='class')
|
||||
def inline_query_result_video():
|
||||
return InlineQueryResultVideo(TestInlineQueryResultVideo.id,
|
||||
TestInlineQueryResultVideo.video_url,
|
||||
TestInlineQueryResultVideo.mime_type,
|
||||
TestInlineQueryResultVideo.thumb_url,
|
||||
TestInlineQueryResultVideo.title,
|
||||
video_width=TestInlineQueryResultVideo.video_width,
|
||||
video_height=TestInlineQueryResultVideo.video_height,
|
||||
video_duration=TestInlineQueryResultVideo.video_duration,
|
||||
caption=TestInlineQueryResultVideo.caption,
|
||||
parse_mode=TestInlineQueryResultVideo.parse_mode,
|
||||
description=TestInlineQueryResultVideo.description,
|
||||
input_message_content=TestInlineQueryResultVideo.input_message_content,
|
||||
reply_markup=TestInlineQueryResultVideo.reply_markup)
|
||||
return InlineQueryResultVideo(
|
||||
TestInlineQueryResultVideo.id,
|
||||
TestInlineQueryResultVideo.video_url,
|
||||
TestInlineQueryResultVideo.mime_type,
|
||||
TestInlineQueryResultVideo.thumb_url,
|
||||
TestInlineQueryResultVideo.title,
|
||||
video_width=TestInlineQueryResultVideo.video_width,
|
||||
video_height=TestInlineQueryResultVideo.video_height,
|
||||
video_duration=TestInlineQueryResultVideo.video_duration,
|
||||
caption=TestInlineQueryResultVideo.caption,
|
||||
parse_mode=TestInlineQueryResultVideo.parse_mode,
|
||||
description=TestInlineQueryResultVideo.description,
|
||||
input_message_content=TestInlineQueryResultVideo.input_message_content,
|
||||
reply_markup=TestInlineQueryResultVideo.reply_markup)
|
||||
|
||||
|
||||
class TestInlineQueryResultVideo(object):
|
||||
|
@ -69,8 +70,8 @@ class TestInlineQueryResultVideo(object):
|
|||
assert inline_query_result_video.description == self.description
|
||||
assert inline_query_result_video.caption == self.caption
|
||||
assert inline_query_result_video.parse_mode == self.parse_mode
|
||||
assert inline_query_result_video.input_message_content.to_dict() == \
|
||||
self.input_message_content.to_dict()
|
||||
assert (inline_query_result_video.input_message_content.to_dict() ==
|
||||
self.input_message_content.to_dict())
|
||||
assert inline_query_result_video.reply_markup.to_dict() == self.reply_markup.to_dict()
|
||||
|
||||
def test_to_dict(self, inline_query_result_video):
|
||||
|
@ -81,22 +82,22 @@ class TestInlineQueryResultVideo(object):
|
|||
assert inline_query_result_video_dict['id'] == inline_query_result_video.id
|
||||
assert inline_query_result_video_dict['video_url'] == inline_query_result_video.video_url
|
||||
assert inline_query_result_video_dict['mime_type'] == inline_query_result_video.mime_type
|
||||
assert inline_query_result_video_dict['video_width'] == \
|
||||
inline_query_result_video.video_width
|
||||
assert inline_query_result_video_dict['video_height'] == \
|
||||
inline_query_result_video.video_height
|
||||
assert inline_query_result_video_dict['video_duration'] == \
|
||||
inline_query_result_video.video_duration
|
||||
assert (inline_query_result_video_dict['video_width'] ==
|
||||
inline_query_result_video.video_width)
|
||||
assert (inline_query_result_video_dict['video_height'] ==
|
||||
inline_query_result_video.video_height)
|
||||
assert (inline_query_result_video_dict['video_duration'] ==
|
||||
inline_query_result_video.video_duration)
|
||||
assert inline_query_result_video_dict['thumb_url'] == inline_query_result_video.thumb_url
|
||||
assert inline_query_result_video_dict['title'] == inline_query_result_video.title
|
||||
assert inline_query_result_video_dict['description'] == \
|
||||
inline_query_result_video.description
|
||||
assert (inline_query_result_video_dict['description'] ==
|
||||
inline_query_result_video.description)
|
||||
assert inline_query_result_video_dict['caption'] == inline_query_result_video.caption
|
||||
assert inline_query_result_video_dict['parse_mode'] == inline_query_result_video.parse_mode
|
||||
assert inline_query_result_video_dict['input_message_content'] == \
|
||||
inline_query_result_video.input_message_content.to_dict()
|
||||
assert inline_query_result_video_dict['reply_markup'] == \
|
||||
inline_query_result_video.reply_markup.to_dict()
|
||||
assert (inline_query_result_video_dict['input_message_content'] ==
|
||||
inline_query_result_video.input_message_content.to_dict())
|
||||
assert (inline_query_result_video_dict['reply_markup'] ==
|
||||
inline_query_result_video.reply_markup.to_dict())
|
||||
|
||||
def test_equality(self):
|
||||
a = InlineQueryResultVideo(self.id, self.video_url, self.mime_type,
|
||||
|
|
|
@ -25,15 +25,16 @@ from telegram import (InlineKeyboardButton, InputTextMessageContent, InlineQuery
|
|||
|
||||
@pytest.fixture(scope='class')
|
||||
def inline_query_result_voice():
|
||||
return InlineQueryResultVoice(type=TestInlineQueryResultVoice.type,
|
||||
id=TestInlineQueryResultVoice.id,
|
||||
voice_url=TestInlineQueryResultVoice.voice_url,
|
||||
title=TestInlineQueryResultVoice.title,
|
||||
voice_duration=TestInlineQueryResultVoice.voice_duration,
|
||||
caption=TestInlineQueryResultVoice.caption,
|
||||
parse_mode=TestInlineQueryResultVoice.parse_mode,
|
||||
input_message_content=TestInlineQueryResultVoice.input_message_content,
|
||||
reply_markup=TestInlineQueryResultVoice.reply_markup)
|
||||
return InlineQueryResultVoice(
|
||||
type=TestInlineQueryResultVoice.type,
|
||||
id=TestInlineQueryResultVoice.id,
|
||||
voice_url=TestInlineQueryResultVoice.voice_url,
|
||||
title=TestInlineQueryResultVoice.title,
|
||||
voice_duration=TestInlineQueryResultVoice.voice_duration,
|
||||
caption=TestInlineQueryResultVoice.caption,
|
||||
parse_mode=TestInlineQueryResultVoice.parse_mode,
|
||||
input_message_content=TestInlineQueryResultVoice.input_message_content,
|
||||
reply_markup=TestInlineQueryResultVoice.reply_markup)
|
||||
|
||||
|
||||
class TestInlineQueryResultVoice(object):
|
||||
|
@ -55,8 +56,8 @@ class TestInlineQueryResultVoice(object):
|
|||
assert inline_query_result_voice.voice_duration == self.voice_duration
|
||||
assert inline_query_result_voice.caption == self.caption
|
||||
assert inline_query_result_voice.parse_mode == self.parse_mode
|
||||
assert inline_query_result_voice.input_message_content.to_dict() == \
|
||||
self.input_message_content.to_dict()
|
||||
assert (inline_query_result_voice.input_message_content.to_dict() ==
|
||||
self.input_message_content.to_dict())
|
||||
assert inline_query_result_voice.reply_markup.to_dict() == self.reply_markup.to_dict()
|
||||
|
||||
def test_to_dict(self, inline_query_result_voice):
|
||||
|
@ -67,14 +68,14 @@ class TestInlineQueryResultVoice(object):
|
|||
assert inline_query_result_voice_dict['id'] == inline_query_result_voice.id
|
||||
assert inline_query_result_voice_dict['voice_url'] == inline_query_result_voice.voice_url
|
||||
assert inline_query_result_voice_dict['title'] == inline_query_result_voice.title
|
||||
assert inline_query_result_voice_dict['voice_duration'] == \
|
||||
inline_query_result_voice.voice_duration
|
||||
assert (inline_query_result_voice_dict['voice_duration'] ==
|
||||
inline_query_result_voice.voice_duration)
|
||||
assert inline_query_result_voice_dict['caption'] == inline_query_result_voice.caption
|
||||
assert inline_query_result_voice_dict['parse_mode'] == inline_query_result_voice.parse_mode
|
||||
assert inline_query_result_voice_dict['input_message_content'] == \
|
||||
inline_query_result_voice.input_message_content.to_dict()
|
||||
assert inline_query_result_voice_dict['reply_markup'] == \
|
||||
inline_query_result_voice.reply_markup.to_dict()
|
||||
assert (inline_query_result_voice_dict['input_message_content'] ==
|
||||
inline_query_result_voice.input_message_content.to_dict())
|
||||
assert (inline_query_result_voice_dict['reply_markup'] ==
|
||||
inline_query_result_voice.reply_markup.to_dict())
|
||||
|
||||
def test_equality(self):
|
||||
a = InlineQueryResultVoice(self.id, self.voice_url, self.title)
|
||||
|
|
|
@ -43,9 +43,9 @@ class TestInputContactMessageContent(object):
|
|||
input_contact_message_content_dict = input_contact_message_content.to_dict()
|
||||
|
||||
assert isinstance(input_contact_message_content_dict, dict)
|
||||
assert input_contact_message_content_dict['phone_number'] == \
|
||||
input_contact_message_content.phone_number
|
||||
assert input_contact_message_content_dict['first_name'] == \
|
||||
input_contact_message_content.first_name
|
||||
assert input_contact_message_content_dict['last_name'] == \
|
||||
input_contact_message_content.last_name
|
||||
assert (input_contact_message_content_dict['phone_number'] ==
|
||||
input_contact_message_content.phone_number)
|
||||
assert (input_contact_message_content_dict['first_name'] ==
|
||||
input_contact_message_content.first_name)
|
||||
assert (input_contact_message_content_dict['last_name'] ==
|
||||
input_contact_message_content.last_name)
|
||||
|
|
|
@ -43,9 +43,9 @@ class TestInputLocationMessageContent(object):
|
|||
input_location_message_content_dict = input_location_message_content.to_dict()
|
||||
|
||||
assert isinstance(input_location_message_content_dict, dict)
|
||||
assert input_location_message_content_dict['latitude'] == \
|
||||
input_location_message_content.latitude
|
||||
assert input_location_message_content_dict['longitude'] == \
|
||||
input_location_message_content.longitude
|
||||
assert input_location_message_content_dict[
|
||||
'live_period'] == input_location_message_content.live_period
|
||||
assert (input_location_message_content_dict['latitude'] ==
|
||||
input_location_message_content.latitude)
|
||||
assert (input_location_message_content_dict['longitude'] ==
|
||||
input_location_message_content.longitude)
|
||||
assert (input_location_message_content_dict['live_period'] ==
|
||||
input_location_message_content.live_period)
|
||||
|
|
|
@ -20,8 +20,8 @@ import pytest
|
|||
from flaky import flaky
|
||||
|
||||
from telegram import InputMediaVideo, InputMediaPhoto, Message
|
||||
from .test_video import video, video_file
|
||||
from .test_photo import _photo, photo_file, photo, thumb
|
||||
from .test_video import video, video_file # noqa: F401
|
||||
from .test_photo import _photo, photo_file, photo, thumb # noqa: F401
|
||||
|
||||
|
||||
@pytest.fixture(scope='class')
|
||||
|
@ -73,7 +73,7 @@ class TestInputMediaVideo(object):
|
|||
assert input_media_video_dict['parse_mode'] == input_media_video.parse_mode
|
||||
assert input_media_video_dict['supports_streaming'] == input_media_video.supports_streaming
|
||||
|
||||
def test_with_video(self, video):
|
||||
def test_with_video(self, video): # noqa: F811
|
||||
# fixture found in test_video
|
||||
input_media_video = InputMediaVideo(video, caption="test 3")
|
||||
assert input_media_video.type == self.type
|
||||
|
@ -83,7 +83,7 @@ class TestInputMediaVideo(object):
|
|||
assert input_media_video.duration == video.duration
|
||||
assert input_media_video.caption == "test 3"
|
||||
|
||||
def test_error_with_file(self, video_file):
|
||||
def test_error_with_file(self, video_file): # noqa: F811
|
||||
# fixture found in test_video
|
||||
with pytest.raises(ValueError, match="file_id, url or Video"):
|
||||
InputMediaVideo(video_file)
|
||||
|
@ -108,20 +108,20 @@ class TestInputMediaPhoto(object):
|
|||
assert input_media_photo_dict['caption'] == input_media_photo.caption
|
||||
assert input_media_photo_dict['parse_mode'] == input_media_photo.parse_mode
|
||||
|
||||
def test_with_photo(self, photo):
|
||||
def test_with_photo(self, photo): # noqa: F811
|
||||
# fixture found in test_photo
|
||||
imp = InputMediaPhoto(photo, caption="test 2")
|
||||
assert imp.type == self.type
|
||||
assert imp.media == photo.file_id
|
||||
assert imp.caption == "test 2"
|
||||
|
||||
def test_error_with_file(self, photo_file):
|
||||
def test_error_with_file(self, photo_file): # noqa: F811
|
||||
# fixture found in test_photo
|
||||
with pytest.raises(ValueError, match="file_id, url or PhotoSize"):
|
||||
InputMediaPhoto(photo_file)
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
@pytest.fixture(scope='function') # noqa: F811
|
||||
def media_group(photo, thumb):
|
||||
return [InputMediaPhoto(photo, caption='photo `1`', parse_mode='Markdown'),
|
||||
InputMediaPhoto(thumb, caption='<b>photo</b> 2', parse_mode='HTML')]
|
||||
|
|
|
@ -24,9 +24,10 @@ from telegram import InputTextMessageContent, ParseMode
|
|||
|
||||
@pytest.fixture(scope='class')
|
||||
def input_text_message_content():
|
||||
return InputTextMessageContent(TestInputTextMessageContent.message_text,
|
||||
parse_mode=TestInputTextMessageContent.parse_mode,
|
||||
disable_web_page_preview=TestInputTextMessageContent.disable_web_page_preview)
|
||||
return InputTextMessageContent(
|
||||
TestInputTextMessageContent.message_text,
|
||||
parse_mode=TestInputTextMessageContent.parse_mode,
|
||||
disable_web_page_preview=TestInputTextMessageContent.disable_web_page_preview)
|
||||
|
||||
|
||||
class TestInputTextMessageContent(object):
|
||||
|
@ -43,9 +44,9 @@ class TestInputTextMessageContent(object):
|
|||
input_text_message_content_dict = input_text_message_content.to_dict()
|
||||
|
||||
assert isinstance(input_text_message_content_dict, dict)
|
||||
assert input_text_message_content_dict['message_text'] == \
|
||||
input_text_message_content.message_text
|
||||
assert input_text_message_content_dict['parse_mode'] == \
|
||||
input_text_message_content.parse_mode
|
||||
assert input_text_message_content_dict['disable_web_page_preview'] == \
|
||||
input_text_message_content.disable_web_page_preview
|
||||
assert (input_text_message_content_dict['message_text'] ==
|
||||
input_text_message_content.message_text)
|
||||
assert (input_text_message_content_dict['parse_mode'] ==
|
||||
input_text_message_content.parse_mode)
|
||||
assert (input_text_message_content_dict['disable_web_page_preview'] ==
|
||||
input_text_message_content.disable_web_page_preview)
|
||||
|
|
|
@ -49,11 +49,11 @@ class TestInputVenueMessageContent(object):
|
|||
input_venue_message_content_dict = input_venue_message_content.to_dict()
|
||||
|
||||
assert isinstance(input_venue_message_content_dict, dict)
|
||||
assert input_venue_message_content_dict['latitude'] == \
|
||||
input_venue_message_content.latitude
|
||||
assert input_venue_message_content_dict['longitude'] == \
|
||||
input_venue_message_content.longitude
|
||||
assert (input_venue_message_content_dict['latitude'] ==
|
||||
input_venue_message_content.latitude)
|
||||
assert (input_venue_message_content_dict['longitude'] ==
|
||||
input_venue_message_content.longitude)
|
||||
assert input_venue_message_content_dict['title'] == input_venue_message_content.title
|
||||
assert input_venue_message_content_dict['address'] == input_venue_message_content.address
|
||||
assert input_venue_message_content_dict['foursquare_id'] == \
|
||||
input_venue_message_content.foursquare_id
|
||||
assert (input_venue_message_content_dict['foursquare_id'] ==
|
||||
input_venue_message_content.foursquare_id)
|
||||
|
|
|
@ -128,5 +128,5 @@ class TestInvoice(object):
|
|||
|
||||
with pytest.raises(TypeError):
|
||||
assert bot.send_invoice(chat_id, self.title, self.description, self.payload,
|
||||
provider_token, self.start_parameter, self.currency,
|
||||
self.prices, provider_data={'a', 'b', 'c'})
|
||||
provider_token, self.start_parameter, self.currency,
|
||||
self.prices, provider_data={'a', 'b', 'c'})
|
||||
|
|
|
@ -119,8 +119,8 @@ class TestMessageHandler(object):
|
|||
|
||||
def test_none_allowed(self):
|
||||
with pytest.raises(ValueError, match='are all False'):
|
||||
handler = MessageHandler(None, self.callback_basic, message_updates=False,
|
||||
channel_post_updates=False, edited_updates=False)
|
||||
MessageHandler(None, self.callback_basic, message_updates=False,
|
||||
channel_post_updates=False, edited_updates=False)
|
||||
|
||||
def test_with_filter(self, message):
|
||||
handler = MessageHandler(Filters.command, self.callback_basic)
|
||||
|
|
|
@ -18,15 +18,12 @@
|
|||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
import inspect
|
||||
import sys
|
||||
from collections import namedtuple
|
||||
from platform import python_implementation
|
||||
|
||||
import certifi
|
||||
import pytest
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
from telegram.vendor.ptb_urllib3 import urllib3
|
||||
import telegram
|
||||
|
||||
|
@ -50,8 +47,6 @@ def parse_table(h4):
|
|||
table = find_next_sibling_until(h4, 'table', h4.find_next_sibling('h4'))
|
||||
if not table:
|
||||
return []
|
||||
head = [td.text for td in table.tr.find_all('td')]
|
||||
# row = namedtuple('{}TableRow'.format(h4.text), ','.join(head))
|
||||
t = []
|
||||
for tr in table.find_all('tr')[1:]:
|
||||
t.append([td.text for td in tr.find_all('td')])
|
||||
|
|
|
@ -69,8 +69,8 @@ class TestPreCheckoutQuery(object):
|
|||
assert isinstance(pre_checkout_query_dict, dict)
|
||||
assert pre_checkout_query_dict['id'] == pre_checkout_query.id
|
||||
assert pre_checkout_query_dict['invoice_payload'] == pre_checkout_query.invoice_payload
|
||||
assert pre_checkout_query_dict['shipping_option_id'] == \
|
||||
pre_checkout_query.shipping_option_id
|
||||
assert (pre_checkout_query_dict['shipping_option_id'] ==
|
||||
pre_checkout_query.shipping_option_id)
|
||||
assert pre_checkout_query_dict['currency'] == pre_checkout_query.currency
|
||||
assert pre_checkout_query_dict['from'] == pre_checkout_query.from_user.to_dict()
|
||||
assert pre_checkout_query_dict['order_info'] == pre_checkout_query.order_info.to_dict()
|
||||
|
|
|
@ -49,8 +49,9 @@ def false_update(request):
|
|||
|
||||
@pytest.fixture(scope='class')
|
||||
def pre_checkout_query():
|
||||
return Update(1, pre_checkout_query=PreCheckoutQuery('id', User(1, 'test user', False), 'EUR', 223,
|
||||
'invoice_payload'))
|
||||
return Update(1,
|
||||
pre_checkout_query=PreCheckoutQuery('id', User(1, 'test user', False),
|
||||
'EUR', 223, 'invoice_payload'))
|
||||
|
||||
|
||||
class TestPreCheckoutQueryHandler(object):
|
||||
|
|
|
@ -150,8 +150,8 @@ class TestRegexHandler(object):
|
|||
|
||||
def test_none_allowed(self):
|
||||
with pytest.raises(ValueError, match='are all False'):
|
||||
handler = RegexHandler('.*', self.callback_basic, message_updates=False,
|
||||
channel_post_updates=False, edited_updates=False)
|
||||
RegexHandler('.*', self.callback_basic, message_updates=False,
|
||||
channel_post_updates=False, edited_updates=False)
|
||||
|
||||
def test_pass_user_or_chat_data(self, dp, message):
|
||||
handler = RegexHandler('.*', self.callback_data_1, pass_user_data=True)
|
||||
|
|
|
@ -63,12 +63,12 @@ class TestReplyKeyboardMarkup(object):
|
|||
reply_keyboard_markup_dict = reply_keyboard_markup.to_dict()
|
||||
|
||||
assert isinstance(reply_keyboard_markup_dict, dict)
|
||||
assert reply_keyboard_markup_dict['keyboard'][0][0] == \
|
||||
reply_keyboard_markup.keyboard[0][0].to_dict()
|
||||
assert reply_keyboard_markup_dict['keyboard'][0][1] == \
|
||||
reply_keyboard_markup.keyboard[0][1].to_dict()
|
||||
assert reply_keyboard_markup_dict['resize_keyboard'] == \
|
||||
reply_keyboard_markup.resize_keyboard
|
||||
assert reply_keyboard_markup_dict['one_time_keyboard'] == \
|
||||
reply_keyboard_markup.one_time_keyboard
|
||||
assert (reply_keyboard_markup_dict['keyboard'][0][0] ==
|
||||
reply_keyboard_markup.keyboard[0][0].to_dict())
|
||||
assert (reply_keyboard_markup_dict['keyboard'][0][1] ==
|
||||
reply_keyboard_markup.keyboard[0][1].to_dict())
|
||||
assert (reply_keyboard_markup_dict['resize_keyboard'] ==
|
||||
reply_keyboard_markup.resize_keyboard)
|
||||
assert (reply_keyboard_markup_dict['one_time_keyboard'] ==
|
||||
reply_keyboard_markup.one_time_keyboard)
|
||||
assert reply_keyboard_markup_dict['selective'] == reply_keyboard_markup.selective
|
||||
|
|
|
@ -43,6 +43,6 @@ class TestReplyKeyboardRemove(object):
|
|||
def test_to_dict(self, reply_keyboard_remove):
|
||||
reply_keyboard_remove_dict = reply_keyboard_remove.to_dict()
|
||||
|
||||
assert reply_keyboard_remove_dict['remove_keyboard'] == \
|
||||
reply_keyboard_remove.remove_keyboard
|
||||
assert (reply_keyboard_remove_dict['remove_keyboard'] ==
|
||||
reply_keyboard_remove.remove_keyboard)
|
||||
assert reply_keyboard_remove_dict['selective'] == reply_keyboard_remove.selective
|
||||
|
|
|
@ -49,9 +49,10 @@ def false_update(request):
|
|||
|
||||
@pytest.fixture(scope='class')
|
||||
def shiping_query():
|
||||
return Update(1, shipping_query=ShippingQuery(42, User(1, 'test user', False), 'invoice_payload',
|
||||
ShippingAddress('EN', 'my_state', 'my_city',
|
||||
'steer_1', '', 'post_code')))
|
||||
return Update(1,
|
||||
shipping_query=ShippingQuery(42, User(1, 'test user', False), 'invoice_payload',
|
||||
ShippingAddress('EN', 'my_state', 'my_city',
|
||||
'steer_1', '', 'post_code')))
|
||||
|
||||
|
||||
class TestShippingQueryHandler(object):
|
||||
|
|
|
@ -66,14 +66,14 @@ class TestSuccessfulPayment(object):
|
|||
|
||||
assert isinstance(successful_payment_dict, dict)
|
||||
assert successful_payment_dict['invoice_payload'] == successful_payment.invoice_payload
|
||||
assert successful_payment_dict['shipping_option_id'] == \
|
||||
successful_payment.shipping_option_id
|
||||
assert (successful_payment_dict['shipping_option_id'] ==
|
||||
successful_payment.shipping_option_id)
|
||||
assert successful_payment_dict['currency'] == successful_payment.currency
|
||||
assert successful_payment_dict['order_info'] == successful_payment.order_info.to_dict()
|
||||
assert successful_payment_dict['telegram_payment_charge_id'] == \
|
||||
successful_payment.telegram_payment_charge_id
|
||||
assert successful_payment_dict['provider_payment_charge_id'] == \
|
||||
successful_payment.provider_payment_charge_id
|
||||
assert (successful_payment_dict['telegram_payment_charge_id'] ==
|
||||
successful_payment.telegram_payment_charge_id)
|
||||
assert (successful_payment_dict['provider_payment_charge_id'] ==
|
||||
successful_payment.provider_payment_charge_id)
|
||||
|
||||
def test_equality(self):
|
||||
a = SuccessfulPayment(self.currency, self.total_amount, self.invoice_payload,
|
||||
|
|
|
@ -105,7 +105,8 @@ class TestUpdater(object):
|
|||
|
||||
try:
|
||||
# Now, we send an update to the server via urlopen
|
||||
update = Update(1, message=Message(1, User(1, '', False), None, Chat(1, ''), text='Webhook'))
|
||||
update = Update(1, message=Message(1, User(1, '', False), None, Chat(1, ''),
|
||||
text='Webhook'))
|
||||
self._send_webhook_msg(ip, port, update.to_json(), 'TOKEN')
|
||||
sleep(.2)
|
||||
assert q.get(False) == update
|
||||
|
@ -138,7 +139,8 @@ class TestUpdater(object):
|
|||
sleep(.2)
|
||||
|
||||
# Now, we send an update to the server via urlopen
|
||||
update = Update(1, message=Message(1, User(1, '', False), None, Chat(1, ''), text='Webhook 2'))
|
||||
update = Update(1, message=Message(1, User(1, '', False), None, Chat(1, ''),
|
||||
text='Webhook 2'))
|
||||
self._send_webhook_msg(ip, port, update.to_json())
|
||||
sleep(.2)
|
||||
assert q.get(False) == update
|
||||
|
@ -157,11 +159,9 @@ class TestUpdater(object):
|
|||
assert self.attempts == retries
|
||||
|
||||
@pytest.mark.parametrize(('error', 'attempts'),
|
||||
argvalues=[
|
||||
(TelegramError(''), 2),
|
||||
(Unauthorized(''), 1),
|
||||
(InvalidToken(), 1)
|
||||
],
|
||||
argvalues=[(TelegramError(''), 2),
|
||||
(Unauthorized(''), 1),
|
||||
(InvalidToken(), 1)],
|
||||
ids=('TelegramError', 'Unauthorized', 'InvalidToken'))
|
||||
def test_bootstrap_retries_error(self, monkeypatch, updater, error, attempts):
|
||||
retries = 1
|
||||
|
@ -201,7 +201,7 @@ class TestUpdater(object):
|
|||
# self._send_webhook_msg(ip, port, 'dummy-payload', content_len=None)
|
||||
# assert excinfo.value.code == 411
|
||||
|
||||
with pytest.raises(HTTPError) as ctx:
|
||||
with pytest.raises(HTTPError):
|
||||
self._send_webhook_msg(ip, port, 'dummy-payload', content_len='not-a-number')
|
||||
assert excinfo.value.code == 403
|
||||
|
||||
|
|
Loading…
Reference in a new issue