From 0006294f293139f3af1a4ac0b2dc4fc9746e2db5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannes=20H=C3=B6ke?= Date: Sat, 21 Nov 2015 15:45:45 +0100 Subject: [PATCH] update tests --- tests/test_boteventhandler.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/test_boteventhandler.py b/tests/test_boteventhandler.py index a28741246..d8075254d 100644 --- a/tests/test_boteventhandler.py +++ b/tests/test_boteventhandler.py @@ -28,7 +28,7 @@ import re sys.path.append('.') from telegram import Update, Message, TelegramError -from tests.base import BaseTest +from base import BaseTest class BotEventHandlerTest(BaseTest, unittest.TestCase): @@ -41,6 +41,9 @@ class BotEventHandlerTest(BaseTest, unittest.TestCase): self.received_message = None self.message_count = 0 + def tearDown(self): + self.beh.stop() + def telegramHandlerTest(self, bot, update): self.received_message = update.message.text self.message_count += 1 @@ -49,6 +52,10 @@ class BotEventHandlerTest(BaseTest, unittest.TestCase): self.received_message = update self.message_count += 1 + def errorHandlerTest(self, bot, update, error): + self.received_message = error + self.message_count += 1 + def test_addTelegramMessageHandler(self): print('Testing addTelegramMessageHandler') self.beh.bot = MockBot('Test') @@ -129,7 +136,7 @@ class BotEventHandlerTest(BaseTest, unittest.TestCase): def test_addErrorHandler(self): print('Testing addErrorHandler') self.beh.bot = MockBot('') - self.beh.broadcaster.addErrorHandler(self.stringHandlerTest) + self.beh.broadcaster.addErrorHandler(self.errorHandlerTest) queue = self.beh.start_polling(0.05) error = TelegramError("Unauthorized.") queue.put(error) @@ -160,7 +167,11 @@ class MockBot: update.message = message return update - def getUpdates(self, offset): + def getUpdates(self, + offset=None, + limit=100, + timeout=0, + network_delay=2.): if self.send_messages >= 2: self.send_messages -= 2