mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-22 23:27:49 +01:00
test additional arguments
This commit is contained in:
parent
3e732a0736
commit
c7a1d8dca3
1 changed files with 20 additions and 0 deletions
|
@ -78,6 +78,14 @@ class BotEventHandlerTest(BaseTest, unittest.TestCase):
|
|||
self.received_message = update
|
||||
self.message_count += 1
|
||||
|
||||
def additionalArgsTest(self, bot, update, update_queue, args):
|
||||
self.received_message = update
|
||||
self.message_count += 1
|
||||
if args[0] == 'resend':
|
||||
update_queue.put('/test5 noresend')
|
||||
elif args[0] == 'noresend':
|
||||
pass
|
||||
|
||||
def errorHandlerTest(self, bot, update, error):
|
||||
self.received_message = error
|
||||
self.message_count += 1
|
||||
|
@ -197,6 +205,18 @@ class BotEventHandlerTest(BaseTest, unittest.TestCase):
|
|||
self.assertEqual(self.received_message, 'Test4')
|
||||
self.assertEqual(self.message_count, 2)
|
||||
|
||||
def test_additionalArgs(self):
|
||||
print('Testing additional arguments for handlers')
|
||||
self.beh.bot = MockBot('')
|
||||
self.beh.broadcaster.addStringCommandHandler(
|
||||
'test5', self.additionalArgsTest)
|
||||
|
||||
queue = self.beh.start_polling(0.05)
|
||||
queue.put('/test5 resend')
|
||||
sleep(.2)
|
||||
self.assertEqual(self.received_message, '/test5 noresend')
|
||||
self.assertEqual(self.message_count, 2)
|
||||
|
||||
def test_webhook(self):
|
||||
print('Testing Webhook')
|
||||
self.beh.bot = MockBot('Test4', messages=2)
|
||||
|
|
Loading…
Reference in a new issue