mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Add missing hda name length check to submit_form.
This commit is contained in:
+35
-18
@@ -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 = '<HiddenControl('
|
||||
for i, control in enumerate( f.controls ):
|
||||
print "control %d: %s" % ( i, str( control ) )
|
||||
formcontrols.append( "control %d: %s" % ( i, str( control ) ) )
|
||||
for i, control in enumerate( f.controls ):
|
||||
if not hc_prefix in str( control ):
|
||||
try:
|
||||
#check if a repeat element needs to be added
|
||||
if control.name not in kwd and control.name.endswith( '_add' ):
|
||||
#control name doesn't exist, could be repeat
|
||||
repeat_startswith = control.name[0:-4]
|
||||
if repeat_startswith and not [ c_name for c_name in controls.keys() if c_name.startswith( repeat_startswith ) ] and [ c_name for c_name in kwd.keys() if c_name.startswith( repeat_startswith ) ]:
|
||||
tc.submit( control.name )
|
||||
return self.submit_form( form_no=form_no, button=button, **kwd )
|
||||
if control.name is not None:
|
||||
if control.name not in kwd and control.name.endswith( '_add' ):
|
||||
#control name doesn't exist, could be repeat
|
||||
repeat_startswith = control.name[0:-4]
|
||||
if repeat_startswith and not [ c_name for c_name in controls.keys() if c_name.startswith( repeat_startswith ) ] and [ c_name for c_name in kwd.keys() if c_name.startswith( repeat_startswith ) ]:
|
||||
tc.submit( control.name )
|
||||
return self.submit_form( form_no=form_no, button=button, **kwd )
|
||||
# Check for refresh_on_change attribute, submit a change if required
|
||||
if hasattr( control, 'attrs' ) and 'refresh_on_change' in control.attrs.keys():
|
||||
changed = False
|
||||
@@ -1188,9 +1191,10 @@ class TwillTestCase( unittest.TestCase ):
|
||||
# This loop gets the filename/label for the selected values.
|
||||
item_labels = [ item.attrs[ 'label' ] for item in control.get_items() if item.selected ]
|
||||
for value in kwd[ control.name ]:
|
||||
# Galaxy truncates long file names in the dataset_collector in galaxy/tools/parameters/basic.py
|
||||
# Galaxy truncates long file names in the dataset_collector in galaxy/tools/parameters/basic.py.
|
||||
# This (and other places where this is done) should be refactored to use the HDA id.
|
||||
if len( value ) > 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
|
||||
|
||||
Reference in New Issue
Block a user