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.

33 lines
1.2 KiB

  1. from django.test.utils import override_settings
  2. from hc.api.models import Channel
  3. from hc.test import BaseTestCase
  4. class AddSlackTestCase(BaseTestCase):
  5. @override_settings(SLACK_CLIENT_ID=None)
  6. def test_instructions_work(self):
  7. self.client.login(username="[email protected]", password="password")
  8. r = self.client.get("/integrations/add_slack/")
  9. self.assertContains(r, "Integration Settings", status_code=200)
  10. @override_settings(SLACK_CLIENT_ID=None)
  11. def test_it_works(self):
  12. form = {"value": "http://example.org"}
  13. self.client.login(username="[email protected]", password="password")
  14. r = self.client.post("/integrations/add_slack/", form)
  15. self.assertRedirects(r, "/integrations/")
  16. c = Channel.objects.get()
  17. self.assertEqual(c.kind, "slack")
  18. self.assertEqual(c.value, "http://example.org")
  19. self.assertEqual(c.project, self.project)
  20. @override_settings(SLACK_CLIENT_ID=None)
  21. def test_it_rejects_bad_url(self):
  22. form = {"value": "not an URL"}
  23. self.client.login(username="[email protected]", password="password")
  24. r = self.client.post("/integrations/add_slack/", form)
  25. self.assertContains(r, "Enter a valid URL")