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

  1. import json
  2. from django.test import TestCase
  3. from hc.api.models import Check, Ping
  4. class EmailTestCase(TestCase):
  5. def test_it_works(self):
  6. check = Check()
  7. check.save()
  8. payload = [{
  9. "event": "inbound",
  10. "msg": {
  11. "raw_msg": "This is raw message",
  12. "to": [
  13. ["[email protected]", "Somebody"],
  14. ["%s@example.com" % check.code, "Healthchecks"]
  15. ]
  16. }
  17. }]
  18. data = {"mandrill_events": json.dumps(payload)}
  19. r = self.client.post("/handle_email/", data=data)
  20. assert r.status_code == 200
  21. same_check = Check.objects.get(code=check.code)
  22. assert same_check.status == "up"
  23. pings = list(Ping.objects.all())
  24. assert pings[0].scheme == "email"
  25. def test_it_rejects_get(self):
  26. r = self.client.get("/handle_email/")
  27. assert r.status_code == 400