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.

40 lines
1.4 KiB

  1. from hc.api.models import Channel
  2. from hc.test import BaseTestCase
  3. class AddVictorOpsTestCase(BaseTestCase):
  4. def setUp(self):
  5. super().setUp()
  6. self.url = "/projects/%s/add_victorops/" % self.project.code
  7. def test_instructions_work(self):
  8. self.client.login(username="[email protected]", password="password")
  9. r = self.client.get(self.url)
  10. self.assertContains(r, "incident management system")
  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(self.url, form)
  15. self.assertRedirects(r, self.channels_url)
  16. c = Channel.objects.get()
  17. self.assertEqual(c.kind, "victorops")
  18. self.assertEqual(c.value, "http://example.org")
  19. self.assertEqual(c.project, self.project)
  20. def test_it_rejects_bad_url(self):
  21. form = {"value": "not an URL"}
  22. self.client.login(username="[email protected]", password="password")
  23. r = self.client.post(self.url, form)
  24. self.assertContains(r, "Enter a valid URL")
  25. def test_it_requires_rw_access(self):
  26. self.bobs_membership.rw = False
  27. self.bobs_membership.save()
  28. self.client.login(username="[email protected]", password="password")
  29. r = self.client.get(self.url)
  30. self.assertEqual(r.status_code, 403)