Ejemplo n.º 1
0
def test_logout(client_session):
    client, session = client_session

    # logout without previous login
    rv = client.get('/logout')
    assert rv.status_code == 302
    assert rv.location == 'http://localhost/login?next=%2Flogout'
    rv = client.get('/logout', follow_redirects=True)
    assert rv.status_code == 200

    # logout from a previous login
    login(client, 'test_user', 'test')
    rv = client.get('/logout')
    assert rv.status_code == 302
    assert rv.location == 'http://localhost/login'
    user = get_user_by_name(session, 'test_user')
    assert not user.is_authenticated
    login(client, 'test_user', 'test')
    rv = client.get('/logout', follow_redirects=True)
    assert rv.status_code == 200
Ejemplo n.º 2
0
def test_login_logout(client):
    # check that we can login and logout a client
    rv = login(client, 'test_iris_admin', 'test')
    # the login function will follow the redirection and should be a 200 code
    assert rv.status_code == 200
    assert b'*****@*****.**' in rv.data
    assert b'Iris classification' in rv.data
    assert b'Boston housing price regression' in rv.data
    rv = logout(client)
    assert rv.status_code == 200
    assert b'Login' in rv.data
    assert b'Username' in rv.data
    assert b'Password' in rv.data