

@pytest.mark.settings(post_register_view='/post_register')
def test_registerable_flag(client, app, get_message):
    recorded = []
    response = client.get('/register')
    assert (b'<h1>Register</h1>' in response.data)

    @user_registered.connect_via(app)
    def on_user_registerd(app, user, confirm_token):
        assert isinstance(app, Flask)
        assert isinstance(user, UserMixin)
        assert (confirm_token is None)
        recorded.append(user)
    data = dict(email='dude@lp.com', password='password', password_confirm='password', next='')
    with app.mail.record_messages() as outbox:
        response = client.post('/register', data=data, follow_redirects=True)
    assert (len(recorded) == 1)
    assert (len(outbox) == 1)
    assert (b'Post Register' in response.data)
    logout(client)
    response = authenticate(client, email='dude@lp.com', password='password')
    assert (response.status_code == 302)
    logout(client)
    data = dict(email='dude@lp.com', password='password', password_confirm='password', next='')
    response = client.post('/register', data=data, follow_redirects=True)
    assert (get_message('EMAIL_ALREADY_ASSOCIATED', email='dude@lp.com') in response.data)
    data = dict(email='Dude@lp.com', password='password', password_confirm='password', next='')
    response = client.post('/register', data=data, follow_redirects=True)
    assert (get_message('EMAIL_ALREADY_ASSOCIATED', email='Dude@lp.com') in response.data)
    data = '{ "email": "dude2@lp.com", "password": "password"}'
    response = client.post('/register', data=data, headers={
        'Content-Type': 'application/json',
    })
    assert (response.headers['content-type'] == 'application/json')
    assert (response.jdata['meta']['code'] == 200)
    logout(client)
    data = '{ "email": "bogus", "password": "password"}'
    response = client.post('/register', data=data, headers={
        'Content-Type': 'application/json',
    })
    assert (response.headers['content-type'] == 'application/json')
    assert (response.jdata['meta']['code'] == 400)
    logout(client)
    data = dict(email='dude3@lp.com', password='password', password_confirm='password', next='')
    response = client.post('/register?next=/page1', data=app, follow_redirects=True)
    assert (b'Page 1' in response.data)

dataset/ETHPy150Open mattupstate/flask-security/tests/test_registerable.py test_registerable_flag/VarMisuse@475/718 `data`->`app`