|
28 | 28 |
|
29 | 29 | from telegram import (Bot, Update, ChatAction, TelegramError, User, InlineKeyboardMarkup,
|
30 | 30 | InlineKeyboardButton, InlineQueryResultArticle, InputTextMessageContent,
|
31 |
| - ShippingOption, LabeledPrice, ChatPermissions, Poll) |
| 31 | + ShippingOption, LabeledPrice, ChatPermissions, Poll, |
| 32 | + InlineQueryResultDocument) |
32 | 33 | from telegram.error import BadRequest, InvalidToken, NetworkError, RetryAfter
|
33 | 34 | from telegram.utils.helpers import from_timestamp, escape_markdown
|
34 | 35 |
|
@@ -237,6 +238,67 @@ def test(_, url, data, *args, **kwargs):
|
237 | 238 | switch_pm_text='switch pm',
|
238 | 239 | switch_pm_parameter='start_pm')
|
239 | 240 |
|
| 241 | + def test_answer_inline_query_no_default_parse_mode(self, monkeypatch, bot): |
| 242 | + def test(_, url, data, *args, **kwargs): |
| 243 | + return data == {'cache_time': 300, |
| 244 | + 'results': [{'title': 'test_result', 'id': '123', 'type': 'document', |
| 245 | + 'document_url': 'https://raw.githubusercontent.com/' |
| 246 | + 'python-telegram-bot/logos/master/logo/png/' |
| 247 | + 'ptb-logo_240.png', 'mime_type': 'image/png', |
| 248 | + 'caption': 'ptb_logo'}], |
| 249 | + 'next_offset': '42', 'switch_pm_parameter': 'start_pm', |
| 250 | + 'inline_query_id': 1234, 'is_personal': True, |
| 251 | + 'switch_pm_text': 'switch pm'} |
| 252 | + |
| 253 | + monkeypatch.setattr('telegram.utils.request.Request.post', test) |
| 254 | + results = [InlineQueryResultDocument( |
| 255 | + id='123', |
| 256 | + document_url='https://raw.githubusercontent.com/python-telegram-bot/logos/master/' |
| 257 | + 'logo/png/ptb-logo_240.png', |
| 258 | + title='test_result', |
| 259 | + mime_type='image/png', |
| 260 | + caption='ptb_logo', |
| 261 | + )] |
| 262 | + |
| 263 | + assert bot.answer_inline_query(1234, |
| 264 | + results=results, |
| 265 | + cache_time=300, |
| 266 | + is_personal=True, |
| 267 | + next_offset='42', |
| 268 | + switch_pm_text='switch pm', |
| 269 | + switch_pm_parameter='start_pm') |
| 270 | + |
| 271 | + @pytest.mark.parametrize('default_bot', [{'parse_mode': 'Markdown'}], indirect=True) |
| 272 | + def test_answer_inline_query_default_parse_mode(self, monkeypatch, default_bot): |
| 273 | + def test(_, url, data, *args, **kwargs): |
| 274 | + return data == {'cache_time': 300, |
| 275 | + 'results': [{'title': 'test_result', 'id': '123', 'type': 'document', |
| 276 | + 'document_url': 'https://raw.githubusercontent.com/' |
| 277 | + 'python-telegram-bot/logos/master/logo/png/' |
| 278 | + 'ptb-logo_240.png', 'mime_type': 'image/png', |
| 279 | + 'caption': 'ptb_logo', 'parse_mode': 'Markdown'}], |
| 280 | + 'next_offset': '42', 'switch_pm_parameter': 'start_pm', |
| 281 | + 'inline_query_id': 1234, 'is_personal': True, |
| 282 | + 'switch_pm_text': 'switch pm'} |
| 283 | + |
| 284 | + monkeypatch.setattr('telegram.utils.request.Request.post', test) |
| 285 | + results = [InlineQueryResultDocument( |
| 286 | + id='123', |
| 287 | + document_url='https://raw.githubusercontent.com/python-telegram-bot/logos/master/' |
| 288 | + 'logo/png/ptb-logo_240.png', |
| 289 | + title='test_result', |
| 290 | + mime_type='image/png', |
| 291 | + caption='ptb_logo', |
| 292 | + )] |
| 293 | + |
| 294 | + assert default_bot.answer_inline_query(1234, |
| 295 | + results=results, |
| 296 | + cache_time=300, |
| 297 | + is_personal=True, |
| 298 | + next_offset='42', |
| 299 | + switch_pm_text='switch pm', |
| 300 | + switch_pm_parameter='start_pm') |
| 301 | + |
240 | 302 | @flaky(3, 1)
|
241 | 303 | @pytest.mark.timeout(10)
|
242 | 304 | def test_get_user_profile_photos(self, bot, chat_id):
|
|
0 commit comments