Skip to content

Commit 9274400

Browse files
committed
Merge pull request #1 from jmchilton/tool_form_section_tag
Tool testing sections.
2 parents a3cdf22 + 3b263a8 commit 9274400

4 files changed

Lines changed: 64 additions & 1 deletion

File tree

lib/galaxy/tools/parser/xml.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,13 @@ def __expand_input_elems( root_elem, prefix="" ):
418418
__pull_up_params( root_elem, cond_elem )
419419
root_elem.remove( cond_elem )
420420

421+
section_elems = root_elem.findall( 'section' )
422+
for section_elem in section_elems:
423+
new_prefix = __prefix_join( prefix, section_elem.get( "name" ) )
424+
__expand_input_elems( section_elem, new_prefix )
425+
__pull_up_params( root_elem, section_elem )
426+
root_elem.remove( section_elem )
427+
421428

422429
def __append_prefix_to_params( elem, prefix ):
423430
for param_elem in elem.findall( 'param' ):

lib/galaxy/tools/test.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,12 @@ def __process_raw_inputs( self, tool_inputs, raw_inputs, parent_context=None ):
166166
# an infinite loop - hence the "case_value is not None"
167167
# check.
168168
expanded_inputs[ case_context.for_state() ] = expanded_case_value
169-
169+
elif isinstance( value, galaxy.tools.parameters.grouping.Section ):
170+
context = ParamContext( name=value.name, parent_context=parent_context )
171+
for r_name, r_value in value.inputs.iteritems():
172+
expanded_input = self.__process_raw_inputs( { context.for_state(): r_value }, raw_inputs, parent_context=context )
173+
if expanded_input:
174+
expanded_inputs.update( expanded_input )
170175
elif isinstance( value, galaxy.tools.parameters.grouping.Repeat ):
171176
repeat_index = 0
172177
while True:
@@ -364,6 +369,13 @@ def expand_input_elems( root_elem, prefix="" ):
364369
__pull_up_params( root_elem, cond_elem )
365370
root_elem.remove( cond_elem )
366371

372+
section_elems = root_elem.findall( 'section' )
373+
for section_elem in section_elems:
374+
new_prefix = __prefix_join( prefix, section_elem.get( "name" ) )
375+
expand_input_elems( section_elem, new_prefix )
376+
__pull_up_params( root_elem, section_elem )
377+
root_elem.remove( section_elem )
378+
367379

368380
def __append_prefix_to_params( elem, prefix ):
369381
for param_elem in elem.findall( 'param' ):

test/functional/tools/samples_tool_conf.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<tool file="column_param.xml" />
2929
<tool file="column_multi_param.xml" />
3030
<tool file="special_params.xml" />
31+
<tool file="section.xml" />
3132
<tool file="top_level_data.xml" />
3233
<tool file="validation_default.xml" />
3334
<tool file="validation_sanitizer.xml" />

test/functional/tools/section.xml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<tool id="section" name="section">
2+
<command>
3+
echo "$int.inttest" >> $out_file1;
4+
echo "$float.floattest" >> $out_file1;
5+
</command>
6+
<inputs>
7+
<section name="int" title="Integer Section" expanded="true">
8+
<param name="inttest" value="1" type="integer" />
9+
</section>
10+
<section name="float" title="Float Section" expanded="false">
11+
<param name="floattest" value="1.0" type="float" />
12+
</section>
13+
</inputs>
14+
<outputs>
15+
<data name="out_file1" format="txt" />
16+
</outputs>
17+
<tests>
18+
<test>
19+
<param name="inttest" value="12456" />
20+
<param name="floattest" value="6.789" />
21+
<output name="out_file1">
22+
<assert_contents>
23+
<has_line line="12456" />
24+
<has_line line="6.789" />
25+
</assert_contents>
26+
</output>
27+
</test>
28+
<test>
29+
<section name="int">
30+
<param name="inttest" value="12456" />
31+
</section>
32+
<section name="float">
33+
<param name="floattest" value="6.789" />
34+
</section>
35+
<output name="out_file1">
36+
<assert_contents>
37+
<has_line line="12456" />
38+
<has_line line="6.789" />
39+
</assert_contents>
40+
</output>
41+
</test>
42+
</tests>
43+
</tool>

0 commit comments

Comments
 (0)