|
|
@ -1,8 +1,11 @@ |
|
|
|
from django.core import mail |
|
|
|
from django.test.utils import override_settings |
|
|
|
|
|
|
|
from hc.api.models import Channel |
|
|
|
from hc.test import BaseTestCase |
|
|
|
|
|
|
|
|
|
|
|
class AddPdTestCase(BaseTestCase): |
|
|
|
class AddEmailTestCase(BaseTestCase): |
|
|
|
url = "/integrations/add_email/" |
|
|
|
|
|
|
|
def test_instructions_work(self): |
|
|
@ -23,6 +26,12 @@ class AddPdTestCase(BaseTestCase): |
|
|
|
self.assertFalse(c.email_verified) |
|
|
|
self.assertEqual(c.project, self.project) |
|
|
|
|
|
|
|
# Email should have been sent |
|
|
|
self.assertEqual(len(mail.outbox), 1) |
|
|
|
|
|
|
|
email = mail.outbox[0] |
|
|
|
self.assertTrue(email.subject.startswith("Verify email address on")) |
|
|
|
|
|
|
|
def test_team_access_works(self): |
|
|
|
form = {"value": "[email protected]"} |
|
|
|
|
|
|
@ -48,3 +57,19 @@ class AddPdTestCase(BaseTestCase): |
|
|
|
|
|
|
|
c = Channel.objects.get() |
|
|
|
self.assertEqual(c.value, "[email protected]") |
|
|
|
|
|
|
|
@override_settings(EMAIL_USE_VERIFICATION=False) |
|
|
|
def test_it_auto_verifies_email(self): |
|
|
|
form = {"value": "[email protected]"} |
|
|
|
|
|
|
|
self.client.login(username="[email protected]", password="password") |
|
|
|
r = self.client.post(self.url, form) |
|
|
|
self.assertRedirects(r, "/integrations/") |
|
|
|
|
|
|
|
c = Channel.objects.get() |
|
|
|
self.assertEqual(c.kind, "email") |
|
|
|
self.assertEqual(c.value, "[email protected]") |
|
|
|
self.assertTrue(c.email_verified) |
|
|
|
|
|
|
|
# Email should *not* have been sent |
|
|
|
self.assertEqual(len(mail.outbox), 0) |