##// END OF EJS Templates
Code review changes....
Zachary Sailer -
Show More
@@ -7,6 +7,7 b' import json'
7
7
8 import requests
8 import requests
9
9
10 from IPython.html.utils import url_path_join
10 from IPython.html.tests.launchnotebook import NotebookTestBase
11 from IPython.html.tests.launchnotebook import NotebookTestBase
11
12
12
13
@@ -14,7 +15,7 b' class KernelAPITest(NotebookTestBase):'
14 """Test the kernels web service API"""
15 """Test the kernels web service API"""
15
16
16 def base_url(self):
17 def base_url(self):
17 return super(KernelAPITest,self).base_url() + 'api/kernels'
18 return url_path_join(super(KernelAPITest,self).base_url(), 'api/kernels')
18
19
19 def mkkernel(self):
20 def mkkernel(self):
20 r = requests.post(self.base_url())
21 r = requests.post(self.base_url())
@@ -117,7 +117,20 b' class FileNotebookManager(NotebookManager):'
117 return os.path.isfile(path)
117 return os.path.isfile(path)
118
118
119 def list_notebooks(self, path):
119 def list_notebooks(self, path):
120 """List all notebooks in the notebook dir."""
120 """Returns a list of dictionaries that are the standard model
121 for all notebooks in the relative 'path'.
122
123 Parameters
124 ----------
125 path : str
126 the URL path that describes the relative path for the
127 listed notebooks
128
129 Returns
130 -------
131 notebooks : list of dicts
132 a list of the notebook models without 'content'
133 """
121 notebook_names = self.get_notebook_names(path)
134 notebook_names = self.get_notebook_names(path)
122 notebooks = []
135 notebooks = []
123 for name in notebook_names:
136 for name in notebook_names:
@@ -127,7 +140,22 b' class FileNotebookManager(NotebookManager):'
127 return notebooks
140 return notebooks
128
141
129 def get_notebook_model(self, name, path='/', content=True):
142 def get_notebook_model(self, name, path='/', content=True):
130 """read a notebook object from a path"""
143 """ Takes a path and name for a notebook and returns it's model
144
145 Parameters
146 ----------
147 name : str
148 the name of the notebook
149 path : str
150 the URL path that describes the relative path for
151 the notebook
152
153 Returns
154 -------
155 model : dict
156 the notebook model. If contents=True, returns the 'contents'
157 dict in the model as well.
158 """
131 os_path = self.get_os_path(name, path)
159 os_path = self.get_os_path(name, path)
132 if not os.path.isfile(os_path):
160 if not os.path.isfile(os_path):
133 raise web.HTTPError(404, u'Notebook does not exist: %s' % name)
161 raise web.HTTPError(404, u'Notebook does not exist: %s' % name)
@@ -8,13 +8,14 b' from zmq.utils import jsonapi'
8
8
9 import requests
9 import requests
10
10
11 from IPython.html.utils import url_path_join
11 from IPython.html.tests.launchnotebook import NotebookTestBase
12 from IPython.html.tests.launchnotebook import NotebookTestBase
12
13
13 class APITest(NotebookTestBase):
14 class APITest(NotebookTestBase):
14 """Test the kernels web service API"""
15 """Test the kernels web service API"""
15
16
16 def notebook_url(self):
17 def notebook_url(self):
17 return super(APITest,self).base_url() + 'api/notebooks'
18 return url_path_join(super(APITest,self).base_url(), 'api/notebooks')
18
19
19 def mknb(self, name='', path='/'):
20 def mknb(self, name='', path='/'):
20 url = self.notebook_url() + path
21 url = self.notebook_url() + path
@@ -8,14 +8,14 b' from zmq.utils import jsonapi'
8
8
9 import requests
9 import requests
10
10
11 from IPython.html.utils import url_path_join
11 from IPython.html.tests.launchnotebook import NotebookTestBase
12 from IPython.html.tests.launchnotebook import NotebookTestBase
12
13
13
14 class SessionAPITest(NotebookTestBase):
14 class SessionAPITest(NotebookTestBase):
15 """Test the sessions web service API"""
15 """Test the sessions web service API"""
16
16
17 def notebook_url(self):
17 def notebook_url(self):
18 return super(SessionAPITest,self).base_url() + 'api/notebooks'
18 return url_path_join(super(SessionAPITest,self).base_url(), 'api/notebooks')
19
19
20 def session_url(self):
20 def session_url(self):
21 return super(SessionAPITest,self).base_url() + 'api/sessions'
21 return super(SessionAPITest,self).base_url() + 'api/sessions'
General Comments 0
You need to be logged in to leave comments. Login now