##// END OF EJS Templates
use default kernel name in kernels service...
MinRK -
Show More
@@ -27,16 +27,16 b' class MainKernelHandler(IPythonHandler):'
27 @web.authenticated
27 @web.authenticated
28 @json_errors
28 @json_errors
29 def post(self):
29 def post(self):
30 km = self.kernel_manager
30 model = self.get_json_body()
31 model = self.get_json_body()
31 if model is None:
32 if model is None:
32 raise web.HTTPError(400, "No JSON data provided")
33 model = {
33 try:
34 'name': km.default_kernel_name
34 name = model['name']
35 }
35 except KeyError:
36 else:
36 raise web.HTTPError(400, "Missing field in JSON data: name")
37 model.setdefault('name', km.default_kernel_name)
37
38
38 km = self.kernel_manager
39 kernel_id = km.start_kernel(kernel_name=model['name'])
39 kernel_id = km.start_kernel(kernel_name=name)
40 model = km.kernel_model(kernel_id)
40 model = km.kernel_model(kernel_id)
41 location = url_path_join(self.base_url, 'api', 'kernels', kernel_id)
41 location = url_path_join(self.base_url, 'api', 'kernels', kernel_id)
42 self.set_header('Location', url_escape(location))
42 self.set_header('Location', url_escape(location))
@@ -57,6 +57,16 b' class KernelAPITest(NotebookTestBase):'
57 kernels = self.kern_api.list().json()
57 kernels = self.kern_api.list().json()
58 self.assertEqual(kernels, [])
58 self.assertEqual(kernels, [])
59
59
60 def test_default_kernel(self):
61 # POST request
62 r = self.kern_api._req('POST', '')
63 kern1 = r.json()
64 self.assertEqual(r.headers['location'], '/api/kernels/' + kern1['id'])
65 self.assertEqual(r.status_code, 201)
66 self.assertIsInstance(kern1, dict)
67
68 self.assertEqual(r.headers['x-frame-options'], "SAMEORIGIN")
69
60 def test_main_kernel_handler(self):
70 def test_main_kernel_handler(self):
61 # POST request
71 # POST request
62 r = self.kern_api.start()
72 r = self.kern_api.start()
General Comments 0
You need to be logged in to leave comments. Login now