Upload a tool test's inputs in parallel.

Probably small optimization in most cases since tests generally have few inputs.
This commit is contained in:
John Chilton
2013-11-21 19:17:12 -06:00
parent f08a3fe3bb
commit aedd40c2eb
2 changed files with 19 additions and 5 deletions
+8 -1
View File
@@ -197,7 +197,7 @@ class TwillTestCase( unittest.TestCase ):
filename = os.path.join( *path )
file(filename, 'wt').write(buffer.getvalue())
def upload_file( self, filename, ftype='auto', dbkey='unspecified (?)', space_to_tab=False, metadata=None, composite_data=None, shed_tool_id=None ):
def upload_file( self, filename, ftype='auto', dbkey='unspecified (?)', space_to_tab=False, metadata=None, composite_data=None, name=None, shed_tool_id=None, wait=True ):
"""
Uploads a file. If shed_tool_id has a value, we're testing tools migrated from the distribution to the tool shed,
so the tool-data directory of test data files is contained in the installed tool shed repository.
@@ -218,12 +218,19 @@ class TwillTestCase( unittest.TestCase ):
filename = self.get_filename( filename, shed_tool_id=shed_tool_id )
tc.formfile( "tool_form", "file_data", filename )
tc.fv( "tool_form", "space_to_tab", space_to_tab )
if name:
# NAME is a hidden form element, so the following prop must
# set to use it.
tc.config("readonly_controls_writeable", 1)
tc.fv( "tool_form", "NAME", name )
tc.submit( "runtool_btn" )
self.home()
except AssertionError, err:
errmsg = "Uploading file resulted in the following exception. Make sure the file (%s) exists. " % filename
errmsg += str( err )
raise AssertionError( errmsg )
if not wait:
return
# Make sure every history item has a valid hid
hids = self.get_hids_in_history()
for hid in hids:
+11 -4
View File
@@ -25,8 +25,11 @@ class ToolTestCase( TwillTestCase ):
test_history = galaxy_interactor.new_history()
# Upload any needed files
upload_waits = []
for test_data in testdef.test_data():
galaxy_interactor.stage_data( test_data, shed_tool_id )
upload_waits.append( galaxy_interactor.stage_data_async( test_data, shed_tool_id ) )
for upload_wait in upload_waits:
upload_wait()
data_list = galaxy_interactor.run_tool( testdef )
self.assertTrue( data_list )
@@ -70,20 +73,24 @@ class GalaxyInteractorTwill( object ):
def __init__( self, twill_test_case ):
self.twill_test_case = twill_test_case
def stage_data( self, test_data, shed_tool_id ):
def stage_data_async( self, test_data, shed_tool_id, async=True ):
name = test_data.get( 'name', None )
if name:
async = False
self.twill_test_case.upload_file( test_data['fname'],
ftype=test_data['ftype'],
dbkey=test_data['dbkey'],
metadata=test_data['metadata'],
composite_data=test_data['composite_data'],
shed_tool_id=shed_tool_id )
name = test_data.get('name', None)
shed_tool_id=shed_tool_id,
wait=(not async) )
if name:
hda_id = self.twill_test_case.get_history_as_data_list()[-1].get( 'id' )
try:
self.twill_test_case.edit_hda_attribute_info( hda_id=str(hda_id), new_name=name )
except:
print "### call to edit_hda failed for hda_id %s, new_name=%s" % (hda_id, name)
return lambda: self.twill_test_case.wait()
def run_tool( self, testdef ):
# We need to handle the case where we've uploaded a valid compressed file since the upload