From fc415b39c880aed63368b657f879eb20b851ca5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Sat, 31 Dec 2016 16:18:27 +0200 Subject: [PATCH] Better formatting for Pushover notifications in log --- hc/front/tests/test_log.py | 26 +++++++++++++++++++++++++- templates/front/log.html | 2 ++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/hc/front/tests/test_log.py b/hc/front/tests/test_log.py index 1bf31882..736db3e2 100644 --- a/hc/front/tests/test_log.py +++ b/hc/front/tests/test_log.py @@ -1,4 +1,4 @@ -from hc.api.models import Check, Ping +from hc.api.models import Channel, Check, Notification, Ping from hc.test import BaseTestCase @@ -48,3 +48,27 @@ class LogTestCase(BaseTestCase): self.client.login(username="charlie@example.org", password="password") r = self.client.get(url) assert r.status_code == 403 + + def test_it_shows_pushover_notifications(self): + ch = Channel(kind="po", user=self.alice) + ch.save() + + Notification(owner=self.check, channel=ch, check_status="down").save() + + url = "/checks/%s/log/" % self.check.code + + self.client.login(username="alice@example.org", password="password") + r = self.client.get(url) + self.assertContains(r, "Sent a Pushover notification", status_code=200) + + def test_it_shows_webhook_notifications(self): + ch = Channel(kind="webhook", user=self.alice, value="foo/$NAME") + ch.save() + + Notification(owner=self.check, channel=ch, check_status="down").save() + + url = "/checks/%s/log/" % self.check.code + + self.client.login(username="alice@example.org", password="password") + r = self.client.get(url) + self.assertContains(r, "Called webhook foo/$NAME", status_code=200) diff --git a/templates/front/log.html b/templates/front/log.html index 77f86148..fbd1e60f 100644 --- a/templates/front/log.html +++ b/templates/front/log.html @@ -93,6 +93,8 @@ Sent alert to OpsGenie {% elif event.channel.kind == "hipchat" %} Sent alert to HipChat + {% elif event.channel.kind == "po" %} + Sent a Pushover notification {% elif event.channel.kind == "webhook" %} Called webhook {{ event.channel.value_down }} {% else %}