2017-12-27 07:15:27 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from zerver.lib.test_classes import WebhookTestCase
|
|
|
|
|
|
|
|
class StatuspageHookTests(WebhookTestCase):
|
|
|
|
STREAM_NAME = 'statuspage-test'
|
2018-03-16 22:53:50 +01:00
|
|
|
URL_TEMPLATE = u"/api/v1/external/statuspage?api_key={api_key}&stream={stream}"
|
2017-12-27 07:15:27 +01:00
|
|
|
|
|
|
|
def test_statuspage_incident(self) -> None:
|
2018-11-09 20:33:58 +01:00
|
|
|
expected_topic = u"Database query delays: All Systems Operational"
|
2019-04-12 05:55:01 +02:00
|
|
|
expected_message = """
|
|
|
|
**Database query delays**:
|
|
|
|
* State: **identified**
|
|
|
|
* 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 !!!
|
|
|
|
""".strip()
|
2017-12-27 07:15:27 +01:00
|
|
|
self.send_and_test_stream_message('incident_created',
|
2018-11-09 20:33:58 +01:00
|
|
|
expected_topic,
|
2017-12-27 07:15:27 +01:00
|
|
|
expected_message,
|
|
|
|
content_type="application/x-www-form-urlencoded")
|
|
|
|
|
|
|
|
def test_statuspage_incident_update(self) -> None:
|
2018-11-09 20:33:58 +01:00
|
|
|
expected_topic = u"Database query delays: All Systems Operational"
|
2019-04-12 05:55:01 +02:00
|
|
|
expected_message = """
|
|
|
|
**Database query delays**:
|
|
|
|
* State: **resolved**
|
|
|
|
* Description: The database issue is resolved.
|
|
|
|
""".strip()
|
2017-12-27 07:15:27 +01:00
|
|
|
self.send_and_test_stream_message('incident_update',
|
2018-11-09 20:33:58 +01:00
|
|
|
expected_topic,
|
2017-12-27 07:15:27 +01:00
|
|
|
expected_message,
|
|
|
|
content_type="application/x-www-form-urlencoded")
|
|
|
|
|
|
|
|
def test_statuspage_component(self) -> None:
|
2018-11-09 20:33:58 +01:00
|
|
|
expected_topic = u"Database component: Service Under Maintenance"
|
2019-04-12 05:55:01 +02:00
|
|
|
expected_message = u"**Database component** has changed status from **operational** to **under_maintenance**."
|
2017-12-27 07:15:27 +01:00
|
|
|
self.send_and_test_stream_message('component_status_update',
|
2018-11-09 20:33:58 +01:00
|
|
|
expected_topic,
|
2017-12-27 07:15:27 +01:00
|
|
|
expected_message,
|
|
|
|
content_type="application/x-www-form-urlencoded")
|
|
|
|
|
2018-05-10 19:34:01 +02:00
|
|
|
def get_body(self, fixture_name: str) -> str:
|
2018-04-20 03:57:21 +02:00
|
|
|
return self.webhook_fixture_data("statuspage", fixture_name, file_type="json")
|