2016-09-20 22:51:11 +02:00
# -*- coding: utf-8 -*-
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 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 :
2018-11-09 20:33:58 +01:00
expected_topic = " Apdex score fell below critical level of 0.90 "
2019-04-17 23:26:31 +02:00
expected_message = ' Alert opened on [application name]: Apdex score fell below critical level of 0.90 ([view alert](https://rpm.newrelc.com/accounts/[account_id]/applications/[application_id]/incidents/[incident_id])). '
2018-11-09 20:33:58 +01:00
self . send_and_test_stream_message ( ' alert ' , expected_topic , expected_message ,
2016-09-20 22:51:11 +02:00
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 :
2018-11-09 20:33:58 +01:00
expected_topic = ' Test App deploy '
2019-04-17 23:26:31 +02:00
expected_message = """
* * 1242 * * deployed by * * Zulip Test * * :
` ` ` quote
Description sent via curl
` ` `
Changelog :
` ` ` quote
Changelog string
` ` `
""" .strip()
2018-11-09 20:33:58 +01:00
self . send_and_test_stream_message ( ' deployment ' , expected_topic , expected_message ,
2016-09-20 22:51:11 +02:00
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 ( " newrelic " , fixture_name , file_type = " txt " )