mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Extend tools API to allow use of data params with multiple='true' with multiple values.
Likewise extend API driven tool testing framework to support these, add sample test cases. Also fixup english on a log warning.
This commit is contained in:
@@ -1739,7 +1739,13 @@ class DataToolParameter( ToolParameter ):
|
||||
if isinstance( value, str ) and value.find( "," ) > 0:
|
||||
value = [ int( value_part ) for value_part in value.split( "," ) ]
|
||||
if isinstance( value, list ):
|
||||
rval = [ trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( v ) for v in value ]
|
||||
rval = []
|
||||
for single_value in value:
|
||||
if isinstance( single_value, dict ):
|
||||
assert single_value['src'] == 'hda'
|
||||
rval.append( trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( trans.app.security.decode_id( single_value[ 'id' ] ) ) )
|
||||
else:
|
||||
rval.append( trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( single_value ) )
|
||||
elif isinstance( value, trans.app.model.HistoryDatasetAssociation ):
|
||||
rval = value
|
||||
elif isinstance( value, dict ) and 'src' in value and 'id' in value:
|
||||
|
||||
@@ -179,10 +179,12 @@ class ToolTestBuilder( object ):
|
||||
raw_input = context.extract_value( raw_inputs )
|
||||
if raw_input:
|
||||
(name, param_value, param_extra) = raw_input
|
||||
param_value = self.__split_if_str( param_value )
|
||||
if isinstance( value, basic.DataToolParameter ):
|
||||
processed_value = [ self.__add_uploaded_dataset( context.for_state(), param_value, param_extra, value ) ]
|
||||
if not isinstance(param_value, list):
|
||||
param_value = [ param_value ]
|
||||
processed_value = [ self.__add_uploaded_dataset( context.for_state(), v, param_extra, value ) for v in param_value ]
|
||||
else:
|
||||
param_value = self.__split_if_str( param_value )
|
||||
processed_value = param_value
|
||||
expanded_inputs[ context.for_state() ] = processed_value
|
||||
return expanded_inputs
|
||||
@@ -309,7 +311,7 @@ def __parse_output_elem( output_elem ):
|
||||
for metadata_elem in output_elem.findall( 'metadata' ):
|
||||
metadata[ metadata_elem.get('name') ] = metadata_elem.get( 'value' )
|
||||
if not (assert_list or file or extra_files or metadata):
|
||||
raise Exception( "Test output defines not checks (e.g. must have a 'file' check against, assertions to check, etc...)")
|
||||
raise Exception( "Test output defines nothting to check (e.g. must have a 'file' check against, assertions to check, etc...)")
|
||||
attributes['assert_list'] = assert_list
|
||||
attributes['extra_files'] = extra_files
|
||||
attributes['metadata'] = metadata
|
||||
|
||||
@@ -133,9 +133,13 @@ class GalaxyInteractorApi( object ):
|
||||
inputs_tree = testdef.inputs.copy()
|
||||
for key, value in inputs_tree.iteritems():
|
||||
values = [value] if not isinstance(value, list) else value
|
||||
new_values = []
|
||||
for value in values:
|
||||
if value in self.uploads:
|
||||
inputs_tree[ key ] = self.uploads[ value ]
|
||||
new_values.append( self.uploads[ value ] )
|
||||
else:
|
||||
new_values.append( value )
|
||||
inputs_tree[ key ] = new_values
|
||||
|
||||
# # HACK: Flatten single-value lists. Required when using expand_grouping
|
||||
for key, value in inputs_tree.iteritems():
|
||||
|
||||
@@ -18,13 +18,23 @@
|
||||
<output name="out1" file="simple_line.txt" />
|
||||
<output name="out2" file="simple_line_alternative.txt" />
|
||||
</test>
|
||||
<!-- TODO: Support this or something like this.
|
||||
<test>
|
||||
<param name="f1" value="simple_line.txt,simple_line_alternative.txt" />
|
||||
<param name="f2" value="simple_line_alternative.txt" />
|
||||
<output name="out1">
|
||||
<assert_contents>
|
||||
<has_line line="This is a line of text." />
|
||||
<has_line line="This is a different line of text." />
|
||||
</assert_contents>
|
||||
</output>
|
||||
</test>
|
||||
<!-- Twill interactor cannot do these latter two, but not even
|
||||
UI widget can do this next one. -->
|
||||
<test>
|
||||
<param name="f1" value="simple_line.txt,simple_line.txt" />
|
||||
<param name="f2" value="simple_line_alternative.txt" />
|
||||
<output name="out1" file="simple_line_x2.txt" />
|
||||
<output name="out1" file="simple_line_alternative.txt" />
|
||||
<output name="out2" file="simple_line_alternative.txt" />
|
||||
</test>
|
||||
-->
|
||||
</tests>
|
||||
</tool>
|
||||
|
||||
Reference in New Issue
Block a user