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.

41 lines
1.5 KiB

  1. from hc.api.models import Channel
  2. from hc.test import BaseTestCase
  3. from django.test.utils import override_settings
  4. @override_settings(APPRISE_ENABLED=True)
  5. class AddAppriseTestCase(BaseTestCase):
  6. def setUp(self):
  7. super(AddAppriseTestCase, self).setUp()
  8. self.url = "/projects/%s/add_apprise/" % self.project.code
  9. def test_instructions_work(self):
  10. self.client.login(username="[email protected]", password="password")
  11. r = self.client.get(self.url)
  12. self.assertContains(r, "Integration Settings", status_code=200)
  13. def test_it_works(self):
  14. form = {"url": "json://example.org"}
  15. self.client.login(username="[email protected]", password="password")
  16. r = self.client.post(self.url, form)
  17. self.assertRedirects(r, self.channels_url)
  18. c = Channel.objects.get()
  19. self.assertEqual(c.kind, "apprise")
  20. self.assertEqual(c.value, "json://example.org")
  21. self.assertEqual(c.project, self.project)
  22. @override_settings(APPRISE_ENABLED=False)
  23. def test_it_requires_client_id(self):
  24. self.client.login(username="[email protected]", password="password")
  25. r = self.client.get(self.url)
  26. self.assertEqual(r.status_code, 404)
  27. def test_it_requires_rw_access(self):
  28. self.bobs_membership.rw = False
  29. self.bobs_membership.save()
  30. self.client.login(username="[email protected]", password="password")
  31. r = self.client.get(self.url)
  32. self.assertEqual(r.status_code, 403)