Files
zulip/zerver/webhooks/statuspage/tests.py
Eeshan Garg a4979410f9 webhooks: Migrate most integrations to use check_send_webhook_message.
This commit migrates all of our webhooks to use
check_send_webhook_message, except the following:

beeminder: Rishi wanted to wait on this one.
teamcity: This one is slightly more work.

yo: This one is PM-only. I am still trying to decide whether we
    should have a force_private argument or something in
    check_send_webhook_message.

facebook: No point in migrating this, will be removed as part of
          #8433.

slack: Slightly more work too with the `channel_to_topics` feature.
       Warrants a longer discussion.
2018-03-16 19:23:50 -02:30

39 lines
2.1 KiB
Python

# -*- coding: utf-8 -*-
from typing import Text
from zerver.lib.test_classes import WebhookTestCase
class StatuspageHookTests(WebhookTestCase):
STREAM_NAME = 'statuspage-test'
URL_TEMPLATE = u"/api/v1/external/statuspage?api_key={api_key}&stream={stream}"
def test_statuspage_incident(self) -> None:
expected_subject = u"Database query delays: All Systems Operational"
expected_message = u"**Database query delays** \n * State: **identified** \n \
* Description: We just encountered that database queries are timing out resulting in inconvenience \
to our end users...we'll do quick fix latest by tommorow !!!"
self.send_and_test_stream_message('incident_created',
expected_subject,
expected_message,
content_type="application/x-www-form-urlencoded")
def test_statuspage_incident_update(self) -> None:
expected_subject = u"Database query delays: All Systems Operational"
expected_message = u"**Database query delays** \n * State: **resolved** \n \
* Description: The database issue is resolved."
self.send_and_test_stream_message('incident_update',
expected_subject,
expected_message,
content_type="application/x-www-form-urlencoded")
def test_statuspage_component(self) -> None:
expected_subject = u"Database component: Service Under Maintenance"
expected_message = u"**Database component** has changed status \
from **operational** to **under_maintenance**"
self.send_and_test_stream_message('component_status_update',
expected_subject,
expected_message,
content_type="application/x-www-form-urlencoded")
def get_body(self, fixture_name: Text) -> Text:
return self.fixture_data("statuspage", fixture_name, file_type="json")