forked from GithubBackups/healthchecks
Fix bug with pinging webhook
This commit is contained in:
parent
058101b941
commit
7240ce9ba8
@ -4,7 +4,7 @@ python:
|
|||||||
- "3.4"
|
- "3.4"
|
||||||
install:
|
install:
|
||||||
- pip install -r requirements.txt
|
- pip install -r requirements.txt
|
||||||
- pip install coveralls mysqlclient
|
- pip install coveralls mock mysqlclient
|
||||||
env:
|
env:
|
||||||
- DB=sqlite
|
- DB=sqlite
|
||||||
- DB=mysql
|
- DB=mysql
|
||||||
|
@ -117,7 +117,7 @@ class Channel(models.Model):
|
|||||||
}
|
}
|
||||||
emails.alert(self.value, ctx)
|
emails.alert(self.value, ctx)
|
||||||
n.save()
|
n.save()
|
||||||
elif self.kind == "webhook" and self.status == "down":
|
elif self.kind == "webhook" and check.status == "down":
|
||||||
r = requests.get(self.value)
|
r = requests.get(self.value)
|
||||||
n.status = r.status_code
|
n.status = r.status_code
|
||||||
n.save()
|
n.save()
|
||||||
|
24
hc/api/tests/test_notify.py
Normal file
24
hc/api/tests/test_notify.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
from django.contrib.auth.models import User
|
||||||
|
from django.test import TestCase
|
||||||
|
from mock import patch
|
||||||
|
|
||||||
|
from hc.api.models import Channel, Check
|
||||||
|
|
||||||
|
|
||||||
|
class NotifyTestCase(TestCase):
|
||||||
|
|
||||||
|
@patch("hc.api.models.requests")
|
||||||
|
def test_webhook(self, mock_requests):
|
||||||
|
alice = User(username="alice")
|
||||||
|
alice.save()
|
||||||
|
|
||||||
|
check = Check()
|
||||||
|
check.status = "down"
|
||||||
|
check.save()
|
||||||
|
|
||||||
|
channel = Channel(user=alice, kind="webhook", value="http://example")
|
||||||
|
channel.save()
|
||||||
|
channel.checks.add(check)
|
||||||
|
|
||||||
|
channel.notify(check)
|
||||||
|
mock_requests.get.assert_called_with(u"http://example")
|
Loading…
x
Reference in New Issue
Block a user