Skip to content

Commit

Permalink
fix tests:
Browse files Browse the repository at this point in the history
- extend mock app config by display_builtin_converters
  • Loading branch information
bernt-matthias committed Nov 20, 2023
1 parent 095e9c1 commit 1fad559
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
1 change: 1 addition & 0 deletions lib/galaxy/app_unittest_utils/galaxy_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 0 additions & 1 deletion lib/galaxy/tool_util/toolbox/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
string_as_bool,
unicodify,
)

from galaxy.util.bunch import Bunch
from galaxy.util.dictifiable import Dictifiable
from .filters import FilterFactory
Expand Down
30 changes: 21 additions & 9 deletions test/unit/app/tools/test_toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
"""<toolbox><section id="tid" name="Completely unrelated"><label id="lab1" text="Label 1" /><label id="lab2" text="Label 2" /></section></toolbox>"""
)
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
Expand Down Expand Up @@ -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("""<toolbox><workflow id="%s" /></toolbox>""" % 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
Expand All @@ -477,22 +479,26 @@ def test_workflow_in_section(self):
self._add_config(
"""<toolbox><section id="tid" name="TID"><workflow id="%s" /></section></toolbox>""" % 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()))
assert panel_workflow == stored_workflow.latest_workflow

def test_label_in_panel(self):
self._add_config("""<toolbox><label id="lab1" text="Label 1" /><label id="lab2" text="Label 2" /></toolbox>""")
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(
"""<toolbox><section id="tid" name="TID"><label id="lab1" text="Label 1" /><label id="lab2" text="Label 2" /></section></toolbox>"""
)
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)

Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
9 changes: 6 additions & 3 deletions test/unit/shed_unit/test_tool_panel_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1fad559

Please sign in to comment.