0
0
Fork 0
mirror of https://github.com/healthchecks/healthchecks.git synced 2025-04-11 15:51:19 +00:00

Fix the Pushullet integration to use Flip.new_status

This commit is contained in:
Pēteris Caune 2024-04-12 15:08:25 +03:00
parent f24a1dbc25
commit a485bea2b2
No known key found for this signature in database
GPG key ID: E28D7679E9A9EDE2
3 changed files with 8 additions and 7 deletions

View file

@ -17,7 +17,9 @@ class NotifyPushbulletTestCase(BaseTestCase):
self.check = Check(project=self.project)
self.check.name = "Foo"
self.check.status = "up"
# Transport classes should use flip.new_status,
# so the status "paused" should not appear anywhere
self.check.status = "paused"
self.check.last_ping = now() - td(minutes=61)
self.check.save()
@ -30,12 +32,11 @@ class NotifyPushbulletTestCase(BaseTestCase):
self.flip = Flip(owner=self.check)
self.flip.created = now()
self.flip.old_status = "new"
self.flip.new_status = "down"
self.flip.new_status = "up"
@patch("hc.api.transports.curl.request", autospec=True)
def test_it_works(self, mock_post: Mock) -> None:
self.check.status = "down"
self.check.save()
self.flip.new_status = "down"
mock_post.return_value.status_code = 200
self.channel.notify(self.flip)

View file

@ -627,8 +627,8 @@ class PagerTree(HttpTransport):
class Pushbullet(HttpTransport):
def notify(self, check: Check, notification: Notification) -> None:
text = tmpl("pushbullet_message.html", check=check)
def notify_flip(self, flip: Flip, notification: Notification) -> None:
text = tmpl("pushbullet_message.html", check=flip.owner, status=flip.new_status)
url = "https://api.pushbullet.com/v2/pushes"
headers = {
"Access-Token": self.channel.value,

View file

@ -1,6 +1,6 @@
{% load humanize %}
{% if check.status == "down" %}
{% if status == "down" %}
The check "{{ check.name_then_code|safe }}" is DOWN.{% if check.last_ping %} Last ping was {{ check.last_ping|naturaltime }}.{% endif %}
{% else %}
The check "{{ check.name_then_code|safe }}" received a ping and is now UP.