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.

50 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. self.assertEqual(c.project, self.project)
  19. def test_team_access_works(self):
  20. form = {"value": "[email protected]"}
  21. self.client.login(username="[email protected]", password="password")
  22. self.client.post(self.url, form)
  23. ch = Channel.objects.get()
  24. # Added by bob, but should belong to alice (bob has team access)
  25. self.assertEqual(ch.user, self.alice)
  26. def test_it_rejects_bad_email(self):
  27. form = {"value": "not an email address"}
  28. self.client.login(username="[email protected]", password="password")
  29. r = self.client.post(self.url, form)
  30. self.assertContains(r, "Enter a valid email address.")
  31. def test_it_trims_whitespace(self):
  32. form = {"value": " [email protected] "}
  33. self.client.login(username="[email protected]", password="password")
  34. self.client.post(self.url, form)
  35. c = Channel.objects.get()
  36. self.assertEqual(c.value, "[email protected]")