Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 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>')
Ejemplo n.º 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)
Ejemplo n.º 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,
    )
Ejemplo n.º 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,
    )
Ejemplo n.º 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,
    )