1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/44ac8fc8f7b6/ Changeset: 44ac8fc8f7b6 User: jmchilton Date: 2014-05-15 20:43:43 Summary: Merged in jmchilton/galaxy-central-fork-1 (pull request #387) Recursive Tool Parameter Dictification Affected #: 2 files diff -r f24bb5dde1f5f23353bd410001bf2b2ce82a9653 -r 44ac8fc8f7b6789cff1302a15d53f6181a54118b lib/galaxy/tools/parameters/grouping.py --- a/lib/galaxy/tools/parameters/grouping.py +++ b/lib/galaxy/tools/parameters/grouping.py @@ -53,6 +53,9 @@ 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 @@ 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 @@ 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 diff -r f24bb5dde1f5f23353bd410001bf2b2ce82a9653 -r 44ac8fc8f7b6789cff1302a15d53f6181a54118b test/api/test_tools.py --- a/test/api/test_tools.py +++ b/test/api/test_tools.py @@ -25,6 +25,49 @@ 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' ) Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.