def test_send_retries_if_mailing_fails(pyramid_mailer, celery, pyramid_request): celery.request = pyramid_request request_mailer = pyramid_mailer.get_mailer.return_value request_mailer.send_immediately.side_effect = SMTPServerDisconnected() mailer.send.retry = mock.Mock(spec_set=[]) mailer.send(recipients=['*****@*****.**'], subject='My email subject', body='Some text body') assert mailer.send.retry.called
def test_send_retries_if_mailing_fails(pyramid_mailer, celery): celery.request = mock.sentinel.request request_mailer = pyramid_mailer.get_mailer.return_value request_mailer.send_immediately.side_effect = SMTPServerDisconnected() mailer.send.retry = mock.Mock(spec_set=[]) mailer.send(recipients=['*****@*****.**'], subject='My email subject', body='Some text body') assert mailer.send.retry.called
def test_send_dispatches_email_using_request_mailer(pyramid_mailer, celery, pyramid_request): celery.request = pyramid_request request_mailer = pyramid_mailer.get_mailer.return_value message = pyramid_mailer.message.Message.return_value mailer.send(recipients=['*****@*****.**'], subject='My email subject', body='Some text body') pyramid_mailer.get_mailer.assert_called_once_with(pyramid_request) request_mailer.send_immediately.assert_called_once_with(message)
def test_send_dispatches_email_using_request_mailer(pyramid_mailer, celery): celery.request = mock.sentinel.request request_mailer = pyramid_mailer.get_mailer.return_value message = pyramid_mailer.message.Message.return_value mailer.send(recipients=['*****@*****.**'], subject='My email subject', body='Some text body') pyramid_mailer.get_mailer.assert_called_once_with(mock.sentinel.request) request_mailer.send_immediately.assert_called_once_with(message)
def test_send_creates_email_message(pyramid_mailer, celery, pyramid_request): celery.request = pyramid_request mailer.send(recipients=['*****@*****.**'], subject='My email subject', body='Some text body') pyramid_mailer.message.Message.assert_called_once_with( subject='My email subject', recipients=['*****@*****.**'], body='Some text body', html=None)
def test_send_retries_if_mailing_fails(pyramid_mailer, celery, pyramid_request): celery.request = pyramid_request request_mailer = pyramid_mailer.get_mailer.return_value request_mailer.send_immediately.side_effect = SMTPServerDisconnected() mailer.send.retry = mock.Mock(spec_set=[]) mailer.send( # pylint:disable=no-value-for-parameter #: bound celery task recipients=["*****@*****.**"], subject="My email subject", body="Some text body", ) assert mailer.send.retry.called
def test_send_creates_email_message_with_html_body(pyramid_mailer, celery): celery.request = mock.sentinel.request mailer.send(recipients=['*****@*****.**'], subject='My email subject', body='Some text body', html='<p>An HTML body</p>') pyramid_mailer.message.Message.assert_called_once_with( subject='My email subject', recipients=['*****@*****.**'], body='Some text body', html='<p>An HTML body</p>')
def test_send_dispatches_email_using_request_mailer(pyramid_mailer, celery, pyramid_request): celery.request = pyramid_request request_mailer = pyramid_mailer.get_mailer.return_value message = pyramid_mailer.message.Message.return_value mailer.send( recipients=["*****@*****.**"], subject="My email subject", body="Some text body", ) pyramid_mailer.get_mailer.assert_called_once_with(pyramid_request) request_mailer.send_immediately.assert_called_once_with(message)
def test_send_creates_email_message(pyramid_mailer, celery, pyramid_request): celery.request = pyramid_request mailer.send( recipients=["*****@*****.**"], subject="My email subject", body="Some text body", ) pyramid_mailer.message.Message.assert_called_once_with( subject="My email subject", recipients=["*****@*****.**"], body="Some text body", html=None, )
def test_send_creates_email_message(pyramid_mailer, celery, pyramid_request): celery.request = pyramid_request mailer.send( # pylint:disable=no-value-for-parameter #: (bound celery task) recipients=["*****@*****.**"], subject="My email subject", body="Some text body", ) pyramid_mailer.message.Message.assert_called_once_with( subject="My email subject", recipients=["*****@*****.**"], body="Some text body", html=None, )