test additional arguments

This commit is contained in:
Jannes Höke 2015-11-22 14:08:33 +01:00
parent 3e732a0736
commit c7a1d8dca3

View file

@ -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)