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.

56 lines
1.9 KiB

9 years ago
9 years ago
9 years ago
9 years ago
6 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
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(RemoveChannelTestCase, self).setUp()
  6. self.channel = Channel(user=self.alice, kind="email")
  7. self.channel.project = self.project
  8. self.channel.value = "[email protected]"
  9. self.channel.save()
  10. def test_it_works(self):
  11. url = "/integrations/%s/remove/" % self.channel.code
  12. self.client.login(username="[email protected]", password="password")
  13. r = self.client.post(url)
  14. self.assertRedirects(r, "/integrations/")
  15. assert Channel.objects.count() == 0
  16. def test_team_access_works(self):
  17. url = "/integrations/%s/remove/" % self.channel.code
  18. self.client.login(username="[email protected]", password="password")
  19. self.client.post(url)
  20. assert Channel.objects.count() == 0
  21. def test_it_handles_bad_uuid(self):
  22. url = "/integrations/not-uuid/remove/"
  23. self.client.login(username="[email protected]", password="password")
  24. r = self.client.post(url)
  25. self.assertEqual(r.status_code, 404)
  26. def test_it_checks_owner(self):
  27. url = "/integrations/%s/remove/" % self.channel.code
  28. self.client.login(username="[email protected]", password="password")
  29. r = self.client.post(url)
  30. assert r.status_code == 403
  31. def test_it_handles_missing_uuid(self):
  32. # Valid UUID but there is no channel for it:
  33. url = "/integrations/6837d6ec-fc08-4da5-a67f-08a9ed1ccf62/remove/"
  34. self.client.login(username="[email protected]", password="password")
  35. r = self.client.post(url)
  36. assert r.status_code == 302
  37. def test_it_rejects_get(self):
  38. url = "/integrations/%s/remove/" % self.channel.code
  39. self.client.login(username="[email protected]", password="password")
  40. r = self.client.get(url)
  41. self.assertEqual(r.status_code, 405)