From 1fad5594751b31fb898cbb560a003aa9cc36c61b Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Fri, 10 Nov 2023 15:10:44 +0100 Subject: [PATCH] fix tests: - extend mock app config by display_builtin_converters --- lib/galaxy/app_unittest_utils/galaxy_mock.py | 1 + lib/galaxy/tool_util/toolbox/base.py | 1 - test/unit/app/tools/test_toolbox.py | 30 +++++++++++++------ .../unit/shed_unit/test_tool_panel_manager.py | 9 ++++-- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/lib/galaxy/app_unittest_utils/galaxy_mock.py b/lib/galaxy/app_unittest_utils/galaxy_mock.py index 117873b2c128..ac292a2e5fee 100644 --- a/lib/galaxy/app_unittest_utils/galaxy_mock.py +++ b/lib/galaxy/app_unittest_utils/galaxy_mock.py @@ -205,6 +205,7 @@ def __init__(self, **kwargs): 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 @property def config_dict(self): diff --git a/lib/galaxy/tool_util/toolbox/base.py b/lib/galaxy/tool_util/toolbox/base.py index cd48f8b2725e..846902625103 100644 --- a/lib/galaxy/tool_util/toolbox/base.py +++ b/lib/galaxy/tool_util/toolbox/base.py @@ -32,7 +32,6 @@ string_as_bool, unicodify, ) - from galaxy.util.bunch import Bunch from galaxy.util.dictifiable import Dictifiable from .filters import FilterFactory diff --git a/test/unit/app/tools/test_toolbox.py b/test/unit/app/tools/test_toolbox.py index 7ef73e80f3df..39dfe0b33d82 100644 --- a/test/unit/app/tools/test_toolbox.py +++ b/test/unit/app/tools/test_toolbox.py @@ -412,14 +412,15 @@ def test_group_tools_out_of_section(self): self._setup_two_versions() self.__verify_two_test_tools() - # Assert tools merged in tool panel. - assert len(self.toolbox._tool_panel) == 1 + # Assert tools merged in tool panel (2nd element is the built in converters section loaded per default) + assert len(self.toolbox._tool_panel) == 2 def test_get_section_by_label(self): self._add_config( """
""" ) - assert len(self.toolbox._tool_panel) == 1 + # assert len of 2: the section + the builtin converters that are loaded per default + assert len(self.toolbox._tool_panel) == 2 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 @@ -466,7 +467,8 @@ def test_workflow_in_panel(self): stored_workflow = self.__test_workflow() encoded_id = self.app.security.encode_id(stored_workflow.id) self._add_config("""""" % encoded_id) - assert len(self.toolbox._tool_panel) == 1 + # assert len of 2: the workflow + the builtin converters that are loaded per default + assert len(self.toolbox._tool_panel) == 2 panel_workflow = next(iter(self.toolbox._tool_panel.values())) assert panel_workflow == stored_workflow.latest_workflow # TODO: test to_dict with workflows @@ -477,7 +479,8 @@ def test_workflow_in_section(self): self._add_config( """
""" % encoded_id ) - assert len(self.toolbox._tool_panel) == 1 + # assert len of 2: the section + the builtin converters that are loaded per default + assert len(self.toolbox._tool_panel) == 2 section = self.toolbox._tool_panel["tid"] assert len(section.elems) == 1 panel_workflow = next(iter(section.elems.values())) @@ -485,14 +488,17 @@ def test_workflow_in_section(self): def test_label_in_panel(self): self._add_config("""""") - assert len(self.toolbox._tool_panel) == 2 + + # assert len of 3: 2 labels + the builtin converters that are loaded per default + assert len(self.toolbox._tool_panel) == 3 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 of 2: section + the builtin converters that are loaded per default + assert len(self.toolbox._tool_panel) == 2 section = self.toolbox._tool_panel["tid"] self.__check_test_labels(section.elems) @@ -510,7 +516,12 @@ def _init_tool_in_section(self, json=False): 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" @@ -584,7 +595,8 @@ def __init_versioned_tools(self): 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 of 2: the section + the builtin converters that are loaded per default + assert len(self.toolbox._tool_panel) == 2 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/shed_unit/test_tool_panel_manager.py b/test/unit/shed_unit/test_tool_panel_manager.py index 1314506332c5..0adf7a288e95 100644 --- a/test/unit/shed_unit/test_tool_panel_manager.py +++ b/test/unit/shed_unit/test_tool_panel_manager.py @@ -25,20 +25,23 @@ def test_handle_tool_panel_section(self): assert section_id == "tid" assert len(section.elems) == 1 # tool.xml assert section.id == "tid" - assert len(toolbox._tool_panel) == 1 + # assert len of 2: the section + the builtin converters that are loaded per default + assert len(toolbox._tool_panel) == 2 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 of 3: tid, tid2 + the builtin converters that are loaded per default + assert len(toolbox._tool_panel) == 3 # 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 of 3: tid, tid2 + the builtin converters that are loaded per default + assert len(toolbox._tool_panel) == 3 def test_add_tool_to_panel(self): self._init_ts_tool(guid=DEFAULT_GUID)