Beispiel #1
0
def test_extension_raises_error_if_no_application_bound_to_context(app, mail):
    mailer = Mailer()
    mailer.init_app(app)

    with pytest.raises(RuntimeError) as exc:
        mailer.send(mail)
        assert 'no application bound to current context' in exc.exconly()
Beispiel #2
0
def test_extension_use_the_application_bound_to_the_current_context(app, mail):
    mailer = Mailer()
    mailer.init_app(app)

    with app.test_request_context():
        mailer.send(mail)
        assert mailer.outbox == [mail,]
Beispiel #3
0
def test_extension_raises_error_if_not_properly_initialized(app, mail):
    mailer = Mailer()
    err = 'Mailer extension does not registered ' \
          'with current application or' \
          'no application bound to current context'

    with pytest.raises(RuntimeError) as exc:
        mailer.send(mail)
        assert err in exc.exconly()

    with app.test_request_context():
        with pytest.raises(RuntimeError) as exc:
            mailer.send(mail)
            assert err in exc.exconly()