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:
parent
f24a1dbc25
commit
a485bea2b2
3 changed files with 8 additions and 7 deletions
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue