mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	Generated by `pyupgrade --py3-plus --keep-percent-format` on all our Python code except `zthumbor` and `zulip-ec2-configure-interfaces`, followed by manual indentation fixes. Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
		
			
				
	
	
		
			36 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
from zerver.lib.test_classes import WebhookTestCase
 | 
						|
 | 
						|
 | 
						|
class NewRelicHookTests(WebhookTestCase):
 | 
						|
    STREAM_NAME = 'newrelic'
 | 
						|
    URL_TEMPLATE = "/api/v1/external/newrelic?stream={stream}&api_key={api_key}"
 | 
						|
 | 
						|
    def test_alert(self) -> None:
 | 
						|
        expected_topic = "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 ([view alert](https://rpm.newrelc.com/accounts/[account_id]/applications/[application_id]/incidents/[incident_id])).'
 | 
						|
 | 
						|
        self.send_and_test_stream_message('alert', expected_topic, expected_message,
 | 
						|
                                          content_type="application/x-www-form-urlencoded")
 | 
						|
 | 
						|
    def test_deployment(self) -> None:
 | 
						|
        expected_topic = 'Test App deploy'
 | 
						|
        expected_message = """
 | 
						|
**1242** deployed by **Zulip Test**:
 | 
						|
 | 
						|
``` quote
 | 
						|
Description sent via curl
 | 
						|
```
 | 
						|
 | 
						|
Changelog:
 | 
						|
 | 
						|
``` quote
 | 
						|
Changelog string
 | 
						|
```
 | 
						|
""".strip()
 | 
						|
 | 
						|
        self.send_and_test_stream_message('deployment', expected_topic, expected_message,
 | 
						|
                                          content_type="application/x-www-form-urlencoded")
 | 
						|
 | 
						|
    def get_body(self, fixture_name: str) -> str:
 | 
						|
        return self.webhook_fixture_data("newrelic", fixture_name, file_type="txt")
 |