mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-22 23:27:49 +01:00
tests
This commit is contained in:
parent
5134f71380
commit
555e36ee80
1 changed files with 35 additions and 1 deletions
|
@ -47,7 +47,7 @@ except ImportError:
|
||||||
|
|
||||||
sys.path.append('.')
|
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.utils.request import stop_con_pool
|
||||||
from telegram.ext import *
|
from telegram.ext import *
|
||||||
from telegram.ext.dispatcher import run_async
|
from telegram.ext.dispatcher import run_async
|
||||||
|
@ -445,6 +445,40 @@ class UpdaterTest(BaseTest, unittest.TestCase):
|
||||||
self.assertEqual(self.received_message, (('This', 'regex group'),
|
self.assertEqual(self.received_message, (('This', 'regex group'),
|
||||||
{'testgroup': 'regex group'}))
|
{'testgroup': 'regex group'}))
|
||||||
|
|
||||||
|
def test_regexGroupHandlerInlineQuery(self):
|
||||||
|
self._setup_updater('', messages=0)
|
||||||
|
d = self.updater.dispatcher
|
||||||
|
handler = InlineQueryHandler(self.regexGroupHandlerTest,
|
||||||
|
pattern='^(This).*?(?P<testgroup>regex 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).*?(?P<testgroup>regex 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):
|
def test_runAsyncWithAdditionalArgs(self):
|
||||||
self._setup_updater('Test6', messages=2)
|
self._setup_updater('Test6', messages=2)
|
||||||
d = self.updater.dispatcher
|
d = self.updater.dispatcher
|
||||||
|
|
Loading…
Reference in a new issue