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

  1. from hc.api.models import Channel
  2. from hc.test import BaseTestCase
  3. class AddPdTestCase(BaseTestCase):
  4. url = "/integrations/add_email/"
  5. def test_instructions_work(self):
  6. self.client.login(username="[email protected]", password="password")
  7. r = self.client.get(self.url)
  8. self.assertContains(r, "Get an email message")
  9. def test_it_creates_channel(self):
  10. form = {"value": "[email protected]"}
  11. self.client.login(username="[email protected]", password="password")
  12. r = self.client.post(self.url, form)
  13. self.assertRedirects(r, "/integrations/")
  14. c = Channel.objects.get()
  15. self.assertEqual(c.kind, "email")
  16. self.assertEqual(c.value, "[email protected]")
  17. self.assertFalse(c.email_verified)
  18. def test_team_access_works(self):
  19. form = {"value": "[email protected]"}
  20. self.client.login(username="[email protected]", password="password")
  21. self.client.post(self.url, form)
  22. ch = Channel.objects.get()
  23. # Added by bob, but should belong to alice (bob has team access)
  24. self.assertEqual(ch.user, self.alice)
  25. def test_it_rejects_bad_email(self):
  26. form = {"value": "not an email address"}
  27. self.client.login(username="[email protected]", password="password")
  28. r = self.client.post(self.url, form)
  29. self.assertContains(r, "Enter a valid email address.")
  30. def test_it_trims_whitespace(self):
  31. form = {"value": " [email protected] "}
  32. self.client.login(username="[email protected]", password="password")
  33. self.client.post(self.url, form)
  34. c = Channel.objects.get()
  35. self.assertEqual(c.value, "[email protected]")