2016-09-20 22:51:11 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
2016-12-04 18:38:56 +01:00
|
|
|
from typing import Text
|
2016-11-10 19:30:09 +01:00
|
|
|
from zerver.lib.test_classes import WebhookTestCase
|
2016-09-20 22:51:11 +02:00
|
|
|
|
|
|
|
class NewRelicHookTests(WebhookTestCase):
|
|
|
|
STREAM_NAME = 'newrelic'
|
|
|
|
URL_TEMPLATE = u"/api/v1/external/newrelic?stream={stream}&api_key={api_key}"
|
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def test_alert(self) -> None:
|
2016-09-20 22:51:11 +02:00
|
|
|
expected_subject = "Apdex score fell below critical level of 0.90"
|
|
|
|
expected_message = 'Alert opened on [application name]: \
|
|
|
|
Apdex score fell below critical level of 0.90\n\
|
|
|
|
[View alert](https://rpm.newrelc.com/accounts/[account_id]/applications/[application_id]/incidents/[incident_id])'
|
|
|
|
self.send_and_test_stream_message('alert', expected_subject, expected_message,
|
|
|
|
content_type="application/x-www-form-urlencoded")
|
2016-11-29 07:22:02 +01:00
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def test_deployment(self) -> None:
|
2016-09-20 22:51:11 +02:00
|
|
|
expected_subject = 'Test App deploy'
|
|
|
|
expected_message = '`1242` deployed by **Zulip Test**\n\
|
|
|
|
Description sent via curl\n\nChangelog string'
|
|
|
|
self.send_and_test_stream_message('deployment', expected_subject, expected_message,
|
|
|
|
content_type="application/x-www-form-urlencoded")
|
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def get_body(self, fixture_name: Text) -> Text:
|
2016-09-20 22:51:11 +02:00
|
|
|
return self.fixture_data("newrelic", fixture_name, file_type="txt")
|