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.

30 lines
1.0 KiB

  1. from hc.api.models import Channel
  2. from hc.test import BaseTestCase
  3. class AddVictorOpsTestCase(BaseTestCase):
  4. url = "/integrations/add_victorops/"
  5. def test_instructions_work(self):
  6. self.client.login(username="[email protected]", password="password")
  7. r = self.client.get(self.url)
  8. self.assertContains(r, "incident management system")
  9. def test_it_works(self):
  10. form = {"value": "http://example.org"}
  11. self.client.login(username="[email protected]", password="password")
  12. r = self.client.post(self.url, form)
  13. self.assertRedirects(r, "/integrations/")
  14. c = Channel.objects.get()
  15. self.assertEqual(c.kind, "victorops")
  16. self.assertEqual(c.value, "http://example.org")
  17. self.assertEqual(c.project, self.project)
  18. def test_it_rejects_bad_url(self):
  19. form = {"value": "not an URL"}
  20. self.client.login(username="[email protected]", password="password")
  21. r = self.client.post(self.url, form)
  22. self.assertContains(r, "Enter a valid URL")