Skip to content

Commit a516ed6

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 22b140d commit a516ed6

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

server/tests/services/test_notebook_service.py

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ def test_get_all_notebooks(self):
3838

3939
def test_create_and_get_notebook(self):
4040
with self.app.app_context():
41-
create_response = Notebook.create_notebook_with_init_cells(notebook_name='Notebook.ipynb', notebook_path='')
42-
self.assertEqual(create_response[1], 200)
41+
# Create with name but without path & get by path
42+
create_response_0 = Notebook.create_notebook_with_init_cells(notebook_name='Notebook.ipynb', notebook_path='')
43+
self.assertEqual(create_response_0[1], 200)
4344

4445
get_response_0 = Notebook.get_notebook_by_path(notebook_path='work/Notebook.ipynb')
4546
notebook_0 = get_response_0[0]
@@ -50,11 +51,28 @@ def test_create_and_get_notebook(self):
5051
self.assertEqual(notebook_0['path'], 'work/Notebook.ipynb')
5152
self.assertEqual(len(notebook_0['content']['cells']), 2)
5253

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]
54+
# Create without name / path & get by path
55+
create_response_1 = Notebook.create_notebook_with_init_cells(notebook_name='', notebook_path='')
56+
self.assertEqual(create_response_1[1], 200)
57+
print(create_response_1)
5658

57-
self.assertEqual(status_code_1, 404)
59+
# get_response_1 = Notebook.get_notebook_by_path(notebook_path='work/Notebook.ipynb')
60+
# notebook_0 = get_response_0[0]
61+
# status_code_0 = get_response_0[1]
5862

59-
print(notebook_1.json())
63+
# self.assertEqual(status_code_0, 200)
64+
# self.assertEqual(notebook_0['name'], 'Notebook.ipynb')
65+
# self.assertEqual(notebook_0['path'], 'work/Notebook.ipynb')
66+
# self.assertEqual(len(notebook_0['content']['cells']), 2)
67+
68+
# Create with name / path & get by path
69+
70+
# Get non-exist path
71+
get_response_3 = Notebook.get_notebook_by_path(notebook_path='work/Notebook666.ipynb')
72+
status_code_3 = get_response_3[1]
73+
74+
self.assertEqual(status_code_3, 404)
75+
76+
def test_delete_notebook(self):
77+
pass
6078

0 commit comments

Comments
 (0)