mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-03-17 04:39:55 +01:00
Add tests for empty string as switch_inline_query(_current_chat) (#1635)
This commit is contained in:
parent
392d4e1a9c
commit
61a66a32c8
1 changed files with 21 additions and 1 deletions
|
@ -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()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue