Test for Update.idle()

This commit is contained in:
Jannes Höke 2015-11-24 14:57:54 +01:00
parent 1005ad57ce
commit e1f3f346bc

View file

@ -22,6 +22,8 @@ import logging
import unittest
import sys
import re
import os
import signal
from random import randrange
from time import sleep
from datetime import datetime
@ -259,6 +261,21 @@ class BotEventHandlerTest(BaseTest, unittest.TestCase):
sleep(1)
self.assertEqual(self.received_message, 'Webhook Test')
def signalsender(self):
sleep(0.5)
os.kill(os.getpid(), signal.SIGTERM)
def test_idle(self):
print('Testing idle')
self.updater.bot = MockBot('Test4', messages=0)
self.updater.start_polling(poll_interval=0.01)
Thread(target=self.signalsender).start()
self.updater.idle()
# If we get this far, idle() ran through
sleep(1)
self.updater.running = False
class MockBot: