##// END OF EJS Templates
don't use jsonapi in test_notebook_api
MinRK -
Show More
@@ -7,8 +7,6 b' import os'
7 import shutil
7 import shutil
8 from unicodedata import normalize
8 from unicodedata import normalize
9
9
10 from zmq.utils import jsonapi
11
12 pjoin = os.path.join
10 pjoin = os.path.join
13
11
14 import requests
12 import requests
@@ -67,7 +65,7 b' class NBAPI(object):'
67 return self._req('DELETE', url_path_join(path, name))
65 return self._req('DELETE', url_path_join(path, name))
68
66
69 def rename(self, name, path, new_name):
67 def rename(self, name, path, new_name):
70 body = jsonapi.dumps({'name': new_name})
68 body = json.dumps({'name': new_name})
71 return self._req('PATCH', url_path_join(path, name), body)
69 return self._req('PATCH', url_path_join(path, name), body)
72
70
73 def get_checkpoints(self, name, path):
71 def get_checkpoints(self, name, path):
@@ -186,14 +184,14 b' class APITest(NotebookTestBase):'
186 nb = new_notebook(name='Upload test')
184 nb = new_notebook(name='Upload test')
187 nbmodel = {'content': nb}
185 nbmodel = {'content': nb}
188 resp = self.nb_api.upload_untitled(path=u'Γ₯ b',
186 resp = self.nb_api.upload_untitled(path=u'Γ₯ b',
189 body=jsonapi.dumps(nbmodel))
187 body=json.dumps(nbmodel))
190 self._check_nb_created(resp, 'Untitled0.ipynb', u'Γ₯ b')
188 self._check_nb_created(resp, 'Untitled0.ipynb', u'Γ₯ b')
191
189
192 def test_upload(self):
190 def test_upload(self):
193 nb = new_notebook(name=u'ignored')
191 nb = new_notebook(name=u'ignored')
194 nbmodel = {'content': nb}
192 nbmodel = {'content': nb}
195 resp = self.nb_api.upload(u'Upload tΓ©st.ipynb', path=u'Γ₯ b',
193 resp = self.nb_api.upload(u'Upload tΓ©st.ipynb', path=u'Γ₯ b',
196 body=jsonapi.dumps(nbmodel))
194 body=json.dumps(nbmodel))
197 self._check_nb_created(resp, u'Upload tΓ©st.ipynb', u'Γ₯ b')
195 self._check_nb_created(resp, u'Upload tΓ©st.ipynb', u'Γ₯ b')
198
196
199 def test_copy_untitled(self):
197 def test_copy_untitled(self):
@@ -226,14 +224,14 b' class APITest(NotebookTestBase):'
226
224
227 def test_save(self):
225 def test_save(self):
228 resp = self.nb_api.read('a.ipynb', 'foo')
226 resp = self.nb_api.read('a.ipynb', 'foo')
229 nbcontent = jsonapi.loads(resp.text)['content']
227 nbcontent = json.loads(resp.text)['content']
230 nb = to_notebook_json(nbcontent)
228 nb = to_notebook_json(nbcontent)
231 ws = new_worksheet()
229 ws = new_worksheet()
232 nb.worksheets = [ws]
230 nb.worksheets = [ws]
233 ws.cells.append(new_heading_cell(u'Created by test Β³'))
231 ws.cells.append(new_heading_cell(u'Created by test Β³'))
234
232
235 nbmodel= {'name': 'a.ipynb', 'path':'foo', 'content': nb}
233 nbmodel= {'name': 'a.ipynb', 'path':'foo', 'content': nb}
236 resp = self.nb_api.save('a.ipynb', path='foo', body=jsonapi.dumps(nbmodel))
234 resp = self.nb_api.save('a.ipynb', path='foo', body=json.dumps(nbmodel))
237
235
238 nbfile = pjoin(self.notebook_dir.name, 'foo', 'a.ipynb')
236 nbfile = pjoin(self.notebook_dir.name, 'foo', 'a.ipynb')
239 with io.open(nbfile, 'r', encoding='utf-8') as f:
237 with io.open(nbfile, 'r', encoding='utf-8') as f:
@@ -247,7 +245,7 b' class APITest(NotebookTestBase):'
247
245
248 # Save and rename
246 # Save and rename
249 nbmodel= {'name': 'a2.ipynb', 'path':'foo/bar', 'content': nb}
247 nbmodel= {'name': 'a2.ipynb', 'path':'foo/bar', 'content': nb}
250 resp = self.nb_api.save('a.ipynb', path='foo', body=jsonapi.dumps(nbmodel))
248 resp = self.nb_api.save('a.ipynb', path='foo', body=json.dumps(nbmodel))
251 saved = resp.json()
249 saved = resp.json()
252 self.assertEqual(saved['name'], 'a2.ipynb')
250 self.assertEqual(saved['name'], 'a2.ipynb')
253 self.assertEqual(saved['path'], 'foo/bar')
251 self.assertEqual(saved['path'], 'foo/bar')
@@ -265,7 +263,7 b' class APITest(NotebookTestBase):'
265 self.assertEqual(r.headers['Location'].split('/')[-1], cp1['id'])
263 self.assertEqual(r.headers['Location'].split('/')[-1], cp1['id'])
266
264
267 # Modify it
265 # Modify it
268 nbcontent = jsonapi.loads(resp.text)['content']
266 nbcontent = json.loads(resp.text)['content']
269 nb = to_notebook_json(nbcontent)
267 nb = to_notebook_json(nbcontent)
270 ws = new_worksheet()
268 ws = new_worksheet()
271 nb.worksheets = [ws]
269 nb.worksheets = [ws]
@@ -273,7 +271,7 b' class APITest(NotebookTestBase):'
273 ws.cells.append(hcell)
271 ws.cells.append(hcell)
274 # Save
272 # Save
275 nbmodel= {'name': 'a.ipynb', 'path':'foo', 'content': nb}
273 nbmodel= {'name': 'a.ipynb', 'path':'foo', 'content': nb}
276 resp = self.nb_api.save('a.ipynb', path='foo', body=jsonapi.dumps(nbmodel))
274 resp = self.nb_api.save('a.ipynb', path='foo', body=json.dumps(nbmodel))
277
275
278 # List checkpoints
276 # List checkpoints
279 cps = self.nb_api.get_checkpoints('a.ipynb', 'foo').json()
277 cps = self.nb_api.get_checkpoints('a.ipynb', 'foo').json()
General Comments 0
You need to be logged in to leave comments. Login now