Example #1
0
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
Example #2
0
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
Example #3
0
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)
Example #4
0
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)
Example #5
0
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)
Example #6
0
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)
Example #7
0
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
Example #8
0
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>')
Example #9
0
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)
Example #10
0
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,
    )
Example #11
0
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,
    )
Example #12
0
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,
    )