From 13793b39cc81d823a383bb4f2e896932fa6b63ca Mon Sep 17 00:00:00 2001 From: Dave Bouvier Date: Thu, 9 May 2013 13:49:13 -0400 Subject: [PATCH] Add missing hda name length check to submit_form. --- test/base/twilltestcase.py | 53 +++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/test/base/twilltestcase.py b/test/base/twilltestcase.py index a42b4a823d5..841aec77e18 100644 --- a/test/base/twilltestcase.py +++ b/test/base/twilltestcase.py @@ -1169,18 +1169,21 @@ class TwillTestCase( unittest.TestCase ): # To help with debugging a tool, print out the form controls when the test fails print "form '%s' contains the following controls ( note the values )" % f.name controls = {} + formcontrols = [] hc_prefix = ' 30 and control.is_of_kind( 'singlelist' ): - field_value = '%s..%s' % ( elem[:17], elem[-11:] ) + field_value = '%s..%s' % ( value[:17], value[-11:] ) else: field_value = value if field_value not in control.value and True not in [ field_value in item_label for item_label in item_labels ]: @@ -1214,7 +1218,9 @@ class TwillTestCase( unittest.TestCase ): tc.submit( '___refresh_grouping___' ) return self.submit_form( form_no=form_no, button=button, **kwd ) except Exception, e: - log.debug( "In submit_form, continuing, but caught exception: %s" % str( e ) ) + log.exception( "In submit_form, continuing, but caught exception." ) + for formcontrol in formcontrols: + log.debug( formcontrol ) continue controls[ control.name ] = control # No refresh_on_change attribute found in current form, so process as usual @@ -1254,15 +1260,25 @@ class TwillTestCase( unittest.TestCase ): for elem in control_value: try: tc.fv( f.name, control.name, str( elem ) ) - except Exception, e2: - print "Attempting to set control '", control.name, "' to value '", elem, "' threw exception: ", e2 - # Galaxy truncates long file names in the dataset_collector in galaxy/tools/parameters/basic.py - if len( elem ) > 30: - elem_name = '%s..%s' % ( elem[:17], elem[-11:] ) - else: - elem_name = elem - tc.fv( f.name, control.name, str( elem_name ) ) + except Exception: + try: + # Galaxy truncates long file names in the dataset_collector in galaxy/tools/parameters/basic.py + if len( elem ) > 30: + elem_name = '%s..%s' % ( elem[:17], elem[-11:] ) + tc.fv( f.name, control.name, str( elem_name ) ) + pass + else: + raise + except Exception: + raise + except Exception: + for formcontrol in formcontrols: + log.debug( formcontrol ) + log.exception( "Attempting to set control '%s' to value '%s' (also tried '%s') threw exception.", control.name, elem, elem_name ) + pass except Exception, exc: + for formcontrol in formcontrols: + log.debug( formcontrol ) errmsg = "Attempting to set field '%s' to value '%s' in form '%s' threw exception: %s\n" % ( control_name, str( control_value ), f.name, str( exc ) ) errmsg += "control: %s\n" % str( control ) errmsg += "If the above control is a DataToolparameter whose data type class does not include a sniff() method,\n" @@ -1272,6 +1288,7 @@ class TwillTestCase( unittest.TestCase ): # Add conditions for other control types here when necessary. pass tc.submit( button ) + def refresh_form( self, control_name, value, form_no=0, **kwd ): """Handles Galaxy's refresh_on_change for forms without ultimately submitting the form""" # control_name is the name of the form field that requires refresh_on_change, and value is