From 680302b42d37666b078c44590858c3b909dfd894 Mon Sep 17 00:00:00 2001 From: RichieBrady Date: Mon, 12 Apr 2021 16:03:21 +0100 Subject: [PATCH 1/3] Adding reference to Notebook item --- spinetoolbox/category.py | 3 ++- spinetoolbox/ui_main.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/spinetoolbox/category.py b/spinetoolbox/category.py index 41d8bbc46..6b69fb130 100644 --- a/spinetoolbox/category.py +++ b/spinetoolbox/category.py @@ -16,7 +16,7 @@ :date: 6.5.2020 """ # The categories will appear in the main window in the same order they are declared here. -CATEGORIES = ("Data Stores", "Data Connections", "Tools", "Views", "Importers", "Exporters", "Manipulators") +CATEGORIES = ("Data Stores", "Data Connections", "Tools", "Notebooks", "Views", "Importers", "Exporters", "Manipulators") CATEGORY_DESCRIPTIONS = { @@ -25,6 +25,7 @@ "Exporters": "Data conversion from Spine to an external format", "Importers": "Data conversion from an external format to Spine", "Tools": "Custom data processing", + "Notebooks": "Custom data processing with Jupyter notebooks", "Views": "Data visualization", "Manipulators": "Data conversion from Spine to Spine", } diff --git a/spinetoolbox/ui_main.py b/spinetoolbox/ui_main.py index da162ab17..2c345fe6b 100644 --- a/spinetoolbox/ui_main.py +++ b/spinetoolbox/ui_main.py @@ -770,7 +770,10 @@ def load_specification(self, definition): ProjectItemSpecification or NoneType: specification or None if factory isn't found. """ # NOTE: If the spec doesn't have the "item_type" key, we can assume it's a tool spec - item_type = definition.get("item_type", "Tool") + if "notebook_type" in definition: + item_type = "Notebook" + else: + item_type = definition.get("item_type", "Tool") spec_factory = self._item_specification_factories.get(item_type) if spec_factory is None: return None From a8298d2ed90b044545faf081f8bd582ad7ed253d Mon Sep 17 00:00:00 2001 From: RichieBrady Date: Mon, 12 Apr 2021 16:30:23 +0100 Subject: [PATCH 2/3] Update test to account for new notebook item --- tests/test_toolboxUI.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_toolboxUI.py b/tests/test_toolboxUI.py index 77ffcd778..5ded86321 100644 --- a/tests/test_toolboxUI.py +++ b/tests/test_toolboxUI.py @@ -90,8 +90,8 @@ def test_init_project_item_model_with_project(self): def check_init_project_item_model(self): """Checks that category items are created as expected.""" n = self.toolbox.project_item_model.rowCount() - # Data Stores, Data Connections, Tools, Views, Importers, Exporters, Manipulators - self.assertEqual(n, 7) + # Data Stores, Data Connections, Tools, Notebooks, Views, Importers, Exporters, Manipulators + self.assertEqual(n, 8) # Check that there's only one column self.assertEqual(self.toolbox.project_item_model.columnCount(), 1) # Check that the items DisplayRoles are (In this particular order) From d97648dda81853e59269c649f7dfca0695c455e6 Mon Sep 17 00:00:00 2001 From: RichieBrady Date: Mon, 12 Apr 2021 17:03:28 +0100 Subject: [PATCH 3/3] Adding Notebooks to test --- tests/test_toolboxUI.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/test_toolboxUI.py b/tests/test_toolboxUI.py index 5ded86321..d3e422f61 100644 --- a/tests/test_toolboxUI.py +++ b/tests/test_toolboxUI.py @@ -111,25 +111,30 @@ def check_init_project_item_model(self): item3.parent(), RootProjectTreeItem, "Parent item of category item on row 2 should be root" ) item4 = self.toolbox.project_item_model.root().child(3) - self.assertEqual(item4.name, "Views", "Item on row 3 is not 'Views'") + self.assertEqual(item4.name, "Notebooks", "Item on row 3 is not 'Notebooks'") self.assertIsInstance( item4.parent(), RootProjectTreeItem, "Parent item of category item on row 3 should be root" ) item5 = self.toolbox.project_item_model.root().child(4) - self.assertEqual(item5.name, "Importers", "Item on row 4 is not 'Importers'") + self.assertEqual(item5.name, "Views", "Item on row 4 is not 'Views'") self.assertIsInstance( item5.parent(), RootProjectTreeItem, "Parent item of category item on row 4 should be root" ) item6 = self.toolbox.project_item_model.root().child(5) - self.assertEqual(item6.name, "Exporters", "Item on row 5 is not 'Exporters'") + self.assertEqual(item6.name, "Importers", "Item on row 5 is not 'Importers'") self.assertIsInstance( item6.parent(), RootProjectTreeItem, "Parent item of category item on row 5 should be root" ) item7 = self.toolbox.project_item_model.root().child(6) - self.assertEqual(item7.name, "Manipulators", "Item on row 6 is not 'Manipulators'") + self.assertEqual(item7.name, "Exporters", "Item on row 6 is not 'Exporters'") self.assertIsInstance( item7.parent(), RootProjectTreeItem, "Parent item of category item on row 6 should be root" ) + item8 = self.toolbox.project_item_model.root().child(7) + self.assertEqual(item8.name, "Manipulators", "Item on row 7 is not 'Manipulators'") + self.assertIsInstance( + item8.parent(), RootProjectTreeItem, "Parent item of category item on row 7 should be root" + ) def test_init_specification_model(self): """Check that specification model has no items after init and that