2018-01-29 11:33:21 +01:00
|
|
|
from zerver.lib.test_classes import WebhookTestCase
|
|
|
|
|
|
|
|
|
|
|
|
class InspingHookTests(WebhookTestCase):
|
2024-05-04 22:02:50 +02:00
|
|
|
CHANNEL_NAME = "test"
|
2018-03-16 22:53:50 +01:00
|
|
|
URL_TEMPLATE = "/api/v1/external/insping?&api_key={api_key}&stream={stream}"
|
2021-06-26 09:18:33 +02:00
|
|
|
WEBHOOK_DIR_NAME = "insping"
|
2018-01-29 11:33:21 +01:00
|
|
|
|
|
|
|
def test_website_state_available_message(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "insping"
|
2019-04-17 21:32:23 +02:00
|
|
|
expected_message = """
|
|
|
|
State changed to **Available**:
|
|
|
|
* **URL**: http://privisus.zulipdev.org:9991
|
|
|
|
* **Response time**: 223 ms
|
|
|
|
* **Timestamp**: Fri Dec 29 17:23:46 2017
|
|
|
|
""".strip()
|
2018-01-29 11:33:21 +01:00
|
|
|
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook(
|
|
|
|
"website_state_available",
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name,
|
2020-08-23 15:49:24 +02:00
|
|
|
expected_message,
|
|
|
|
content_type="application/x-www-form-urlencoded",
|
|
|
|
)
|
2018-01-29 11:33:21 +01:00
|
|
|
|
|
|
|
def test_website_state_not_responding_message(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "insping"
|
2019-04-17 21:32:23 +02:00
|
|
|
expected_message = """
|
|
|
|
State changed to **Not Responding**:
|
|
|
|
* **URL**: http://privisus.zulipdev.org:9991
|
|
|
|
* **Response time**: 942 ms
|
|
|
|
* **Timestamp**: Fri Dec 29 17:13:46 2017
|
|
|
|
""".strip()
|
2018-01-29 11:33:21 +01:00
|
|
|
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook(
|
|
|
|
"website_state_not_responding",
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name,
|
2020-08-23 15:49:24 +02:00
|
|
|
expected_message,
|
|
|
|
content_type="application/x-www-form-urlencoded",
|
|
|
|
)
|