-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.py
More file actions
45 lines (35 loc) · 1.55 KB
/
tests.py
File metadata and controls
45 lines (35 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import time
from telebot import types
from Globals import bot, Globals
class TestTeleBot:
def test_message_handler(self):
msg_help = self.create_text_message(Globals.help_slash_com)
msg_weather = self.create_text_message(
Globals.choose_option_weather_com)
@bot.message_handler(commands=[Globals.help_com])
def help_handler(message):
"""
Тест команды /help
:param message: входное сообщение
"""
message.text = Globals.help_message
bot.process_new_messages([msg_help])
time.sleep(1)
assert msg_help.text == Globals.help_message
@bot.message_handler(commands=[Globals.weather_com])
def weather_handler(message):
"""
Тест команды /weather
:param message: входное сообщение
"""
message.text = Globals.choose_option_text
bot.process_new_messages([msg_weather])
time.sleep(1)
assert msg_weather.text == Globals.choose_option_text
@staticmethod
def create_text_message(text):
params = {Globals.content_type: text}
chat = types.User(Globals.user_id_test, False, Globals.first_name)
print(types.Message(Globals.user_id_test_1, None, None, chat, Globals.content_type, params, ""))
return types.Message(Globals.user_id_test_1, None, None, chat, Globals.content_type, params, "")
TestTeleBot().test_message_handler()