2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/8244a5142f90/ Changeset: 8244a5142f90 User: jmchilton Date: 2014-01-14 21:43:39 Summary: Add tool execution unit test for rerun_remapping. Affected #: 2 files diff -r bb0b6a7e73d7154377b414939b9fa44da1fb6306 -r 8244a5142f90a0d7f1c8b2f2f8886e7d30e0240d test/unit/tools/test_execution.py --- a/test/unit/tools/test_execution.py +++ b/test/unit/tools/test_execution.py @@ -89,6 +89,18 @@ runtool_btn="dummy", ) assert template == "tool_executed.mako" + # Didn't specify a rerun_remap_id so this should be None + assert self.tool_action.execution_call_args[ 0 ][ "rerun_remap_job_id" ] is None + + def test_remap_job( self ): + self.__init_tool( SIMPLE_TOOL_CONTENTS ) + template, template_vars = self.__handle_with_incoming( + param1="moo", + rerun_remap_job_id=self.app.security.encode_id(123), + runtool_btn="dummy", + ) + assert template == "tool_executed.mako" + assert self.tool_action.execution_call_args[ 0 ][ "rerun_remap_job_id" ] == 123 def test_repeat_state_updates( self ): self.__init_tool( REPEAT_TOOL_CONTENTS ) diff -r bb0b6a7e73d7154377b414939b9fa44da1fb6306 -r 8244a5142f90a0d7f1c8b2f2f8886e7d30e0240d test/unit/tools_support.py --- a/test/unit/tools_support.py +++ b/test/unit/tools_support.py @@ -9,6 +9,7 @@ import shutil from galaxy.util.bunch import Bunch +from galaxy.web.security import SecurityHelper import galaxy.model from galaxy.model import mapping @@ -54,6 +55,7 @@ self.model[ module_member_name ] = module_member self.toolbox = None self.object_store = None + self.security = SecurityHelper(id_secret="testing") class MockContext(object): https://bitbucket.org/galaxy/galaxy-central/commits/c5fbdfd31b38/ Changeset: c5fbdfd31b38 User: jmchilton Date: 2014-01-14 21:43:39 Summary: Refactor tool so incoming dict isn't passed to __handle_tool_execute. Slightly confusing that state params and raw incoming passed to that method, so pull out rerun_remap_job_id sooner and just pass that along (it was the only incoming was used for). Use the oppertunity to isolate potential errors with decoding rerun_remap_job_id and include more informative error message. Add unit test to test invalid rerun_remap_job_ids. Affected #: 2 files diff -r 8244a5142f90a0d7f1c8b2f2f8886e7d30e0240d -r c5fbdfd31b387056d1dfdad5e9e356c0020c5cec lib/galaxy/tools/__init__.py --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -1847,6 +1847,14 @@ that is why this is not just called for_api. """ all_pages = ( process_state == "populate" ) # If process_state = update, handle all pages at once. + rerun_remap_job_id = None + if 'rerun_remap_job_id' in incoming: + try: + rerun_remap_job_id = trans.app.security.decode_id( incoming[ 'rerun_remap_job_id' ] ) + except Exception: + message = 'Failure executing tool (attempting to rerun invalid job).' + return 'message.mako', dict( status='error', message=message, refresh_frames=[] ) + state, state_new = self.__fetch_state( trans, incoming, history, all_pages=all_pages ) if state_new: # This feels a bit like a hack. It allows forcing full processing @@ -1874,7 +1882,7 @@ return "tool_form.mako", dict( errors=errors, tool_state=state, incoming=incoming, error_message=error_message ) # If we've completed the last page we can execute the tool elif all_pages or state.page == self.last_page: - return self.__handle_tool_execute( trans, incoming, params, history ) + return self.__handle_tool_execute( trans, rerun_remap_job_id, params, history ) # Otherwise move on to the next page else: return self.__handle_page_advance( trans, state, errors ) @@ -1882,11 +1890,8 @@ def __should_refresh_state( self, incoming ): return not( 'runtool_btn' in incoming or 'URL' in incoming or 'ajax_upload' in incoming ) - def __handle_tool_execute( self, trans, incoming, params, history ): + def __handle_tool_execute( self, trans, rerun_remap_job_id, params, history ): try: - rerun_remap_job_id = None - if 'rerun_remap_job_id' in incoming: - rerun_remap_job_id = trans.app.security.decode_id(incoming['rerun_remap_job_id']) _, out_data = self.execute( trans, incoming=params, history=history, rerun_remap_job_id=rerun_remap_job_id ) except httpexceptions.HTTPFound, e: #if it's a paste redirect exception, pass it up the stack diff -r 8244a5142f90a0d7f1c8b2f2f8886e7d30e0240d -r c5fbdfd31b387056d1dfdad5e9e356c0020c5cec test/unit/tools/test_execution.py --- a/test/unit/tools/test_execution.py +++ b/test/unit/tools/test_execution.py @@ -102,6 +102,17 @@ assert template == "tool_executed.mako" assert self.tool_action.execution_call_args[ 0 ][ "rerun_remap_job_id" ] == 123 + def test_invalid_remap_job( self ): + self.__init_tool( SIMPLE_TOOL_CONTENTS ) + template, template_vars = self.__handle_with_incoming( + param1="moo", + rerun_remap_job_id='123', # Not encoded + runtool_btn="dummy", + ) + assert template == "message.mako" + assert template_vars[ "status" ] == "error" + assert "invalid job" in template_vars[ "message" ] + def test_repeat_state_updates( self ): self.__init_tool( REPEAT_TOOL_CONTENTS ) 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.