Skip to content

Commit

Permalink
Rebase into test case commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Aug 11, 2024
1 parent 31002fa commit 477a1a1
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 12 deletions.
10 changes: 10 additions & 0 deletions lib/galaxy/tool_util/parameters/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
FloatParameterModel,
IntegerParameterModel,
RepeatParameterModel,
SectionParameterModel,
ToolParameterT,
)
from .state import TestCaseToolState
Expand Down Expand Up @@ -235,6 +236,15 @@ def _merge_into_state(
repeat.parameters, inputs, repeat_state_array[i], profile, warnings, repeat_instance_prefix
)
)
elif isinstance(tool_input, (SectionParameterModel,)):
section_state = state_at_level.get(input_name, {})
if input_name not in state_at_level:
state_at_level[input_name] = section_state

section = cast(SectionParameterModel, tool_input)
handled_inputs.update(
_merge_level_into_state(section.parameters, inputs, section_state, profile, warnings, state_path)
)
else:
test_input = _input_for(state_path, inputs)
if test_input is not None:
Expand Down
43 changes: 43 additions & 0 deletions test/functional/tools/section_24_2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<tool id="section_24_2" name="section_24_2" version="1.0.0" profile="24.2">
<command><![CDATA[
echo $int.inttest > '$out_file1' &&
echo $float.floattest >> '$out_file1'
]]></command>
<inputs>
<section name="int" title="Integer Section" expanded="true">
<param name="inttest" value="1" type="integer" />
</section>
<section name="float" title="Float Section" expanded="false">
<param name="floattest" value="1.0" type="float" />
</section>
</inputs>
<outputs>
<data name="out_file1" format="txt" />
</outputs>
<tests>
<test>
<param name="int|inttest" value="12456" />
<param name="float|floattest" value="6.789" />
<output name="out_file1">
<assert_contents>
<has_line line="12456" />
<has_line line="6.789" />
</assert_contents>
</output>
</test>
<test>
<section name="int">
<param name="inttest" value="12456" />
</section>
<section name="float">
<param name="floattest" value="6.789" />
</section>
<output name="out_file1">
<assert_contents>
<has_line line="12456" />
<has_line line="6.789" />
</assert_contents>
</output>
</test>
</tests>
</tool>
18 changes: 6 additions & 12 deletions test/unit/tool_util/test_parameter_test_cases.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import re
from typing import List

from galaxy.tool_util.models import parse_tool
Expand Down Expand Up @@ -77,21 +78,14 @@ def _assert_tool_test_parsing_only_fails_with_newer_profile(tmp_path, filename:
new_path = tmp_path / filename
with open(original_path) as rf:
tool_contents = rf.read()
import re

tool_contents = re.sub('profile=".*"', r"", tool_contents)
print(tool_contents)
tool_contents = re.sub(r'profile="[\d\.]*"', r"", tool_contents)
new_profile_contents = tool_contents.replace("<tool ", '<tool profile="24.2" ', 1)
with open(new_path, "w") as wf:
wf.write(new_profile_contents)
parse_tool_test_descriptions(get_tool_source(original_path))
exception = None
try:
parse_tool_test_descriptions(get_tool_source(new_path))
except Exception as e:
print(e)
exception = e
assert exception, f"expected {filename} to have validation failure preventing loading of tools"
test_cases = parse_tool_test_descriptions(get_tool_source(original_path))
assert test_cases[0].to_dict()["error"] is False
test_cases = parse_tool_test_descriptions(get_tool_source(new_path))
assert test_cases[0].to_dict()["error"] is True, f"expected {filename} to have validation failure preventing loading of tools"


def test_validate_framework_test_tools():
Expand Down

0 comments on commit 477a1a1

Please sign in to comment.