From 555e36ee8036a179f157f60dcb0c3fcf958146f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannes=20H=C3=B6ke?= Date: Sat, 6 Aug 2016 14:47:45 +0200 Subject: [PATCH] tests --- tests/test_updater.py | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/tests/test_updater.py b/tests/test_updater.py index c5d606495..9a6692f0f 100644 --- a/tests/test_updater.py +++ b/tests/test_updater.py @@ -47,7 +47,7 @@ except ImportError: sys.path.append('.') -from telegram import Update, Message, TelegramError, User, Chat, Bot +from telegram import Update, Message, TelegramError, User, Chat, Bot, InlineQuery, CallbackQuery from telegram.utils.request import stop_con_pool from telegram.ext import * from telegram.ext.dispatcher import run_async @@ -445,6 +445,40 @@ class UpdaterTest(BaseTest, unittest.TestCase): self.assertEqual(self.received_message, (('This', 'regex group'), {'testgroup': 'regex group'})) + def test_regexGroupHandlerInlineQuery(self): + self._setup_updater('', messages=0) + d = self.updater.dispatcher + handler = InlineQueryHandler(self.regexGroupHandlerTest, + pattern='^(This).*?(?Pregex group).*', + pass_groupdict=True, + pass_groups=True) + d.add_handler(handler) + queue = self.updater.start_polling(0.01) + queue.put(Update(update_id=0, + inline_query=InlineQuery( + 0, None, 'This is a test message for regex group matching.', None))) + + sleep(.1) + self.assertEqual(self.received_message, (('This', 'regex group'), + {'testgroup': 'regex group'})) + + def test_regexGroupHandlerCallbackQuery(self): + self._setup_updater('', messages=0) + d = self.updater.dispatcher + handler = CallbackQueryHandler(self.regexGroupHandlerTest, + pattern='^(This).*?(?Pregex group).*', + pass_groupdict=True, + pass_groups=True) + d.add_handler(handler) + queue = self.updater.start_polling(0.01) + queue.put(Update(update_id=0, + callback_query=CallbackQuery( + 0, None, 'This is a test message for regex group matching.'))) + + sleep(.1) + self.assertEqual(self.received_message, (('This', 'regex group'), + {'testgroup': 'regex group'})) + def test_runAsyncWithAdditionalArgs(self): self._setup_updater('Test6', messages=2) d = self.updater.dispatcher