2021-04-15 23:39:16 +02:00
|
|
|
from zerver.lib.test_classes import WebhookTestCase
|
|
|
|
|
|
|
|
|
|
|
|
class FreshpingHookTests(WebhookTestCase):
|
2024-05-04 22:02:50 +02:00
|
|
|
CHANNEL_NAME = "freshping"
|
2021-04-15 23:39:16 +02:00
|
|
|
URL_TEMPLATE = "/api/v1/external/freshping?api_key={api_key}&stream={stream}"
|
2021-06-26 09:18:33 +02:00
|
|
|
WEBHOOK_DIR_NAME = "freshping"
|
2021-04-15 23:39:16 +02:00
|
|
|
|
|
|
|
def test_freshping_check_test(self) -> None:
|
|
|
|
"""
|
|
|
|
Tests if freshping check test is handled correctly
|
|
|
|
"""
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "Freshping"
|
2021-04-15 23:39:16 +02:00
|
|
|
expected_message = "Freshping webhook has been successfully configured."
|
2024-01-17 15:53:30 +01:00
|
|
|
self.check_webhook("freshping_check_test", expected_topic_name, expected_message)
|
2021-04-15 23:39:16 +02:00
|
|
|
|
|
|
|
def test_freshping_check_unreachable(self) -> None:
|
|
|
|
"""
|
|
|
|
Tests if freshping check unreachable is handled correctly
|
|
|
|
"""
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "Test Check"
|
2021-04-15 23:39:16 +02:00
|
|
|
expected_message = """
|
|
|
|
https://example.com has just become unreachable.
|
2021-05-10 07:02:14 +02:00
|
|
|
Error code: 521.
|
2021-04-15 23:39:16 +02:00
|
|
|
""".strip()
|
2024-01-17 15:53:30 +01:00
|
|
|
self.check_webhook("freshping_check_unreachable", expected_topic_name, expected_message)
|
2021-04-15 23:39:16 +02:00
|
|
|
|
|
|
|
def test_freshping_check_reachable(self) -> None:
|
|
|
|
"""
|
|
|
|
Tests if freshping check reachable is handled correctly
|
|
|
|
"""
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "Test Check"
|
2021-04-15 23:39:16 +02:00
|
|
|
expected_message = "https://example.com is back up and no longer unreachable."
|
2024-01-17 15:53:30 +01:00
|
|
|
self.check_webhook("freshping_check_reachable", expected_topic_name, expected_message)
|