Skip to content

Commit 96d0b38

Browse files
committed
Refactor notebook creation API endpoint and model in test_notebook_service.py, fix test_create_and_get_notebook test case, and handle non-existent notebook in Notebook class
1 parent cae9ce8 commit 96d0b38

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

server/tests/services/test_notebook_service.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,20 @@ def test_create_and_get_notebook(self):
4141
create_response = Notebook.create_notebook_with_init_cells(notebook_name='Notebook.ipynb', notebook_path='')
4242
self.assertEqual(create_response[1], 200)
4343

44-
notebook = Notebook.get_notebook_by_path(notebook_path='work/Notebook.ipynb')[0]
45-
status_code = Notebook.get_notebook_by_path(notebook_path='work/Notebook.ipynb')[1]
44+
get_response_0 = Notebook.get_notebook_by_path(notebook_path='work/Notebook.ipynb')
45+
notebook_0 = get_response_0[0]
46+
status_code_0 = get_response_0[1]
4647

47-
self.assertEqual(status_code, 200)
48-
self.assertEqual(notebook['name'], 'Notebook.ipynb')
49-
self.assertEqual(notebook['path'], 'work/Notebook.ipynb')
50-
self.assertEqual(len(notebook['content']['cells']), 2)
48+
self.assertEqual(status_code_0, 200)
49+
self.assertEqual(notebook_0['name'], 'Notebook.ipynb')
50+
self.assertEqual(notebook_0['path'], 'work/Notebook.ipynb')
51+
self.assertEqual(len(notebook_0['content']['cells']), 2)
5152

52-
print(Notebook.get_notebook_by_path(notebook_path='work/Notebook666.ipynb'))
53+
get_response_1 = Notebook.get_notebook_by_path(notebook_path='work/Notebook666.ipynb')
54+
notebook_1 = get_response_1[0]
55+
status_code_1 = get_response_1[1]
56+
57+
self.assertEqual(status_code_1, 404)
58+
59+
print(notebook_1)
5360

0 commit comments

Comments
 (0)