1+ """Fixtures for use with jupyter server and downstream."""
12# Copyright (c) Jupyter Development Team.
23# Distributed under the terms of the Modified BSD License.
34
@@ -59,6 +60,7 @@ def http_server(io_loop, http_server_port, jp_web_app):
5960 """Start a tornado HTTP server that listens on all available interfaces."""
6061
6162 async def get_server ():
63+ """Get a server asynchronously."""
6264 server = tornado .httpserver .HTTPServer (jp_web_app )
6365 server .add_socket (http_server_port [0 ])
6466 return server
@@ -385,6 +387,7 @@ def inner(nbpath):
385387
386388@pytest .fixture (autouse = True )
387389def jp_server_cleanup (jp_asyncio_loop ):
390+ """Automatically cleans up server resources."""
388391 yield
389392 app : ServerApp = ServerApp .instance ()
390393 try :
@@ -422,6 +425,7 @@ async def _(url, **fetch_kwargs):
422425
423426@pytest .fixture
424427def jp_server_auth_core_resources ():
428+ """The core auth resources for use with a server."""
425429 modules = []
426430 for mod_name in JUPYTER_SERVICE_HANDLERS .values ():
427431 if mod_name :
@@ -438,10 +442,13 @@ def jp_server_auth_core_resources():
438442
439443@pytest .fixture
440444def jp_server_auth_resources (jp_server_auth_core_resources ):
445+ """The auth resources used by the server."""
441446 return jp_server_auth_core_resources
442447
443448
444449class _Authorizer (Authorizer ):
450+ """A custom authorizer class for testing."""
451+
445452 # Set these class attributes from within a test
446453 # to verify that they match the arguments passed
447454 # by the REST API.
@@ -484,6 +491,7 @@ def normalize_url(self, path):
484491 return path
485492
486493 def is_authorized (self , handler , user , action , resource ):
494+ """Test if a request is authorized."""
487495 # Parse Request
488496 if isinstance (handler , WebSocketHandler ):
489497 method = "WEBSOCKET"
@@ -511,6 +519,7 @@ def is_authorized(self, handler, user, action, resource):
511519
512520@pytest .fixture
513521def jp_server_authorizer (jp_server_auth_resources ):
522+ """An authorizer for the server."""
514523 auth_klass = _Authorizer
515524 auth_klass ._default_regex_mapping = jp_server_auth_resources
516525 return auth_klass
0 commit comments