Skip to content

Commit d20decc

Browse files
PIG208timabbott
authored andcommitted
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.
1 parent 562cbca commit d20decc

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"subject": "service remote load on postgres.humbughq.com",
3+
"body": "**PROBLEM**: service is CRITICAL\n> CRITICAL - load average: 7.49, 8.20, 4.72"
4+
}

zerver/lib/integrations.py

+1
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,7 @@ def __init__(self, name: str, *args: Any, **kwargs: Any) -> None:
741741
"json": [ScreenshotConfig("json_github_push__1_commit.json")],
742742
"librato": [ScreenshotConfig("three_conditions_alert.json", payload_as_query_param=True)],
743743
"mention": [ScreenshotConfig("webfeeds.json")],
744+
"nagios": [BaseScreenshotConfig("service_notify.json")],
744745
"netlify": [ScreenshotConfig("deploy_building.json")],
745746
"newrelic": [ScreenshotConfig("alert.txt", "002.png")],
746747
"opbeat": [ScreenshotConfig("error_reopen.json")],

zerver/tests/test_integrations.py

+10
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
INTEGRATIONS,
44
NO_SCREENSHOT_WEBHOOKS,
55
WEBHOOK_INTEGRATIONS,
6+
BaseScreenshotConfig,
7+
Integration,
68
ScreenshotConfig,
79
WebhookIntegration,
810
get_fixture_and_image_paths,
@@ -26,6 +28,14 @@ def test_get_fixture_and_image_paths(self) -> None:
2628
self.assertEqual(fixture_path, "zerver/webhooks/airbrake/fixtures/error_message.json")
2729
self.assertEqual(image_path, "static/images/integrations/ci/002.png")
2830

31+
def test_get_fixture_and_image_paths_non_webhook(self) -> None:
32+
integration = INTEGRATIONS["nagios"]
33+
assert isinstance(integration, Integration)
34+
screenshot_config = BaseScreenshotConfig("service_notify.json", "001.png")
35+
fixture_path, image_path = get_fixture_and_image_paths(integration, screenshot_config)
36+
self.assertEqual(fixture_path, "zerver/integration_fixtures/nagios/service_notify.json")
37+
self.assertEqual(image_path, "static/images/integrations/nagios/001.png")
38+
2939
def test_get_bot_avatar_path(self) -> None:
3040
integration = INTEGRATIONS["alertmanager"]
3141
self.assertEqual(

0 commit comments

Comments
 (0)