mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-21 22:56:38 +01:00
final renaming of files and flake8
This commit is contained in:
parent
83d2ca3aa7
commit
628a4c4eac
3 changed files with 17 additions and 14 deletions
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
This Bot uses the BotEventHandler class to handle the bot.
|
||||
This Bot uses the Updater class to handle the bot.
|
||||
|
||||
First, a few handler functions are defined. Then, those functions are passed to
|
||||
the Dispatcher and registered at their respective places.
|
||||
|
@ -34,6 +34,7 @@ last_chat_id = 0
|
|||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# Command Handlers
|
||||
def start(bot, update):
|
||||
""" Answer in Telegram """
|
||||
|
@ -151,4 +152,3 @@ def main():
|
|||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
This Bot uses the BotEventHandler class to handle the bot.
|
||||
This Bot uses the Updater class to handle the bot.
|
||||
|
||||
First, a few handler functions are defined. Then, those functions are passed to
|
||||
the Dispatcher and registered at their respective places.
|
||||
|
@ -15,7 +15,6 @@ Type 'stop' on the command line to stop the bot.
|
|||
from telegram import Updater
|
||||
import logging
|
||||
import sys
|
||||
from time import sleep
|
||||
|
||||
# Enable logging
|
||||
root = logging.getLogger()
|
||||
|
@ -30,6 +29,7 @@ root.addHandler(ch)
|
|||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# Command Handlers
|
||||
def start(bot, update):
|
||||
bot.sendMessage(update.message.chat_id, text='Hi!')
|
||||
|
@ -73,4 +73,3 @@ def main():
|
|||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
@ -17,7 +17,10 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
|
||||
""" This module contains a object that represents Tests for BotEventHandler """
|
||||
"""
|
||||
This module contains a object that represents Tests for Updater, Dispatcher,
|
||||
WebhookServer and WebhookHandler
|
||||
"""
|
||||
import logging
|
||||
import unittest
|
||||
import sys
|
||||
|
@ -51,8 +54,11 @@ ch.setFormatter(formatter)
|
|||
root.addHandler(ch)
|
||||
|
||||
|
||||
class BotEventHandlerTest(BaseTest, unittest.TestCase):
|
||||
"""This object represents Tests for Telegram Bot."""
|
||||
class UpdaterTest(BaseTest, unittest.TestCase):
|
||||
"""
|
||||
This object represents Tests for Updater, Dispatcher, WebhookServer and
|
||||
WebhookHandler
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
self.updater = Updater('', workers=2)
|
||||
|
@ -117,7 +123,6 @@ class BotEventHandlerTest(BaseTest, unittest.TestCase):
|
|||
sleep(.1)
|
||||
self.assertTrue(None is self.received_message)
|
||||
|
||||
|
||||
def test_addTelegramMessageHandlerMultipleMessages(self):
|
||||
print('Testing addTelegramMessageHandler and send 100 messages...')
|
||||
self.updater.bot = MockBot('Multiple', 100)
|
||||
|
@ -345,8 +350,8 @@ class BotEventHandlerTest(BaseTest, unittest.TestCase):
|
|||
# Select random port for travis
|
||||
port = randrange(1024, 49152)
|
||||
self.updater.start_webhook('127.0.0.1', port,
|
||||
'./tests/test_boteventhandler.py',
|
||||
'./tests/test_boteventhandler.py',
|
||||
'./tests/test_updater.py',
|
||||
'./tests/test_updater.py',
|
||||
listen='127.0.0.1')
|
||||
sleep(0.5)
|
||||
# SSL-Wrapping will fail, so we start the server without SSL
|
||||
|
@ -396,7 +401,6 @@ class BotEventHandlerTest(BaseTest, unittest.TestCase):
|
|||
self.updater.httpd.shutdown()
|
||||
self.assertTrue(True)
|
||||
|
||||
|
||||
def signalsender(self):
|
||||
sleep(0.5)
|
||||
os.kill(os.getpid(), signal.SIGTERM)
|
||||
|
@ -412,7 +416,6 @@ class BotEventHandlerTest(BaseTest, unittest.TestCase):
|
|||
self.updater.running = False
|
||||
|
||||
|
||||
|
||||
class MockBot:
|
||||
|
||||
def __init__(self, text, messages=1, raise_error=False):
|
||||
|
@ -422,7 +425,8 @@ class MockBot:
|
|||
self.token = "TOKEN"
|
||||
pass
|
||||
|
||||
def mockUpdate(self, text):
|
||||
@staticmethod
|
||||
def mockUpdate(text):
|
||||
message = Message(0, None, None, None)
|
||||
message.text = text
|
||||
update = Update(0)
|
Loading…
Reference in a new issue