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

from hc.api.models import Channel
from hc.test import BaseTestCase
class AddPdTestCase(BaseTestCase):
url = "/integrations/add_email/"
def test_instructions_work(self):
self.client.login(username="[email protected]", password="password")
r = self.client.get(self.url)
self.assertContains(r, "Get an email message")
def test_it_creates_channel(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.assertFalse(c.email_verified)
self.assertEqual(c.project, self.project)
def test_team_access_works(self):
form = {"value": "[email protected]"}
self.client.login(username="[email protected]", password="password")
self.client.post(self.url, form)
ch = Channel.objects.get()
# Added by bob, but should belong to alice (bob has team access)
self.assertEqual(ch.project, self.project)
def test_it_rejects_bad_email(self):
form = {"value": "not an email address"}
self.client.login(username="[email protected]", password="password")
r = self.client.post(self.url, form)
self.assertContains(r, "Enter a valid email address.")
def test_it_trims_whitespace(self):
form = {"value": " [email protected] "}
self.client.login(username="[email protected]", password="password")
self.client.post(self.url, form)
c = Channel.objects.get()
self.assertEqual(c.value, "[email protected]")