Add tests for empty string as switch_inline_query(_current_chat) (#1635)

This commit is contained in:
Bibo-Joshi 2020-03-31 00:03:45 +02:00 committed by GitHub
parent 392d4e1a9c
commit 61a66a32c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -20,7 +20,7 @@
import pytest
from flaky import flaky
from telegram import InlineKeyboardButton, InlineKeyboardMarkup
from telegram import InlineKeyboardButton, InlineKeyboardMarkup, ReplyMarkup
@pytest.fixture(scope='class')
@ -68,6 +68,26 @@ class TestInlineKeyboardMarkup(object):
def test_expected_values(self, inline_keyboard_markup):
assert inline_keyboard_markup.inline_keyboard == self.inline_keyboard
def test_expected_values_empty_switch(self, inline_keyboard_markup, bot, monkeypatch):
def test(url, data, reply_to_message_id=None, disable_notification=None,
reply_markup=None, timeout=None, **kwargs):
if reply_markup is not None:
if isinstance(reply_markup, ReplyMarkup):
data['reply_markup'] = reply_markup.to_json()
else:
data['reply_markup'] = reply_markup
assert bool('"switch_inline_query": ""' in data['reply_markup'])
assert bool('"switch_inline_query_current_chat": ""' in data['reply_markup'])
inline_keyboard_markup.inline_keyboard[0][0].callback_data = None
inline_keyboard_markup.inline_keyboard[0][0].switch_inline_query = ''
inline_keyboard_markup.inline_keyboard[0][1].callback_data = None
inline_keyboard_markup.inline_keyboard[0][1].switch_inline_query_current_chat = ''
monkeypatch.setattr(bot, '_message', test)
bot.send_message(123, 'test', reply_markup=inline_keyboard_markup)
def test_to_dict(self, inline_keyboard_markup):
inline_keyboard_markup_dict = inline_keyboard_markup.to_dict()