def test_invalid_no_to(self): """Test that sending an invalid email (no to) raises the appropriate exception """ _td = _test_data() del _td['to'] with self.assertRaises(mail.MissingRecipientsError): mail.send(**_td)
def test_invalid_no_sender(self): """Test that sending an invalid email (no sender) raises the appropriate exception """ _td = _test_data() del _td['sender'] with self.assertRaises(mail.MissingSenderError): mail.send(**_td)
def test_valid_email_empty_body(self): """Test that sending a valid email (with an empty body) succeeds """ mail.send(**_test_data(body='')) messages = self.mail_stub.get_sent_messages() self.assertEqual(1, len(messages)) self.assertEqual('*****@*****.**', messages[0].to)
def test_valid_email_no_body(self): """Test that sending a valid email (with no body) succeeds """ _td = _test_data() del _td['body'] mail.send(**_td) messages = self.mail_stub.get_sent_messages() self.assertEqual(1, len(messages)) self.assertEqual('*****@*****.**', messages[0].to)
def test_invalid_email_empty_to(self): """Test that sending an invalid email (empty to) raises the appropriate exception """ _td = _test_data(to='') with self.assertRaises(mail.InvalidEmailError): mail.send(**_td)