mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-17 15:03:02 +00:00
exercise single-user help output
and tweak some of its output
This commit is contained in:
@@ -9,6 +9,7 @@ import os
|
||||
from jinja2 import ChoiceLoader, FunctionLoader
|
||||
|
||||
from tornado import ioloop
|
||||
from textwrap import dedent
|
||||
|
||||
try:
|
||||
import notebook
|
||||
@@ -31,6 +32,7 @@ from notebook.notebookapp import (
|
||||
from notebook.auth.login import LoginHandler
|
||||
from notebook.auth.logout import LogoutHandler
|
||||
|
||||
from jupyterhub import __version__
|
||||
from .services.auth import HubAuth, HubAuthenticated
|
||||
from .utils import url_path_join
|
||||
|
||||
@@ -117,6 +119,17 @@ def _exclude_home(path_list):
|
||||
|
||||
class SingleUserNotebookApp(NotebookApp):
|
||||
"""A Subclass of the regular NotebookApp that is aware of the parent multiuser context."""
|
||||
description = dedent("""
|
||||
Single-user server for JupyterHub. Extends the Jupyter Notebook server.
|
||||
|
||||
Meant to be invoked by JupyterHub Spawners, and not directly.
|
||||
""")
|
||||
|
||||
examples = ""
|
||||
subcommands = {}
|
||||
version = __version__
|
||||
classes = NotebookApp.classes + [HubAuth]
|
||||
|
||||
user = CUnicode(config=True)
|
||||
def _user_changed(self, name, old, new):
|
||||
self.log.name = new
|
||||
|
@@ -1,10 +1,15 @@
|
||||
"""Tests for jupyterhub.singleuser"""
|
||||
|
||||
from subprocess import check_output
|
||||
import sys
|
||||
|
||||
import requests
|
||||
|
||||
import jupyterhub
|
||||
from .mocking import TestSingleUserSpawner, public_url
|
||||
from ..utils import url_path_join
|
||||
|
||||
|
||||
def test_singleuser_auth(app, io_loop):
|
||||
# use TestSingleUserSpawner to launch a single-user app in a thread
|
||||
app.spawner_class = TestSingleUserSpawner
|
||||
@@ -32,6 +37,7 @@ def test_singleuser_auth(app, io_loop):
|
||||
r = requests.get(url_path_join(url, 'logout'), cookies=cookies)
|
||||
assert len(r.cookies) == 0
|
||||
|
||||
|
||||
def test_disable_user_config(app, io_loop):
|
||||
# use TestSingleUserSpawner to launch a single-user app in a thread
|
||||
app.spawner_class = TestSingleUserSpawner
|
||||
@@ -56,3 +62,13 @@ def test_disable_user_config(app, io_loop):
|
||||
r.raise_for_status()
|
||||
assert r.url.rstrip('/').endswith('/user/nandy/tree')
|
||||
assert r.status_code == 200
|
||||
|
||||
|
||||
def test_help_output():
|
||||
out = check_output([sys.executable, '-m', 'jupyterhub.singleuser', '--help-all']).decode('utf8', 'replace')
|
||||
assert 'JupyterHub' in out
|
||||
|
||||
def test_version():
|
||||
out = check_output([sys.executable, '-m', 'jupyterhub.singleuser', '--version']).decode('utf8', 'replace')
|
||||
assert jupyterhub.__version__ in out
|
||||
|
||||
|
Reference in New Issue
Block a user