diff --git a/lib/galaxy/app.py b/lib/galaxy/app.py index affa3ea7c85..0d7f1abc422 100644 --- a/lib/galaxy/app.py +++ b/lib/galaxy/app.py @@ -703,9 +703,6 @@ class UniverseApplication(StructuredApp, GalaxyManagerApplication): self.datatypes_registry.load_external_metadata_tool(self.toolbox) # Load history import/export tools. load_lib_tools(self.toolbox) - # Load built-in converters - if self.config.display_builtin_converters: - self.toolbox.load_builtin_converters() self.toolbox.persist_cache(register_postfork=True) # visualizations registry: associates resources with visualizations, controls how to render self.visualizations_registry = self._register_singleton( diff --git a/lib/galaxy/app_unittest_utils/galaxy_mock.py b/lib/galaxy/app_unittest_utils/galaxy_mock.py index d6a773e214e..9a9e21cbddc 100644 --- a/lib/galaxy/app_unittest_utils/galaxy_mock.py +++ b/lib/galaxy/app_unittest_utils/galaxy_mock.py @@ -158,6 +158,10 @@ class MockApp(di.Container, GalaxyDataTestApp): def toolbox(self) -> ToolBox: return self._toolbox + @toolbox.setter + def toolbox(self, toolbox: ToolBox): + self._toolbox = toolbox + def wait_for_toolbox_reload(self, toolbox): # TODO: If the tpm test case passes, does the operation really # need to wait. @@ -258,6 +262,7 @@ class MockAppConfig(GalaxyDataTestConfig, CommonConfigurationMixin): self.integrated_tool_panel_config = None self.vault_config_file = kwargs.get("vault_config_file") self.max_discovered_files = 10000 + self.display_builtin_converters = True self.enable_notification_system = True @property diff --git a/lib/galaxy/app_unittest_utils/tools_support.py b/lib/galaxy/app_unittest_utils/tools_support.py index 6c94d5eb59d..e29b96dc029 100644 --- a/lib/galaxy/app_unittest_utils/tools_support.py +++ b/lib/galaxy/app_unittest_utils/tools_support.py @@ -1,6 +1,6 @@ """ Module contains test fixtures meant to aide in the testing of jobs and tool evaluation. Such extensive "fixtures" are something of an anti-pattern -so use of this should be limitted to tests of very 'extensive' classes. +so use of this should be limited to tests of very 'extensive' classes. """ import os.path diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index d94f5b4d3c0..5831359a841 100644 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -442,7 +442,9 @@ class ToolBox(AbstractToolBox): default_panel_view=default_panel_view, save_integrated_tool_panel=save_integrated_tool_panel, ) - + # Load built-in converters + if app.config.display_builtin_converters: + self.load_builtin_converters() if old_toolbox := getattr(app, "toolbox", None): self.dependency_manager = old_toolbox.dependency_manager else: diff --git a/test/unit/app/tools/test_toolbox.py b/test/unit/app/tools/test_toolbox.py index f003fb51927..f4faaa370a1 100644 --- a/test/unit/app/tools/test_toolbox.py +++ b/test/unit/app/tools/test_toolbox.py @@ -239,13 +239,14 @@ class TestToolBox(BaseToolBoxTestCase): self.__verify_two_test_tools() # Assert tools merged in tool panel. - assert len(self.toolbox._tool_panel) == 1 + assert len(self.toolbox._tool_panel) == 2 # 1 tool (w 2 versions) + built-in converters def test_get_section_by_label(self): self._add_config( """
""" ) - assert len(self.toolbox._tool_panel) == 1 + print(self.toolbox._tool_panel) + assert len(self.toolbox._tool_panel) == 2 # section + built-in converters section = self.toolbox._tool_panel["tid"] tool_panel_section_key, section_by_label = self.toolbox.get_section( section_id="nope", new_label="Completely unrelated", create_if_needed=True @@ -292,7 +293,7 @@ class TestToolBox(BaseToolBoxTestCase): stored_workflow = self.__test_workflow() encoded_id = self.app.security.encode_id(stored_workflow.id) self._add_config(f"""""") - assert len(self.toolbox._tool_panel) == 1 + assert len(self.toolbox._tool_panel) == 2 # workflow + built-in converters section panel_workflow = next(iter(self.toolbox._tool_panel.values())) assert panel_workflow == stored_workflow.latest_workflow # TODO: test to_dict with workflows @@ -303,7 +304,7 @@ class TestToolBox(BaseToolBoxTestCase): self._add_config( f"""
""" ) - assert len(self.toolbox._tool_panel) == 1 + assert len(self.toolbox._tool_panel) == 2 # workflow + built-in converters section section = self.toolbox._tool_panel["tid"] assert len(section.elems) == 1 panel_workflow = next(iter(section.elems.values())) @@ -311,14 +312,14 @@ class TestToolBox(BaseToolBoxTestCase): def test_label_in_panel(self): self._add_config("""""") - assert len(self.toolbox._tool_panel) == 2 + assert len(self.toolbox._tool_panel) == 3 # 2 labels + built-in converters section self.__check_test_labels(self.toolbox._tool_panel) def test_label_in_section(self): self._add_config( """
""" ) - assert len(self.toolbox._tool_panel) == 1 + assert len(self.toolbox._tool_panel) == 2 # section + built-in converters section section = self.toolbox._tool_panel["tid"] self.__check_test_labels(section.elems) @@ -336,7 +337,12 @@ class TestToolBox(BaseToolBoxTestCase): self._add_config({"items": [section]}, name="tool_conf.json") def __check_test_labels(self, panel_dict): - assert list(panel_dict.keys()) == ["label_lab1", "label_lab2"] + # if panel_dict is the complete panel it will contain builtin_converters + # if its a section then not + assert list(panel_dict.keys()) in ( + ["label_lab1", "label_lab2", "builtin_converters"], + ["label_lab1", "label_lab2"], + ) label1 = next(iter(panel_dict.values())) assert label1.id == "lab1" assert label1.text == "Label 1" @@ -412,7 +418,7 @@ class TestToolBox(BaseToolBoxTestCase): self._init_tool(filename="tool_v02.xml", version="0.2") def __verify_tool_panel_for_default_lineage(self): - assert len(self.toolbox._tool_panel) == 1 + assert len(self.toolbox._tool_panel) == 2 # tool + built-in-converters section tool = self.toolbox._tool_panel["tool_test_tool"] assert tool.version == "0.2", tool.version assert tool.id == "test_tool" diff --git a/test/unit/tool_shed/test_tool_panel_manager.py b/test/unit/tool_shed/test_tool_panel_manager.py index 751a7c5f5c4..9217b7347c6 100644 --- a/test/unit/tool_shed/test_tool_panel_manager.py +++ b/test/unit/tool_shed/test_tool_panel_manager.py @@ -25,20 +25,20 @@ class TestToolPanelManager(BaseToolBoxTestCase): assert section_id == "tid" assert len(section.elems) == 1 # tool.xml assert section.id == "tid" - assert len(toolbox._tool_panel) == 1 + assert len(toolbox._tool_panel) == 2 # section + built-in converters section section_id, section = tpm.handle_tool_panel_section(toolbox, new_tool_panel_section_label="tid2") assert section_id == "tid2" assert len(section.elems) == 0 # new section assert section.id == "tid2" - assert len(toolbox._tool_panel) == 2 + assert len(toolbox._tool_panel) == 3 # 2 sections + built-in converters section # Test re-fetch new section by same id. section_id, section = tpm.handle_tool_panel_section(toolbox, new_tool_panel_section_label="tid2") assert section_id == "tid2" assert len(section.elems) == 0 # new section assert section.id == "tid2" - assert len(toolbox._tool_panel) == 2 + assert len(toolbox._tool_panel) == 3 # 2 sections + built-in converters section def test_add_tool_to_panel(self): self._init_ts_tool(guid=DEFAULT_GUID)