def test_simple_email_building(self): email = make_email('test_email1', to='*****@*****.**', context={'name': 'foo'}) self.assertEqual(email.subject, 'Subject1: foo') self.assertEqual(email.body, '<b>Mail1: foo</b>\n')
def test_proper_handlign_different_uses_cases(self): from django.core import mail email1 = make_email( 'test_email1', to='*****@*****.**', context={'name': 'foo'}) email2 = make_email( 'test_email2', to='*****@*****.**', context={'name': 'foo'}) email3 = make_email( 'test_email3', to='*****@*****.**', context={'name': 'foo'}) self.assertIsInstance(email1, mail.EmailMessage) self.assertEqual(email1.content_subtype, 'html') self.assertIsInstance(email2, mail.EmailMultiAlternatives) self.assertIsInstance(email3, mail.EmailMessage) self.assertEqual(email3.content_subtype, 'plain')
def test_proper_handlign_different_uses_cases(self): from django.core import mail email1 = make_email( 'test_email1', to='*****@*****.**', context={'name': 'foo'}) email2 = make_email( 'test_email2', to='*****@*****.**', context={'name': 'foo'}) email3 = make_email( 'test_email3', to='*****@*****.**', context={'name': 'foo'}) self.assertIsInstance(email1, mail.EmailMessage) self.assertEqual(email1.content_subtype, 'html') self.assertIsInstance(email2, mail.EmailMultiAlternatives) self.assertIsInstance(email3, mail.EmailMessage) self.assertEqual(email3.content_subtype, 'plain')
def test_error_when_there_is_no_email_body_templates(self): with self.assertRaises(exceptions.TemplateNotFound): email = make_email( 'test_email_error_with_no_body', to='*****@*****.**', context={'name': 'foo'})
def test_error_when_there_is_no_email_body_templates(self): with self.assertRaises(exceptions.TemplateNotFound): email = make_email( 'test_email_error_with_no_body', to='*****@*****.**', context={'name': 'foo'})
def test_simple_email_building(self): email = make_email( 'test_email1', to='*****@*****.**', context={'name': 'foo'}) self.assertEqual(email.subject, 'Subject1: foo') self.assertEqual(email.body, '<b>Mail1: foo</b>\n')