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.1 KiB

  1. from hc.api.models import Channel
  2. from hc.test import BaseTestCase
  3. class AddMsTeamsTestCase(BaseTestCase):
  4. def setUp(self):
  5. super().setUp()
  6. self.url = "/projects/%s/add_msteams/" % 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, "Integration Settings", status_code=200)
  11. def test_it_works(self):
  12. form = {"value": "https://example.com/foo"}
  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, "msteams")
  18. self.assertEqual(c.value, "https://example.com/foo")
  19. self.assertEqual(c.project, self.project)
  20. def test_it_requires_rw_access(self):
  21. self.bobs_membership.rw = False
  22. self.bobs_membership.save()
  23. self.client.login(username="[email protected]", password="password")
  24. r = self.client.get(self.url)
  25. self.assertEqual(r.status_code, 403)