Exemplo n.º 1
0
    def test_send_mail_raises_exception_when_connect_to_mailserver_fails(self):
        self.msc.side_effect = SMTPConnectError("a", "b")
        with self.assertRaises(SMTPConnectError):
            send_mail(**self.send_mail_arguments)

        # also catch socket.error
        self.msc.side_effect = socket.error()
        with self.assertRaises(SMTPConnectError):
            send_mail(**self.send_mail_arguments)
Exemplo n.º 2
0
 def test_send_mail_returns_queue_id(self):
     queueid = send_mail(**self.send_mail_arguments)
     self.assertEqual(queueid, "8E220500567")
Exemplo n.º 3
0
 def test_send_mail_raises_exception_when_no_queueid_found_in_data_response(self):
     self.mock_smtp.data.return_value = (250, "not ok")
     with self.assertRaises(ValueError):
         send_mail(**self.send_mail_arguments)
Exemplo n.º 4
0
 def test_send_mail_raises_exception_when_sending_body_fails(self):
     self.mock_smtp.data.return_value = (0, "not ok")
     with self.assertRaises(SMTPDataError):
         send_mail(**self.send_mail_arguments)
Exemplo n.º 5
0
 def test_send_mail_raises_exception_when_setting_recipient_fails(self):
     self.mock_smtp.rcpt.return_value = (0, "Sender Refused")
     with self.assertRaises(SMTPRecipientsRefused):
         send_mail(**self.send_mail_arguments)
Exemplo n.º 6
0
 def test_send_mail_does_not_require_arguments(self):
     send_mail()
Exemplo n.º 7
0
 def test_send_mail_accepts_smtphost_smtpport_recipient_sender_subject_and_body(self):
     send_mail(self.send_mail_arguments)