mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-02-17 02:34:18 +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.received_message = update
|
||||||
self.message_count += 1
|
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):
|
def errorHandlerTest(self, bot, update, error):
|
||||||
self.received_message = error
|
self.received_message = error
|
||||||
self.message_count += 1
|
self.message_count += 1
|
||||||
|
@ -197,6 +205,18 @@ class BotEventHandlerTest(BaseTest, unittest.TestCase):
|
||||||
self.assertEqual(self.received_message, 'Test4')
|
self.assertEqual(self.received_message, 'Test4')
|
||||||
self.assertEqual(self.message_count, 2)
|
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):
|
def test_webhook(self):
|
||||||
print('Testing Webhook')
|
print('Testing Webhook')
|
||||||
self.beh.bot = MockBot('Test4', messages=2)
|
self.beh.bot = MockBot('Test4', messages=2)
|
||||||
|
|
Loading…
Add table
Reference in a new issue