예제 #1
0
 def test_send_mime_dryrun(self, mock_smtp, mock_smtp_ssl):
     utils.send_MIME_email("from",
                           "to",
                           MIMEMultipart(),
                           app.config,
                           dryrun=True)
     assert not mock_smtp.called
     assert not mock_smtp_ssl.called
예제 #2
0
 def test_send_mime_noauth(self, mock_smtp, mock_smtp_ssl):
     app.config["SMTP_USER"] = None
     app.config["SMTP_PASSWORD"] = None
     mock_smtp.return_value = mock.Mock()
     mock_smtp_ssl.return_value = mock.Mock()
     utils.send_MIME_email("from", "to", MIMEMultipart(), app.config, dryrun=False)
     assert not mock_smtp_ssl.called
     mock_smtp.assert_called_with(app.config["SMTP_HOST"], app.config["SMTP_PORT"])
     assert not mock_smtp.login.called
예제 #3
0
 def test_send_mime_ssl(self, mock_smtp, mock_smtp_ssl):
     app.config["SMTP_SSL"] = True
     mock_smtp.return_value = mock.Mock()
     mock_smtp_ssl.return_value = mock.Mock()
     utils.send_MIME_email("from", "to", MIMEMultipart(), app.config, dryrun=False)
     assert not mock_smtp.called
     mock_smtp_ssl.assert_called_with(
         app.config["SMTP_HOST"], app.config["SMTP_PORT"]
     )
예제 #4
0
 def test_send_mime_ssl(self, mock_smtp, mock_smtp_ssl):
     app.config['SMTP_SSL'] = True
     mock_smtp.return_value = mock.Mock()
     mock_smtp_ssl.return_value = mock.Mock()
     utils.send_MIME_email(
         'from', 'to', MIMEMultipart(), app.config, dryrun=False)
     assert not mock_smtp.called
     mock_smtp_ssl.assert_called_with(
         app.config.get('SMTP_HOST'),
         app.config.get('SMTP_PORT'),
     )
예제 #5
0
 def test_send_mime(self, mock_smtp, mock_smtp_ssl):
     mock_smtp.return_value = mock.Mock()
     mock_smtp_ssl.return_value = mock.Mock()
     msg = MIMEMultipart()
     utils.send_MIME_email("from", "to", msg, app.config, dryrun=False)
     mock_smtp.assert_called_with(app.config["SMTP_HOST"],
                                  app.config["SMTP_PORT"])
     assert mock_smtp.return_value.starttls.called
     mock_smtp.return_value.login.assert_called_with(
         app.config["SMTP_USER"], app.config["SMTP_PASSWORD"])
     mock_smtp.return_value.sendmail.assert_called_with(
         "from", "to", msg.as_string())
     assert mock_smtp.return_value.quit.called
예제 #6
0
 def test_send_mime_noauth(self, mock_smtp, mock_smtp_ssl):
     app.config['SMTP_USER'] = None
     app.config['SMTP_PASSWORD'] = None
     mock_smtp.return_value = mock.Mock()
     mock_smtp_ssl.return_value = mock.Mock()
     utils.send_MIME_email(
         'from', 'to', MIMEMultipart(), app.config, dryrun=False)
     assert not mock_smtp_ssl.called
     mock_smtp.assert_called_with(
         app.config.get('SMTP_HOST'),
         app.config.get('SMTP_PORT'),
     )
     assert not mock_smtp.login.called
예제 #7
0
 def test_send_mime(self, mock_smtp, mock_smtp_ssl):
     mock_smtp.return_value = mock.Mock()
     mock_smtp_ssl.return_value = mock.Mock()
     msg = MIMEMultipart()
     utils.send_MIME_email('from', 'to', msg, app.config, dryrun=False)
     mock_smtp.assert_called_with(
         app.config.get('SMTP_HOST'),
         app.config.get('SMTP_PORT'),
     )
     assert mock_smtp.return_value.starttls.called
     mock_smtp.return_value.login.assert_called_with(
         app.config.get('SMTP_USER'),
         app.config.get('SMTP_PASSWORD'),
     )
     mock_smtp.return_value.sendmail.assert_called_with(
         'from', 'to', msg.as_string())
     assert mock_smtp.return_value.quit.called
예제 #8
0
 def test_send_mime_dryrun(self, mock_smtp, mock_smtp_ssl):
     utils.send_MIME_email(
         'from', 'to', MIMEMultipart(), app.config, dryrun=True)
     assert not mock_smtp.called
     assert not mock_smtp_ssl.called