run black

This commit is contained in:
Min RK
2019-10-22 09:23:04 +02:00
parent 7fbf1826ea
commit 244ad7d38c
3 changed files with 15 additions and 4 deletions

View File

@@ -1273,7 +1273,7 @@ class JupyterHub(Application):
To get the default behavior of /user-redirect/ leave this property unset To get the default behavior of /user-redirect/ leave this property unset
or return None from your callable. or return None from your callable.
""" """,
).tag(config=True) ).tag(config=True)
def init_handlers(self): def init_handlers(self):

View File

@@ -1488,7 +1488,9 @@ class UserRedirectHandler(BaseHandler):
# processing # processing
url = None url = None
if self.app.user_redirect_hook: if self.app.user_redirect_hook:
url = await maybe_future(self.app.user_redirect_hook(self.request, self.current_user)) url = await maybe_future(
self.app.user_redirect_hook(self.request, self.current_user)
)
if url is None: if url is None:
user = self.current_user user = self.current_user
user_url = url_path_join(user.url, path) user_url = url_path_join(user.url, path)

View File

@@ -398,6 +398,7 @@ async def test_user_redirect(app, username):
path = urlparse(r.url).path path = urlparse(r.url).path
assert path == ujoin(app.base_url, '/user/%s/notebooks/test.ipynb' % name) assert path == ujoin(app.base_url, '/user/%s/notebooks/test.ipynb' % name)
async def test_user_redirect_hook(app, username): async def test_user_redirect_hook(app, username):
""" """
Test proper behavior of user_redirect_hook Test proper behavior of user_redirect_hook
@@ -406,7 +407,9 @@ async def test_user_redirect_hook(app, username):
cookies = await app.login_user(name) cookies = await app.login_user(name)
async def dummy_redirect(request, user): async def dummy_redirect(request, user):
assert request.uri == ujoin(app.hub.base_url, 'user-redirect', 'redirect-to-terminal') assert request.uri == ujoin(
app.hub.base_url, 'user-redirect', 'redirect-to-terminal'
)
url = ujoin(user.url, '/terminals/1') url = ujoin(user.url, '/terminals/1')
return url return url
@@ -424,11 +427,17 @@ async def test_user_redirect_hook(app, username):
# We don't actually want to start the server by going through spawn - just want to make sure # We don't actually want to start the server by going through spawn - just want to make sure
# the redirect is to the right place # the redirect is to the right place
r = await get_page('/user-redirect/redirect-to-terminal', app, cookies=cookies, allow_redirects=False) r = await get_page(
'/user-redirect/redirect-to-terminal',
app,
cookies=cookies,
allow_redirects=False,
)
r.raise_for_status() r.raise_for_status()
redirected_url = urlparse(r.headers['Location']) redirected_url = urlparse(r.headers['Location'])
assert redirected_url.path == ujoin(app.base_url, 'user', username, 'terminals/1') assert redirected_url.path == ujoin(app.base_url, 'user', username, 'terminals/1')
async def test_user_redirect_deprecated(app, username): async def test_user_redirect_deprecated(app, username):
"""redirecting from /user/someonelse/ URLs (deprecated)""" """redirecting from /user/someonelse/ URLs (deprecated)"""
name = username name = username