mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-24 12:13:33 +08:00
Merged in jmchilton/galaxy-central-fork-1 (pull request #387)
Recursive Tool Parameter Dictification
This commit is contained in:
@@ -53,6 +53,9 @@ class Group( object, Dictifiable ):
|
||||
return group_dict
|
||||
|
||||
class Repeat( Group ):
|
||||
|
||||
dict_collection_visible_keys = ( 'name', 'type', 'title', 'help', 'default', 'min', 'max' )
|
||||
|
||||
type = "repeat"
|
||||
def __init__( self ):
|
||||
Group.__init__( self )
|
||||
@@ -117,6 +120,16 @@ class Repeat( Group ):
|
||||
rval.append( rval_dict )
|
||||
return rval
|
||||
|
||||
def to_dict( self, trans, view='collection', value_mapper=None ):
|
||||
repeat_dict = super( Repeat, self ).to_dict( trans, view=view, value_mapper=value_mapper )
|
||||
|
||||
def input_to_dict( input ):
|
||||
return input.to_dict( trans, view=view, value_mapper=value_mapper )
|
||||
|
||||
repeat_dict[ "inputs" ] = map( input_to_dict, self.inputs.values() )
|
||||
return repeat_dict
|
||||
|
||||
|
||||
class UploadDataset( Group ):
|
||||
type = "upload_dataset"
|
||||
def __init__( self ):
|
||||
@@ -517,7 +530,29 @@ class Conditional( Group ):
|
||||
rval[ child_input.name ] = child_input.get_initial_value( trans, child_context, history=history )
|
||||
return rval
|
||||
|
||||
class ConditionalWhen( object ):
|
||||
def to_dict( self, trans, view='collection', value_mapper=None ):
|
||||
cond_dict = super( Conditional, self ).to_dict( trans, view=view, value_mapper=value_mapper )
|
||||
|
||||
def nested_to_dict( input ):
|
||||
return input.to_dict( trans, view=view, value_mapper=value_mapper )
|
||||
|
||||
cond_dict[ "cases" ] = map( nested_to_dict, self.cases )
|
||||
cond_dict[ "test_param" ] = nested_to_dict( self.test_param )
|
||||
return cond_dict
|
||||
|
||||
|
||||
class ConditionalWhen( object, Dictifiable ):
|
||||
dict_collection_visible_keys = ( 'value', )
|
||||
|
||||
def __init__( self ):
|
||||
self.value = None
|
||||
self.inputs = None
|
||||
|
||||
def to_dict( self, trans, view='collection', value_mapper=None ):
|
||||
when_dict = super( ConditionalWhen, self ).to_dict( view=view, value_mapper=value_mapper )
|
||||
|
||||
def input_to_dict( input ):
|
||||
return input.to_dict( trans, view=view, value_mapper=value_mapper )
|
||||
|
||||
when_dict[ "inputs" ] = map( input_to_dict, self.inputs.values() )
|
||||
return when_dict
|
||||
|
||||
@@ -25,6 +25,49 @@ class ToolsTestCase( api.ApiTestCase ):
|
||||
tool_ids = map( itemgetter( "id" ), tools_index )
|
||||
assert "upload1" in tool_ids
|
||||
|
||||
@skip_without_tool( "cat1" )
|
||||
def test_show_repeat( self ):
|
||||
tool_info = self._show_valid_tool( "cat1" )
|
||||
parameters = tool_info[ "inputs" ]
|
||||
assert len( parameters ) == 2
|
||||
assert parameters[ 0 ][ "name" ] == "input1"
|
||||
assert parameters[ 1 ][ "name" ] == "queries"
|
||||
|
||||
repeat_info = parameters[ 1 ]
|
||||
self._assert_has_keys( repeat_info, "min", "max", "title", "help" )
|
||||
repeat_params = repeat_info[ "inputs" ]
|
||||
assert len( repeat_params ) == 1
|
||||
assert repeat_params[ 0 ][ "name" ] == "input2"
|
||||
|
||||
@skip_without_tool( "random_lines1" )
|
||||
def test_show_conditional( self ):
|
||||
tool_info = self._show_valid_tool( "random_lines1" )
|
||||
|
||||
cond_info = tool_info[ "inputs" ][ 2 ]
|
||||
self._assert_has_keys( cond_info, "cases", "test_param" )
|
||||
self._assert_has_keys( cond_info[ "test_param" ], 'name', 'type', 'label', 'help' )
|
||||
|
||||
cases = cond_info[ "cases" ]
|
||||
assert len( cases ) == 2
|
||||
case1 = cases[ 0 ]
|
||||
self._assert_has_keys( case1, "value", "inputs" )
|
||||
assert case1[ "value" ] == "no_seed"
|
||||
assert len( case1[ "inputs" ] ) == 0
|
||||
|
||||
case2 = cases[ 1 ]
|
||||
self._assert_has_keys( case2, "value", "inputs" )
|
||||
case2_inputs = case2[ "inputs" ]
|
||||
assert len( case2_inputs ) == 1
|
||||
self._assert_has_keys( case2_inputs[ 0 ], 'name', 'type', 'label', 'help' )
|
||||
assert case2_inputs[ 0 ][ "name" ] == "seed"
|
||||
|
||||
def _show_valid_tool( self, tool_id ):
|
||||
tool_show_response = self._get( "tools/%s" % tool_id, data=dict( io_details=True ) )
|
||||
self._assert_status_code_is( tool_show_response, 200 )
|
||||
tool_info = tool_show_response.json()
|
||||
self._assert_has_keys( tool_info, "inputs", "outputs", "panel_section_id" )
|
||||
return tool_info
|
||||
|
||||
def test_upload1_paste( self ):
|
||||
history_id = self.dataset_populator.new_history()
|
||||
payload = self.dataset_populator.upload_payload( history_id, 'Hello World' )
|
||||
|
||||
Reference in New Issue
Block a user