Skip to content

Commit

Permalink
Fixed telegram tests
Browse files Browse the repository at this point in the history
  • Loading branch information
polshe-v committed Nov 27, 2023
1 parent af0f8a5 commit 1b4e7c1
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions tests/alerters/telegram_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def test_telegram_thread_id(caplog):
alert.alert([match])
expected_data = {
'chat_id': rule['telegram_room_id'],
'text': '⚠ Test Telegram Rule ⚠ \nTest Telegram Rule\n\n@timestamp: 2021-01-01T00:00:00\nsomefield: foobarbaz\n',
'text': '⚠ *Test Telegram Rule*```\nTest Telegram Rule\n\n@timestamp: 2021-01-01T00:00:00\nsomefield: foobarbaz\n ```',
'parse_mode': 'markdown',
'disable_web_page_preview': True,
'message_thread_id' : 2
'message_thread_id': 2
}

mock_post_request.assert_called_once_with(
Expand Down Expand Up @@ -74,7 +74,8 @@ def test_telegram_markdown(caplog):
'chat_id': rule['telegram_room_id'],
'text': '⚠ *Test Telegram Rule* ⚠ ```\nTest Telegram Rule\n\n@timestamp: 2021-01-01T00:00:00\nsomefield: foobarbaz\n ```',
'parse_mode': 'markdown',
'disable_web_page_preview': True
'disable_web_page_preview': True,
'message_thread_id': None
}

mock_post_request.assert_called_once_with(
Expand Down Expand Up @@ -113,7 +114,8 @@ def test_telegram_html(caplog):
'chat_id': rule['telegram_room_id'],
'text': '⚠ Test Telegram Rule ⚠ \nTest Telegram Rule\n\n@timestamp: 2021-01-01T00:00:00\nsomefield: foobarbaz\n',
'parse_mode': 'html',
'disable_web_page_preview': True
'disable_web_page_preview': True,
'message_thread_id': None
}

mock_post_request.assert_called_once_with(
Expand Down Expand Up @@ -153,7 +155,8 @@ def test_telegram_proxy():
'chat_id': rule['telegram_room_id'],
'text': '⚠ *Test Telegram Rule* ⚠ ```\nTest Telegram Rule\n\n@timestamp: 2021-01-01T00:00:00\nsomefield: foobarbaz\n ```',
'parse_mode': 'markdown',
'disable_web_page_preview': True
'disable_web_page_preview': True,
'message_thread_id': None
}

mock_post_request.assert_called_once_with(
Expand Down Expand Up @@ -190,7 +193,8 @@ def test_telegram_text_maxlength():
'text': '⚠ *Test Telegram Rule' + ('a' * 3979) +
'\n⚠ *message was cropped according to telegram limits!* ⚠ ```',
'parse_mode': 'markdown',
'disable_web_page_preview': True
'disable_web_page_preview': True,
'message_thread_id': None
}

mock_post_request.assert_called_once_with(
Expand Down Expand Up @@ -315,7 +319,8 @@ def test_telegram_matchs():
'----------------------------------------\n' +
' ```',
'parse_mode': 'markdown',
'disable_web_page_preview': True
'disable_web_page_preview': True,
'message_thread_id': None
}

mock_post_request.assert_called_once_with(
Expand Down

0 comments on commit 1b4e7c1

Please sign in to comment.