Browse Source
Update notification templates to handle "log" events
pull/680/head
Pēteris Caune
2 years ago
No known key found for this signature in database
GPG Key ID: E28D7679E9A9EDE2
7 changed files with
51 additions and
0 deletions
-
hc/api/tests/test_notify_email.py
-
hc/api/tests/test_notify_msteams.py
-
hc/api/tests/test_notify_slack.py
-
templates/emails/alert-body-html.html
-
templates/emails/alert-body-text.html
-
templates/integrations/msteams_message.json
-
templates/integrations/slack_message.json
|
|
@ -235,3 +235,14 @@ class NotifyEmailTestCase(BaseTestCase): |
|
|
|
html = email.alternatives[0][0] |
|
|
|
self.assertIn("Ignored", email.body) |
|
|
|
self.assertIn("Ignored", html) |
|
|
|
|
|
|
|
def test_it_handles_last_ping_log(self): |
|
|
|
self.ping.kind = "log" |
|
|
|
self.ping.save() |
|
|
|
|
|
|
|
self.channel.notify(self.check) |
|
|
|
|
|
|
|
email = mail.outbox[0] |
|
|
|
html = email.alternatives[0][0] |
|
|
|
self.assertIn("Log", email.body) |
|
|
|
self.assertIn("Log", html) |
|
|
@ -96,6 +96,20 @@ class NotifyMsTeamsTestCase(BaseTestCase): |
|
|
|
facts = {f["name"]: f["value"] for f in payload["sections"][0]["facts"]} |
|
|
|
self.assertEqual(facts["Last Ping:"], "Failure, an hour ago") |
|
|
|
|
|
|
|
@patch("hc.api.transports.requests.request") |
|
|
|
def test_it_handles_last_ping_log(self, mock_post): |
|
|
|
mock_post.return_value.status_code = 200 |
|
|
|
|
|
|
|
self.ping.kind = "log" |
|
|
|
self.ping.save() |
|
|
|
|
|
|
|
self.channel.notify(self.check) |
|
|
|
|
|
|
|
args, kwargs = mock_post.call_args |
|
|
|
payload = kwargs["json"] |
|
|
|
facts = {f["name"]: f["value"] for f in payload["sections"][0]["facts"]} |
|
|
|
self.assertEqual(facts["Last Ping:"], "Log, an hour ago") |
|
|
|
|
|
|
|
@patch("hc.api.transports.requests.request") |
|
|
|
def test_it_shows_ignored_nonzero_exitstatus(self, mock_post): |
|
|
|
mock_post.return_value.status_code = 200 |
|
|
|
|
|
@ -142,6 +142,22 @@ class NotifySlackTestCase(BaseTestCase): |
|
|
|
fields = {f["title"]: f["value"] for f in attachment["fields"]} |
|
|
|
self.assertEqual(fields["Last Ping"], "Failure, an hour ago") |
|
|
|
|
|
|
|
@override_settings(SITE_ROOT="http://testserver") |
|
|
|
@patch("hc.api.transports.requests.request") |
|
|
|
def test_it_handles_last_ping_log(self, mock_post): |
|
|
|
self._setup_data("123") |
|
|
|
mock_post.return_value.status_code = 200 |
|
|
|
|
|
|
|
self.ping.kind = "log" |
|
|
|
self.ping.save() |
|
|
|
|
|
|
|
self.channel.notify(self.check) |
|
|
|
|
|
|
|
args, kwargs = mock_post.call_args |
|
|
|
attachment = kwargs["json"]["attachments"][0] |
|
|
|
fields = {f["title"]: f["value"] for f in attachment["fields"]} |
|
|
|
self.assertEqual(fields["Last Ping"], "Log, an hour ago") |
|
|
|
|
|
|
|
@override_settings(SITE_ROOT="http://testserver") |
|
|
|
@patch("hc.api.transports.requests.request") |
|
|
|
def test_it_shows_ignored_nonzero_exitstatus(self, mock_post): |
|
|
|
|
|
@ -86,6 +86,10 @@ |
|
|
|
<span style="background-color: #dff0d8; color: #333333; padding-left: 4px; padding-right: 4px; border-radius: 2px;"> |
|
|
|
Started |
|
|
|
</span> |
|
|
|
{% elif ping.kind == "log" %} |
|
|
|
<span style="background-color: #eeeeee; color: #333333; padding-left: 4px; padding-right: 4px; border-radius: 2px;"> |
|
|
|
Log |
|
|
|
</span> |
|
|
|
{% else %} |
|
|
|
<span style="background-color: #dff0d8; color: #333333; padding-left: 4px; padding-right: 4px; border-radius: 2px;"> |
|
|
|
Success |
|
|
|
|
|
@ -46,6 +46,8 @@ |
|
|
|
{% line %}Last ping type: Failure{% endline %} |
|
|
|
{% elif ping.kind == "start" %} |
|
|
|
{% line %}Last ping type: Started{% endline %} |
|
|
|
{% elif ping.kind == "log" %} |
|
|
|
{% line %}Last ping type: Log{% endline %} |
|
|
|
{% else %} |
|
|
|
{% line %}Last ping type: Success{% endline %} |
|
|
|
{% endif %} |
|
|
|
|
|
@ -33,6 +33,8 @@ |
|
|
|
"value": "Failure, {{ ping.created|naturaltime }}" |
|
|
|
{% elif ping.kind == "start" %} |
|
|
|
"value": "Start, {{ ping.created|naturaltime }}" |
|
|
|
{% elif ping.kind == "log" %} |
|
|
|
"value": "Log, {{ ping.created|naturaltime }}" |
|
|
|
{% else %} |
|
|
|
"value": "Success, {{ ping.created|naturaltime }}" |
|
|
|
{% endif %} |
|
|
|
|
|
@ -55,6 +55,8 @@ |
|
|
|
"value": "Failure, {{ ping.created|naturaltime }}", |
|
|
|
{% elif ping.kind == "start" %} |
|
|
|
"value": "Start, {{ ping.created|naturaltime }}", |
|
|
|
{% elif ping.kind == "log" %} |
|
|
|
"value": "Log, {{ ping.created|naturaltime }}", |
|
|
|
{% else %} |
|
|
|
"value": "Success, {{ ping.created|naturaltime }}", |
|
|
|
{% endif %} |
|
|
|