Here are the examples of the python api pytest.mark.recoverable taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2 Examples
3
Example 1
Project: flask-security Source File: test_misc.py
@pytest.mark.recoverable()
def test_async_email_task(app, client):
app.mail_sent = False
@app.security.send_mail_task
def send_email(msg):
app.mail_sent = True
client.post('/reset', data=dict(email='[email protected]'))
assert app.mail_sent is True
0
Example 2
Project: flask-security Source File: test_context_processors.py
@pytest.mark.recoverable()
@pytest.mark.registerable()
@pytest.mark.confirmable()
@pytest.mark.changeable()
@pytest.mark.settings(
login_without_confirmation=True,
change_password_template='custom_security/change_password.html',
login_user_template='custom_security/login_user.html',
reset_password_template='custom_security/reset_password.html',
forgot_password_template='custom_security/forgot_password.html',
send_confirmation_template='custom_security/send_confirmation.html',
register_user_template='custom_security/register_user.html')
def test_context_processors(client, app):
@app.security.context_processor
def default_ctx_processor():
return {'global': 'global'}
@app.security.forgot_password_context_processor
def forgot_password():
return {'foo': 'bar'}
response = client.get('/reset')
assert b'global' in response.data
assert b'bar' in response.data
@app.security.login_context_processor
def login():
return {'foo': 'bar'}
response = client.get('/login')
assert b'global' in response.data
assert b'bar' in response.data
@app.security.register_context_processor
def register():
return {'foo': 'bar'}
response = client.get('/register')
assert b'global' in response.data
assert b'bar' in response.data
@app.security.reset_password_context_processor
def reset_password():
return {'foo': 'bar'}
response = client.get('/reset')
assert b'global' in response.data
assert b'bar' in response.data
@app.security.change_password_context_processor
def change_password():
return {'foo': 'bar'}
authenticate(client)
response = client.get('/change')
assert b'global' in response.data
assert b'bar' in response.data
@app.security.send_confirmation_context_processor
def send_confirmation():
return {'foo': 'bar'}
response = client.get('/confirm')
assert b'global' in response.data
assert b'bar' in response.data
@app.security.mail_context_processor
def mail():
return {'foo': 'bar'}
client.get('/logout')
with app.mail.record_messages() as outbox:
client.post('/reset', data=dict(email='[email protected]'))
email = outbox[0]
assert 'global' in email.html
assert 'bar' in email.html