Skip to content

Commit

Permalink
small test created
Browse files Browse the repository at this point in the history
  • Loading branch information
elizaveta-andreeva committed Nov 14, 2023
1 parent 0a2d91d commit 5f04f49
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/app_variables.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
24165427
2c74ae389b90a8d11320ea3e61e3a494
silero_demo_bot
3 changes: 3 additions & 0 deletions tests/test.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/start|Привет! Я бот, который поможет тебе отрефлексировать твое настроение
выбрать время для рассылки|Ты выбрал 18:00 - 19:00 в качестве времени для рассылки. Спасибо!
выбрать фокус|Ты выбрал фокусом этой недели работу с усталостью. Для начала вспомни, какие события или действия наполняют тебя ресурсом, дает прилив энергии и сил?
41 changes: 41 additions & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from time import sleep
from pyrogram import Client


def get_app_info():
with open('app_variables.txt', encoding="utf-8") as f:
app_variables = f.read().split('\n')
return app_variables


def verify_response(expected_value: str, received_value: str):
if not received_value.startswith(expected_value):
print("It's not what I expected.")
print(f"\tExpected: {expected_value}")
print(f"\tReceived: {received_value}")


def delay(seconds=2):
sleep(seconds)


def run_test(app, filename):
with open(filename, encoding="utf-8") as f:
test_configs = [line.split('|') for line in f.read().split('\n')]

msg = None
for input_value, expected_value in test_configs:
if input_value == '/start':
msg = app.send_message(username, input_value)
else:
msg = app.get_messages(username, msg.id + 1)
msg.click(0)
delay(1)
msg = app.get_messages(username, msg.id + 1)
verify_response(expected_value, msg.text)
delay()


api_id, api_hash, username = get_app_info()
with Client("my_account", api_id, api_hash) as app:
run_test(app, 'test.csv')

0 comments on commit 5f04f49

Please sign in to comment.