From c7a1d8dca3ffcb4e6501ce757ee096d03c4c9996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannes=20H=C3=B6ke?= Date: Sun, 22 Nov 2015 14:08:33 +0100 Subject: [PATCH] test additional arguments --- tests/test_boteventhandler.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_boteventhandler.py b/tests/test_boteventhandler.py index a87ded12f..82e3fcd4a 100644 --- a/tests/test_boteventhandler.py +++ b/tests/test_boteventhandler.py @@ -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)