mirror of
https://github.com/healthchecks/healthchecks.git
synced 2025-04-10 23:40:11 +00:00
parent
bc5354b05b
commit
fd0d58e96d
3 changed files with 15 additions and 5 deletions
|
@ -1,4 +1,3 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
|
@ -39,6 +38,7 @@ class NotifyZulipTestCase(BaseTestCase):
|
|||
self.flip.created = now()
|
||||
self.flip.old_status = "new"
|
||||
self.flip.new_status = "down"
|
||||
self.flip.reason = "timeout"
|
||||
|
||||
def definition(self, **kwargs: str) -> dict[str, str]:
|
||||
d = {
|
||||
|
@ -62,13 +62,23 @@ class NotifyZulipTestCase(BaseTestCase):
|
|||
|
||||
payload = mock_post.call_args.kwargs["data"]
|
||||
self.assertEqual(payload["topic"], "Foobar is DOWN")
|
||||
self.assertIn("is **DOWN**.", payload["content"])
|
||||
self.assertIn("Last ping was 10 minutes ago.", payload["content"])
|
||||
self.assertIn("is **DOWN**", payload["content"])
|
||||
self.assertIn("grace time passed", payload["content"])
|
||||
|
||||
# payload should not contain check's code
|
||||
serialized = json.dumps(payload)
|
||||
self.assertNotIn(str(self.check.code), serialized)
|
||||
|
||||
@patch("hc.api.transports.curl.request", autospec=True)
|
||||
def test_it_handles_reason_fail(self, mock_post: Mock) -> None:
|
||||
mock_post.return_value.status_code = 200
|
||||
|
||||
self.flip.reason = "fail"
|
||||
self.channel.notify(self.flip)
|
||||
|
||||
payload = mock_post.call_args.kwargs["data"]
|
||||
self.assertIn("received a failure signal", payload["content"])
|
||||
|
||||
@patch("hc.api.transports.curl.request", autospec=True)
|
||||
def test_it_uses_custom_topic(self, mock_post: Mock) -> None:
|
||||
self.channel.value = json.dumps(self.definition(topic="foo"))
|
||||
|
|
|
@ -1333,9 +1333,9 @@ class Zulip(HttpTransport):
|
|||
auth = (self.channel.zulip.bot_email, self.channel.zulip.api_key)
|
||||
content = tmpl(
|
||||
"zulip_content.html",
|
||||
flip=flip,
|
||||
check=flip.owner,
|
||||
status=flip.new_status,
|
||||
ping=self.last_ping(flip),
|
||||
)
|
||||
data = {
|
||||
"type": self.channel.zulip.mtype,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{% load hc_extras humanize %}
|
||||
|
||||
[{{ check.name_then_code }}]({{ check.cloaked_url }}) is **{{ status|upper }}**. {% if status == "down" and ping %}Last ping was {{ ping.created|naturaltime }}.{% endif %}
|
||||
[{{ check.name_then_code }}]({{ check.cloaked_url }}) is **{{ status|upper }}**{% if flip.reason %} ({{ flip.reason_long }}){% endif %}.
|
||||
|
||||
{% if check.desc %}
|
||||
---
|
||||
|
|
Loading…
Add table
Reference in a new issue