From 588021a4ebf7cc3fa9d65f752246110712946fbf Mon Sep 17 00:00:00 2001 From: xuwenyihust Date: Tue, 2 Jul 2024 22:16:21 +0800 Subject: [PATCH] Add notebook_1 creation to test_notebook_service.py --- server/tests/services/test_notebook_service.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/server/tests/services/test_notebook_service.py b/server/tests/services/test_notebook_service.py index 231587b..a4d9b8a 100644 --- a/server/tests/services/test_notebook_service.py +++ b/server/tests/services/test_notebook_service.py @@ -4,6 +4,7 @@ from database import db from app.models.notebook import NotebookModel from app.services.notebook import Notebook +import json class NotebookServiceTestCase(unittest.TestCase): @@ -22,11 +23,15 @@ def test_get_all_notebooks(self): with self.app.app_context(): notebook_0 = NotebookModel(name='Notebook0', path='/path/to/notebook0') db.session.add(notebook_0) + + notebook_1 = NotebookModel(name='Notebook1', path='/path/to/notebook1') + db.session.add(notebook_1) + db.session.commit() - notebooks = Notebook.get_all_notebooks() - print(notebooks) - print(len(notebooks)) - self.assertEqual(len(notebooks), 1) + notebooks = json.loads(Notebook.get_all_notebooks()) + self.assertEqual(len(notebooks), 2) self.assertEqual(notebooks[0].name, 'Notebook0') - self.assertEqual(notebooks[0].path, '/path/to/notebook0') \ No newline at end of file + self.assertEqual(notebooks[0].path, '/path/to/notebook0') + self.assertEqual(notebooks[1].name, 'Notebook1') + self.assertEqual(notebooks[1].path, '/path/to/notebook1') \ No newline at end of file