2016-11-10 19:30:09 +01:00
|
|
|
from zerver.lib.test_classes import WebhookTestCase
|
2016-09-20 22:51:11 +02:00
|
|
|
|
2020-01-14 22:06:24 +01:00
|
|
|
|
2016-09-20 22:51:11 +02:00
|
|
|
class PingdomHookTests(WebhookTestCase):
|
|
|
|
STREAM_NAME = 'pingdom'
|
2020-04-09 21:51:58 +02:00
|
|
|
URL_TEMPLATE = "/api/v1/external/pingdom?stream={stream}&api_key={api_key}"
|
2016-09-20 22:51:11 +02:00
|
|
|
FIXTURE_DIR_NAME = 'pingdom'
|
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def test_pingdom_from_up_to_down_http_check_message(self) -> None:
|
2016-09-20 22:51:11 +02:00
|
|
|
"""
|
|
|
|
Tests if pingdom http check from up to down is handled correctly
|
|
|
|
"""
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_message = "Service someurl.com changed its HTTP status from UP to DOWN:\n\n``` quote\nNon-recoverable failure in name resolution\n```"
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook("http_up_to_down", "Test check status.", expected_message)
|
2016-09-20 22:51:11 +02:00
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def test_pingdom_from_up_to_down_smtp_check_message(self) -> None:
|
2016-09-20 22:51:11 +02:00
|
|
|
"""
|
|
|
|
Tests if pingdom smtp check from up to down is handled correctly
|
|
|
|
"""
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_message = "Service smtp.someurl.com changed its SMTP status from UP to DOWN:\n\n``` quote\nConnection refused\n```"
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook("smtp_up_to_down", "SMTP check status.", expected_message)
|
2016-09-20 22:51:11 +02:00
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def test_pingdom_from_up_to_down_imap_check_message(self) -> None:
|
2016-09-20 22:51:11 +02:00
|
|
|
"""
|
|
|
|
Tests if pingdom imap check from up to down is handled correctly
|
|
|
|
"""
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_message = "Service imap.someurl.com changed its IMAP status from UP to DOWN:\n\n``` quote\nInvalid hostname, address or socket\n```"
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook("imap_up_to_down", "IMAP check status.", expected_message)
|
2016-09-20 22:51:11 +02:00
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def test_pingdom_from_down_to_up_imap_check_message(self) -> None:
|
2016-09-20 22:51:11 +02:00
|
|
|
"""
|
|
|
|
Tests if pingdom imap check from down to up is handled correctly
|
|
|
|
"""
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_message = "Service imap.someurl.com changed its IMAP status from DOWN to UP."
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook("imap_down_to_up", "IMAP check status.", expected_message)
|