Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Usage
>>> telegram:
--telegram_id=CHAT_ID
Id of telegram chat
--telegram_thread_id=CHAT_THREAD_ID
Id of telegram thread
--telegram_token=BOT_TOKEN
Telegram Bot token
--telegram_report_url=URL
Expand Down
10 changes: 10 additions & 0 deletions pytest_telegram/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ def pytest_addoption(parser):
default=None,
help='Id of telegram chat'
)
group.addoption(
'--telegram_thread_id',
action='store',
dest='telegram_thread_id',
default=None,
help='Id of telegram thread'
)
group.addoption(
'--telegram_token',
action='store',
Expand Down Expand Up @@ -87,6 +94,7 @@ def pytest_terminal_summary(terminalreporter, exitstatus, config):
token = config.option.telegram_token
telegram_uri = f'https://api.telegram.org/bot{token}'
chat_id = config.option.telegram_id
thread_id = config.option.telegram_thread_id

success_sticker_id = config.option.success_sticker_id
fail_sticker_id = config.option.fail_sticker_id
Expand Down Expand Up @@ -134,6 +142,8 @@ def pytest_terminal_summary(terminalreporter, exitstatus, config):
'text': f'{final_results}{time_taken}{custom_text}{report_url}\n{failed_tests}{error_tests}',
'reply_to_message_id': message_id
}
if thread_id:
message_payload['message_thread_id'] = thread_id
requests.post(f'{telegram_uri}/sendMessage', json=message_payload).json()
except exceptions.RequestException as e:
LOG.error("TELEGRAM Sending Message Error!!!")
Expand Down