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.

48 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
9 years ago
  1. from django.contrib.auth.models import User
  2. from hc.api.models import Channel
  3. from hc.test import BaseTestCase
  4. class RemoveChannelTestCase(BaseTestCase):
  5. def setUp(self):
  6. super(RemoveChannelTestCase, self).setUp()
  7. self.channel = Channel(user=self.alice, kind="email")
  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_it_handles_bad_uuid(self):
  17. url = "/integrations/not-uuid/remove/"
  18. self.client.login(username="[email protected]", password="password")
  19. r = self.client.post(url)
  20. assert r.status_code == 400
  21. def test_it_checks_owner(self):
  22. url = "/integrations/%s/remove/" % self.channel.code
  23. mallory = User(username="mallory", email="[email protected]")
  24. mallory.set_password("password")
  25. mallory.save()
  26. self.client.login(username="[email protected]", password="password")
  27. r = self.client.post(url)
  28. assert r.status_code == 403
  29. def test_it_handles_missing_uuid(self):
  30. # Valid UUID but there is no channel for it:
  31. url = "/integrations/6837d6ec-fc08-4da5-a67f-08a9ed1ccf62/remove/"
  32. self.client.login(username="[email protected]", password="password")
  33. r = self.client.post(url)
  34. assert r.status_code == 302