def test_connection_configure_host_ssl(mock_smtp_ssl): mail = Mail(**test_mail_options) mail.mail_suppress_send = False mail.mail_use_tls = False mail.mail_use_ssl = True mock_smtp_ssl.return_value = MagicMock() with mail.connect() as conn: # NOQA mock_smtp_ssl.assert_called_with(mail.mail_server, mail.mail_port)
def test_connection_configure_host_non_ssl(mock_smtp): mail = Mail(**test_mail_options) mail.mail_suppress_send = False mail.mail_use_tls = True mock_smtp.return_value = MagicMock() mock_smtp.return_value.starttls.return_value = None with mail.connect() as conn: mock_smtp.assert_called_with(mail.mail_server, mail.mail_port) assert conn.host.starttls.called