2
0
mirror of https://github.com/jupyter/notebook.git synced 2025-02-11 12:30:51 +08:00

Code review changes.

Fixed handler issues and api tests from code review
from @minrk and @carreau.
This commit is contained in:
Zachary Sailer 2013-08-27 20:16:29 -07:00 committed by MinRK
parent 2d6f4628c4
commit 27680dacb2
4 changed files with 36 additions and 6 deletions
IPython/html/services

View File

@ -7,6 +7,7 @@ import json
import requests
from IPython.html.utils import url_path_join
from IPython.html.tests.launchnotebook import NotebookTestBase
@ -14,7 +15,7 @@ class KernelAPITest(NotebookTestBase):
"""Test the kernels web service API"""
def base_url(self):
return super(KernelAPITest,self).base_url() + 'api/kernels'
return url_path_join(super(KernelAPITest,self).base_url(), 'api/kernels')
def mkkernel(self):
r = requests.post(self.base_url())

View File

@ -117,7 +117,20 @@ class FileNotebookManager(NotebookManager):
return os.path.isfile(path)
def list_notebooks(self, path):
"""List all notebooks in the notebook dir."""
"""Returns a list of dictionaries that are the standard model
for all notebooks in the relative 'path'.
Parameters
----------
path : str
the URL path that describes the relative path for the
listed notebooks
Returns
-------
notebooks : list of dicts
a list of the notebook models without 'content'
"""
notebook_names = self.get_notebook_names(path)
notebooks = []
for name in notebook_names:
@ -127,7 +140,22 @@ class FileNotebookManager(NotebookManager):
return notebooks
def get_notebook_model(self, name, path='/', content=True):
"""read a notebook object from a path"""
""" Takes a path and name for a notebook and returns it's model
Parameters
----------
name : str
the name of the notebook
path : str
the URL path that describes the relative path for
the notebook
Returns
-------
model : dict
the notebook model. If contents=True, returns the 'contents'
dict in the model as well.
"""
os_path = self.get_os_path(name, path)
if not os.path.isfile(os_path):
raise web.HTTPError(404, u'Notebook does not exist: %s' % name)

View File

@ -8,13 +8,14 @@ from zmq.utils import jsonapi
import requests
from IPython.html.utils import url_path_join
from IPython.html.tests.launchnotebook import NotebookTestBase
class APITest(NotebookTestBase):
"""Test the kernels web service API"""
def notebook_url(self):
return super(APITest,self).base_url() + 'api/notebooks'
return url_path_join(super(APITest,self).base_url(), 'api/notebooks')
def mknb(self, name='', path='/'):
url = self.notebook_url() + path

View File

@ -8,14 +8,14 @@ from zmq.utils import jsonapi
import requests
from IPython.html.utils import url_path_join
from IPython.html.tests.launchnotebook import NotebookTestBase
class SessionAPITest(NotebookTestBase):
"""Test the sessions web service API"""
def notebook_url(self):
return super(SessionAPITest,self).base_url() + 'api/notebooks'
return url_path_join(super(SessionAPITest,self).base_url(), 'api/notebooks')
def session_url(self):
return super(SessionAPITest,self).base_url() + 'api/sessions'