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.

49 lines
1.6 KiB

  1. import json
  2. from hc.api.models import Channel
  3. from hc.test import BaseTestCase
  4. class ChannelsTestCase(BaseTestCase):
  5. def test_it_formats_complex_slack_value(self):
  6. ch = Channel(kind="slack", user=self.alice)
  7. ch.value = json.dumps({
  8. "ok": True,
  9. "team_name": "foo-team",
  10. "incoming_webhook": {
  11. "url": "http://example.org",
  12. "channel": "#bar"
  13. }
  14. })
  15. ch.save()
  16. self.client.login(username="[email protected]", password="password")
  17. r = self.client.get("/integrations/")
  18. self.assertContains(r, "foo-team", status_code=200)
  19. self.assertContains(r, "#bar")
  20. def test_it_shows_webhook_post_data(self):
  21. ch = Channel(kind="webhook", user=self.alice)
  22. ch.value = "http://down.example.com\nhttp://up.example.com\nfoobar"
  23. ch.save()
  24. self.client.login(username="[email protected]", password="password")
  25. r = self.client.get("/integrations/")
  26. self.assertEqual(r.status_code, 200)
  27. self.assertContains(r, "<td>http://down.example.com</td>")
  28. self.assertContains(r, "<td>http://up.example.com</td>")
  29. self.assertContains(r, "<td>foobar</td>")
  30. def test_it_shows_pushover_details(self):
  31. ch = Channel(kind="po", user=self.alice)
  32. ch.value = "fake-key|0"
  33. ch.save()
  34. self.client.login(username="[email protected]", password="password")
  35. r = self.client.get("/integrations/")
  36. self.assertEqual(r.status_code, 200)
  37. self.assertContains(r, "fake-key")
  38. self.assertContains(r, "(normal priority)")