tests: Add a test for fixtures for non-webhook integrations.

This commit create a directory to store the mock message for nagios and
more will be added.

The json files in this directory will be used to config the screenshot
generating script for the documentations of non-webhook integrations.
This commit is contained in:
PIG208
2021-03-30 05:04:31 +08:00
committed by Tim Abbott
parent 562cbcac1c
commit d20deccee7
3 changed files with 15 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
{
"subject": "service remote load on postgres.humbughq.com",
"body": "**PROBLEM**: service is CRITICAL\n> CRITICAL - load average: 7.49, 8.20, 4.72"
}

View File

@@ -741,6 +741,7 @@ DOC_SCREENSHOT_CONFIG: Dict[str, List[BaseScreenshotConfig]] = {
"json": [ScreenshotConfig("json_github_push__1_commit.json")],
"librato": [ScreenshotConfig("three_conditions_alert.json", payload_as_query_param=True)],
"mention": [ScreenshotConfig("webfeeds.json")],
"nagios": [BaseScreenshotConfig("service_notify.json")],
"netlify": [ScreenshotConfig("deploy_building.json")],
"newrelic": [ScreenshotConfig("alert.txt", "002.png")],
"opbeat": [ScreenshotConfig("error_reopen.json")],

View File

@@ -3,6 +3,8 @@ from zerver.lib.integrations import (
INTEGRATIONS,
NO_SCREENSHOT_WEBHOOKS,
WEBHOOK_INTEGRATIONS,
BaseScreenshotConfig,
Integration,
ScreenshotConfig,
WebhookIntegration,
get_fixture_and_image_paths,
@@ -26,6 +28,14 @@ class IntegrationsTestCase(ZulipTestCase):
self.assertEqual(fixture_path, "zerver/webhooks/airbrake/fixtures/error_message.json")
self.assertEqual(image_path, "static/images/integrations/ci/002.png")
def test_get_fixture_and_image_paths_non_webhook(self) -> None:
integration = INTEGRATIONS["nagios"]
assert isinstance(integration, Integration)
screenshot_config = BaseScreenshotConfig("service_notify.json", "001.png")
fixture_path, image_path = get_fixture_and_image_paths(integration, screenshot_config)
self.assertEqual(fixture_path, "zerver/integration_fixtures/nagios/service_notify.json")
self.assertEqual(image_path, "static/images/integrations/nagios/001.png")
def test_get_bot_avatar_path(self) -> None:
integration = INTEGRATIONS["alertmanager"]
self.assertEqual(