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.

29 lines
1.1 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 test_instructions_work(self):
  7. self.client.login(username="[email protected]", password="password")
  8. r = self.client.get("/integrations/add_apprise/")
  9. self.assertContains(r, "Integration Settings", status_code=200)
  10. def test_it_works(self):
  11. form = {"url": "json://example.org"}
  12. self.client.login(username="[email protected]", password="password")
  13. r = self.client.post("/integrations/add_apprise/", form)
  14. self.assertRedirects(r, "/integrations/")
  15. c = Channel.objects.get()
  16. self.assertEqual(c.kind, "apprise")
  17. self.assertEqual(c.value, "json://example.org")
  18. self.assertEqual(c.project, self.project)
  19. @override_settings(APPRISE_ENABLED=False)
  20. def test_it_requires_client_id(self):
  21. self.client.login(username="[email protected]", password="password")
  22. r = self.client.get("/integrations/add_apprise/")
  23. self.assertEqual(r.status_code, 404)