commit/galaxy-central: 2 new changesets
2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/503392692e9b/ Changeset: 503392692e9b User: jmchilton Date: 2014-07-04 03:41:09 Summary: Fix unit tests broken with 4de240e. Affected #: 1 file diff -r 63a7243c12dad6c9bf8ab1c58213405e38a5c17e -r 503392692e9b8145fe17886c7f2bec934fa7ebc0 test/unit/tools/test_collect_primary_datasets.py --- a/test/unit/tools/test_collect_primary_datasets.py +++ b/test/unit/tools/test_collect_primary_datasets.py @@ -191,7 +191,7 @@ def _collect( self, job_working_directory=None ): if not job_working_directory: job_working_directory = self.test_directory - return self.tool.collect_primary_datasets( self.outputs, job_working_directory ) + return self.tool.collect_primary_datasets( self.outputs, job_working_directory, "txt" ) def _replace_output_collectors( self, xml_str ): # Rewrite tool as if it had been created with output containing https://bitbucket.org/galaxy/galaxy-central/commits/4139740da48e/ Changeset: 4139740da48e User: jmchilton Date: 2014-07-04 03:41:09 Summary: Fix tool multi-run inside conditionals and repeats during state updates. Fixes multirun inside of conditional, repeats if tool form state updated (e.g. because conditional param updated or repeat block added). More tests - ugly tests - but tests. Affected #: 2 files diff -r 503392692e9b8145fe17886c7f2bec934fa7ebc0 -r 4139740da48e24d96a475da67613be92fbdba478 lib/galaxy/tools/__init__.py --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -2507,13 +2507,16 @@ incoming_value = get_incoming_value( incoming, key, None ) value, error = check_param( trans, input, incoming_value, context, source=source ) # If a callback was provided, allow it to process the value + input_name = input.name if item_callback: - old_value = state.get( input.name, None ) + old_value = state.get( input_name, None ) value, error = item_callback( trans, key, input, value, error, old_value, context ) if error: - errors[ input.name ] = error - state[ input.name ] = value - state.update( self.__meta_properties_for_state( key, incoming, incoming_value, value ) ) + errors[ input_name ] = error + + state[ input_name ] = value + meta_properties = self.__meta_properties_for_state( key, incoming, incoming_value, value, input_name ) + state.update( meta_properties ) return errors def __remove_meta_properties( self, incoming ): @@ -2527,12 +2530,17 @@ del result[ key ] return result - def __meta_properties_for_state( self, key, incoming, incoming_val, state_val ): + def __meta_properties_for_state( self, key, incoming, incoming_val, state_val, input_name ): meta_properties = {} - multirun_key = "%s|__multirun__" % key - if multirun_key in incoming: - multi_value = incoming[ multirun_key ] - meta_properties[ multirun_key ] = multi_value + meta_property_suffixes = [ + "__multirun__", + "__collection_multirun__", + ] + for meta_property_suffix in meta_property_suffixes: + multirun_key = "%s|%s" % ( key, meta_property_suffix ) + if multirun_key in incoming: + multi_value = incoming[ multirun_key ] + meta_properties[ "%s|%s" % ( input_name, meta_property_suffix ) ] = multi_value return meta_properties @property diff -r 503392692e9b8145fe17886c7f2bec934fa7ebc0 -r 4139740da48e24d96a475da67613be92fbdba478 test/unit/tools/test_execution.py --- a/test/unit/tools/test_execution.py +++ b/test/unit/tools/test_execution.py @@ -38,6 +38,7 @@ self.setup_app() self.history = galaxy.model.History() self.trans = MockTrans( self.app, self.history ) + self.app.dataset_collections_service = MockCollectionService() self.tool_action = MockAction( self.trans ) def tearDown(self): @@ -180,6 +181,39 @@ self.__assert_state_serializable( state ) self.assertEquals( state.inputs[ "param1|__multirun__" ], [ 1, 2 ] ) + def test_simple_collection_multirun_state_update( self ): + hdca = self.__setup_collection_multirun_job() + encoded_id = self.app.security.encode_id(hdca.id) + template, template_vars = self.__handle_with_incoming( **{ + "param1|__collection_multirun__": encoded_id, + } ) + state = self.__assert_rerenders_tool_without_errors( template, template_vars ) + self.__assert_state_serializable( state ) + self.assertEquals( state.inputs[ "param1|__collection_multirun__" ], encoded_id ) + + def test_repeat_multirun_state_updates( self ): + self._init_tool( REPEAT_TOOL_CONTENTS ) + + # Fresh state contains no repeat elements + self.__handle_with_incoming() + # Hitting add button adds repeat element + template, template_vars = self.__handle_with_incoming(**{ + "param1|__multirun__": [ 1, 2 ], + "repeat1_add": "dummy", + }) + state = self.__assert_rerenders_tool_without_errors( template, template_vars ) + self.assertEquals( state.inputs[ "param1|__multirun__" ], [ 1, 2 ] ) + assert len( state.inputs[ "repeat1" ] ) == 1 + + # Hitting add button again adds another repeat element + template, template_vars = self.__handle_with_incoming( state, **{ + "repeat1_0|param2|__multirun__": [ 1, 2 ], + "repeat1_add": "dummy", + } ) + state = self.__assert_rerenders_tool_without_errors( template, template_vars ) + self.assertEquals( state.inputs[ "param1|__multirun__" ], [ 1, 2 ] ) + self.assertEquals( state.inputs[ "repeat1" ][0][ "param2|__multirun__" ], [ 1, 2 ] ) + def test_simple_multirun_execution( self ): hda1, hda2 = self.__setup_multirun_job() template, template_vars = self.__handle_with_incoming( **{ @@ -276,6 +310,11 @@ hda1, hda2 = self.__add_dataset( 1 ), self.__add_dataset( 2 ) return hda1, hda2 + def __setup_collection_multirun_job( self ): + self._init_tool( tools_support.SIMPLE_CAT_TOOL_CONTENTS ) + hdca = self.__add_collection_dataset( 1 ) + return hdca + def __handle_with_incoming( self, previous_state=None, **kwds ): """ Execute tool.handle_input with incoming specified by kwds (optionally extending a previous state). @@ -310,6 +349,17 @@ self.history.datasets.append( hda ) return hda + def __add_collection_dataset( self, id, *hdas ): + hdca = galaxy.model.HistoryDatasetCollectionAssociation() + hdca.id = id + collection = galaxy.model.DatasetCollection() + hdca.collection = collection + collection.elements = [ galaxy.model.DatasetCollectionElement(element=self.__add_dataset( 1 )) ] + + self.trans.sa_session.model_objects[ galaxy.model.HistoryDatasetCollectionAssociation ][ id ] = hdca + self.history.dataset_collections.append( hdca ) + return hdca + def __assert_rerenders_tool_without_errors( self, template, template_vars ): assert template == "tool_form.mako" self.__assert_no_errors( template_vars ) @@ -392,3 +442,12 @@ def get_history( self ): return self.history + + +class MockCollectionService( object ): + + def __init__( self ): + self.collection_info = object() + + def match_collections( self, collections_to_match ): + return self.collection_info 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.
participants (1)
-
commits-noreply@bitbucket.org