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.

57 lines
2.0 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. from hc.api.models import Channel
  2. from hc.test import BaseTestCase
  3. class RemoveChannelTestCase(BaseTestCase):
  4. def setUp(self):
  5. super().setUp()
  6. self.channel = Channel(project=self.project, kind="email")
  7. self.channel.value = "[email protected]"
  8. self.channel.save()
  9. self.url = "/integrations/%s/remove/" % self.channel.code
  10. def test_it_works(self):
  11. self.client.login(username="[email protected]", password="password")
  12. r = self.client.post(self.url)
  13. self.assertRedirects(r, self.channels_url)
  14. assert Channel.objects.count() == 0
  15. def test_team_access_works(self):
  16. self.client.login(username="[email protected]", password="password")
  17. self.client.post(self.url)
  18. assert Channel.objects.count() == 0
  19. def test_it_handles_bad_uuid(self):
  20. url = "/integrations/not-uuid/remove/"
  21. self.client.login(username="[email protected]", password="password")
  22. r = self.client.post(url)
  23. self.assertEqual(r.status_code, 404)
  24. def test_it_checks_owner(self):
  25. self.client.login(username="[email protected]", password="password")
  26. r = self.client.post(self.url)
  27. self.assertEqual(r.status_code, 404)
  28. def test_it_handles_missing_uuid(self):
  29. # Valid UUID but there is no channel for it:
  30. url = "/integrations/6837d6ec-fc08-4da5-a67f-08a9ed1ccf62/remove/"
  31. self.client.login(username="[email protected]", password="password")
  32. r = self.client.post(url)
  33. self.assertEqual(r.status_code, 404)
  34. def test_it_rejects_get(self):
  35. self.client.login(username="[email protected]", password="password")
  36. r = self.client.get(self.url)
  37. self.assertEqual(r.status_code, 405)
  38. def test_it_requires_rw_access(self):
  39. self.bobs_membership.role = "r"
  40. self.bobs_membership.save()
  41. self.client.login(username="[email protected]", password="password")
  42. r = self.client.post(self.url)
  43. self.assertEqual(r.status_code, 403)