mirror of
https://github.com/zulip/zulip.git
synced 2025-11-21 06:58:31 +00:00
Almost all webhook tests use this helper, except a few webhooks that write to private streams. Being concise is important here, and the name `self.send_and_test_stream_message` always confused me, since it sounds you're sending a stream message, and it leaves out the webhook piece. We should consider renaming `send_and_test_private_message` to something like `check_webhook_private`, but I couldn't decide on a great name, and it's very rarely used. So for now I just made sure the docstrings of the two sibling functions reference each other.
36 lines
1.7 KiB
Python
36 lines
1.7 KiB
Python
from zerver.lib.test_classes import WebhookTestCase
|
|
|
|
|
|
class PingdomHookTests(WebhookTestCase):
|
|
STREAM_NAME = 'pingdom'
|
|
URL_TEMPLATE = "/api/v1/external/pingdom?stream={stream}&api_key={api_key}"
|
|
FIXTURE_DIR_NAME = 'pingdom'
|
|
|
|
def test_pingdom_from_up_to_down_http_check_message(self) -> None:
|
|
"""
|
|
Tests if pingdom http check from up to down is handled correctly
|
|
"""
|
|
expected_message = "Service someurl.com changed its HTTP status from UP to DOWN:\n\n``` quote\nNon-recoverable failure in name resolution\n```"
|
|
self.check_webhook("http_up_to_down", "Test check status.", expected_message)
|
|
|
|
def test_pingdom_from_up_to_down_smtp_check_message(self) -> None:
|
|
"""
|
|
Tests if pingdom smtp check from up to down is handled correctly
|
|
"""
|
|
expected_message = "Service smtp.someurl.com changed its SMTP status from UP to DOWN:\n\n``` quote\nConnection refused\n```"
|
|
self.check_webhook("smtp_up_to_down", "SMTP check status.", expected_message)
|
|
|
|
def test_pingdom_from_up_to_down_imap_check_message(self) -> None:
|
|
"""
|
|
Tests if pingdom imap check from up to down is handled correctly
|
|
"""
|
|
expected_message = "Service imap.someurl.com changed its IMAP status from UP to DOWN:\n\n``` quote\nInvalid hostname, address or socket\n```"
|
|
self.check_webhook("imap_up_to_down", "IMAP check status.", expected_message)
|
|
|
|
def test_pingdom_from_down_to_up_imap_check_message(self) -> None:
|
|
"""
|
|
Tests if pingdom imap check from down to up is handled correctly
|
|
"""
|
|
expected_message = "Service imap.someurl.com changed its IMAP status from DOWN to UP."
|
|
self.check_webhook("imap_down_to_up", "IMAP check status.", expected_message)
|