def test_user_redirect(app):
    name = 'wash'
    cookies = app.login_user(name)

    r = get_page('/user/baduser', app, cookies=cookies)
    r.raise_for_status()
    print(urlparse(r.url))
    path = urlparse(r.url).path
    assert path == '/user/%s' % name

    r = get_page('/user/baduser/test.ipynb', app, cookies=cookies)
    r.raise_for_status()
    print(urlparse(r.url))
    path = urlparse(r.url).path
    assert path == '/user/%s/test.ipynb' % name

    r = get_page('/user/baduser/test.ipynb', app)
    r.raise_for_status()
    print(urlparse(r.url))
    path = urlparse(r.url).path
    assert path == '/hub/login'
    query = urlparse(r.url).query
    assert query == urlencode({'next': '/hub/user/baduser/test.ipynb'})
dataset/ETHPy150Open jupyterhub/jupyterhub/jupyterhub/tests/test_pages.py/test_user_redirect/original