def test_form_valid_submission_email(self): data = { 'name': 'Jane Doe', 'email': '*****@*****.**', 'email_text': 'Hello world.' } email_form = EmailForm(data=data) assert email_form.is_valid() email_form.send_mail(self.post) assert len(mail.outbox) > 0
def test_form_invalid_failure(self): data = { 'name': None, 'email': None, 'email_text': None } email_form = EmailForm(data=data) assert not email_form.is_valid() with self.assertRaises(InvalidMailError): email_form.send_mail(self.post) assert len(mail.outbox) == 0