You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

37 lines
963 B

import json
from django.test import TestCase
from hc.api.models import Check, Ping
class EmailTestCase(TestCase):
def test_it_works(self):
check = Check()
check.save()
payload = [{
"event": "inbound",
"msg": {
"raw_msg": "This is raw message",
"to": [
["[email protected]", "Somebody"],
["%s@example.com" % check.code, "Healthchecks"]
]
}
}]
data = {"mandrill_events": json.dumps(payload)}
r = self.client.post("/handle_email/", data=data)
assert r.status_code == 200
same_check = Check.objects.get(code=check.code)
assert same_check.status == "up"
pings = list(Ping.objects.all())
assert pings[0].scheme == "email"
def test_it_rejects_get(self):
r = self.client.get("/handle_email/")
assert r.status_code == 400