forked from GithubBackups/healthchecks
Fix Pushover and HipChat.
This commit is contained in:
parent
2c04a42a57
commit
a71ce64579
@ -141,7 +141,7 @@ class Channel(models.Model):
|
||||
elif self.kind == "pd":
|
||||
return transports.PagerDuty(self)
|
||||
elif self.kind == "po":
|
||||
return transports.Pushover()
|
||||
return transports.Pushover(self)
|
||||
else:
|
||||
raise NotImplementedError("Unknown channel kind: %s" % self.kind)
|
||||
|
||||
|
@ -131,6 +131,19 @@ class NotifyTestCase(BaseTestCase):
|
||||
@patch("hc.api.transports.requests.post")
|
||||
def test_hipchat(self, mock_post):
|
||||
self._setup_data("hipchat", "123")
|
||||
mock_post.return_value.status_code = 204
|
||||
|
||||
self.channel.notify(self.check)
|
||||
n = Notification.objects.first()
|
||||
self.assertEqual(n.error, "")
|
||||
|
||||
args, kwargs = mock_post.call_args
|
||||
json = kwargs["json"]
|
||||
self.assertIn("DOWN", json["message"])
|
||||
|
||||
@patch("hc.api.transports.requests.post")
|
||||
def test_pushover(self, mock_post):
|
||||
self._setup_data("po", "123|0")
|
||||
mock_post.return_value.status_code = 200
|
||||
|
||||
self.channel.notify(self.check)
|
||||
@ -138,4 +151,4 @@ class NotifyTestCase(BaseTestCase):
|
||||
|
||||
args, kwargs = mock_post.call_args
|
||||
json = kwargs["json"]
|
||||
self.assertIn("DOWN", json["message"])
|
||||
self.assertIn("DOWN", json["title"])
|
||||
|
@ -67,7 +67,7 @@ class Webhook(Transport):
|
||||
headers = {"User-Agent": "healthchecks.io"}
|
||||
try:
|
||||
r = requests.get(self.channel.value, timeout=5, headers=headers)
|
||||
if r.status_code not in (200, 201):
|
||||
if r.status_code not in (200, 201, 204):
|
||||
return "Received status code %d" % r.status_code
|
||||
except requests.exceptions.Timeout:
|
||||
# Well, we tried
|
||||
@ -81,7 +81,7 @@ class JsonTransport(Transport):
|
||||
headers = {"User-Agent": "healthchecks.io"}
|
||||
try:
|
||||
r = requests.post(url, json=payload, timeout=5, headers=headers)
|
||||
if r.status_code not in (200, 201):
|
||||
if r.status_code not in (200, 201, 204):
|
||||
return "Received status code %d" % r.status_code
|
||||
except requests.exceptions.Timeout:
|
||||
# Well, we tried
|
||||
|
Loading…
x
Reference in New Issue
Block a user