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.

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