From b81ac4a0c7bcae89161e5c4f37609ebb18a90673 Mon Sep 17 00:00:00 2001 From: xuwenyihust Date: Mon, 8 Jul 2024 12:00:48 +0800 Subject: [PATCH] Refactor directory service to include default path handling in get_content_by_path method --- server/app/services/directory.py | 2 ++ server/tests/services/test_notebook_service.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/server/app/services/directory.py b/server/app/services/directory.py index cd55986..f906ad1 100644 --- a/server/app/services/directory.py +++ b/server/app/services/directory.py @@ -17,6 +17,8 @@ def get_content_by_path(path: str = None): jupyter_api_path = app.config['JUPYTER_API_PATH'] jupyter_default_path = app.config['JUPYTER_DEFAULT_PATH'] + if path is None: + path = jupyter_default_path path = f"{jupyter_api_path}/{path}" response = requests.get(path) diff --git a/server/tests/services/test_notebook_service.py b/server/tests/services/test_notebook_service.py index 1965d3c..0c74c39 100644 --- a/server/tests/services/test_notebook_service.py +++ b/server/tests/services/test_notebook_service.py @@ -60,7 +60,7 @@ def test_create_and_get_notebook(self): self.assertTrue(notebook_name_1.startswith('notebook_')) self.assertTrue(notebook_name_1.endswith('.ipynb')) - self.assertEquals('work/' + notebook_name_1, notebook_path_1) + self.assertEqual('work/' + notebook_name_1, notebook_path_1) get_response_1 = Notebook.get_notebook_by_path(notebook_path=notebook_path_1) notebook_1 = get_response_1[0]