Esempio n. 1
0
    def test_smtp_server_not_configured(self, SMTP, info):
        """If smtp_server is not configured, the function should log and return."""
        mail._send_mail('*****@*****.**', '*****@*****.**', 'hi')

        self.assertEqual(SMTP.call_count, 0)
        info.assert_called_once_with(
            'Not sending email: No smtp_server defined')
Esempio n. 2
0
    def test_recipients_refused(self, SMTP, warn):
        """If recipients are refused, a warning should be logged and SMTP should be exited."""
        smtp = SMTP.return_value
        smtp.sendmail.side_effect = smtplib.SMTPRecipientsRefused('nooope!')

        mail._send_mail('*****@*****.**', '*****@*****.**', 'hi')

        SMTP.assert_called_once_with('smtp.fp.o')
        smtp.sendmail.assert_called_once_with('*****@*****.**', ['*****@*****.**'], 'hi')
        warn.assert_called_once_with(
            '"recipient refused" for \'[email protected]\', SMTPRecipientsRefused(\'nooope!\',)')
        smtp.quit.assert_called_once_with()