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.

29 lines
1.0 KiB

  1. from django.core import mail
  2. from hc.api.models import Channel
  3. from hc.test import BaseTestCase
  4. class SendTestNotificationTestCase(BaseTestCase):
  5. def setUp(self):
  6. super(SendTestNotificationTestCase, self).setUp()
  7. self.channel = Channel(kind="email", project=self.project)
  8. self.channel.email_verified = True
  9. self.channel.value = "[email protected]"
  10. self.channel.save()
  11. self.url = "/integrations/%s/test/" % self.channel.code
  12. def test_it_sends_test_email(self):
  13. self.client.login(username="[email protected]", password="password")
  14. r = self.client.post(self.url, {}, follow=True)
  15. self.assertRedirects(r, "/integrations/")
  16. self.assertContains(r, "Test notification sent!")
  17. # And email should have been sent
  18. self.assertEqual(len(mail.outbox), 1)
  19. email = mail.outbox[0]
  20. self.assertEqual(email.to[0], "[email protected]")
  21. self.assertTrue("X-Bounce-Url" in email.extra_headers)
  22. self.assertTrue("List-Unsubscribe" in email.extra_headers)