mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Re-fix new functional test support for setting check boxes and boolean tool params to false, and fix a broken functional test in the security and libraries suite.
This commit is contained in:
@@ -1067,7 +1067,6 @@ class LibraryCommon( BaseController ):
|
||||
# use act_on_multiple_datasets( self, trans, cntrller, library_id, ldda_ids='', **kwd ) since it does what we need
|
||||
kwd['do_action'] = 'zip'
|
||||
return self.act_on_multiple_datasets( trans, cntrller, library_id, ldda_ids=id, **kwd )
|
||||
|
||||
else:
|
||||
mime = trans.app.datatypes_registry.get_mimetype_by_extension( ldda.extension.lower() )
|
||||
trans.response.set_content_type( mime )
|
||||
@@ -1198,15 +1197,16 @@ class LibraryCommon( BaseController ):
|
||||
msg = util.restore_text( params.get( 'msg', '' ) )
|
||||
messagetype = params.get( 'messagetype', 'done' )
|
||||
show_deleted = util.string_as_bool( params.get( 'show_deleted', False ) )
|
||||
action = params.get( 'do_action', None )
|
||||
if not ldda_ids:
|
||||
msg = "You must select at least one dataset"
|
||||
messagetype = 'error'
|
||||
elif not params.do_action:
|
||||
elif not action:
|
||||
msg = "You must select an action to perform on selected datasets"
|
||||
messagetype = 'error'
|
||||
else:
|
||||
ldda_ids = util.listify( ldda_ids )
|
||||
if params.do_action == 'add':
|
||||
if action == 'add':
|
||||
history = trans.get_history()
|
||||
total_imported_lddas = 0
|
||||
msg = ''
|
||||
@@ -1223,7 +1223,7 @@ class LibraryCommon( BaseController ):
|
||||
trans.sa_session.add( history )
|
||||
trans.sa_session.flush()
|
||||
msg += "%i dataset(s) have been imported into your history. " % total_imported_lddas
|
||||
elif params.do_action == 'manage_permissions':
|
||||
elif action == 'manage_permissions':
|
||||
# We need the folder containing the LibraryDatasetDatasetAssociation(s)
|
||||
ldda = trans.sa_session.query( trans.app.model.LibraryDatasetDatasetAssociation ).get( trans.security.decode_id( ldda_ids[0] ) )
|
||||
trans.response.send_redirect( web.url_for( controller='library_common',
|
||||
@@ -1235,7 +1235,7 @@ class LibraryCommon( BaseController ):
|
||||
show_deleted=show_deleted,
|
||||
msg=util.sanitize_text( msg ),
|
||||
messagetype=messagetype ) )
|
||||
elif params.do_action == 'delete':
|
||||
elif action == 'delete':
|
||||
for ldda_id in ldda_ids:
|
||||
ldda = trans.sa_session.query( trans.app.model.LibraryDatasetDatasetAssociation ).get( trans.security.decode_id( ldda_id ) )
|
||||
ldda.deleted = True
|
||||
@@ -1245,18 +1245,18 @@ class LibraryCommon( BaseController ):
|
||||
else:
|
||||
error = False
|
||||
try:
|
||||
if params.do_action == 'zip':
|
||||
if action == 'zip':
|
||||
# Can't use mkstemp - the file must not exist first
|
||||
tmpd = tempfile.mkdtemp()
|
||||
tmpf = os.path.join( tmpd, 'library_download.' + params.do_action )
|
||||
tmpf = os.path.join( tmpd, 'library_download.' + action )
|
||||
if ziptype == '64':
|
||||
archive = zipfile.ZipFile( tmpf, 'w', zipfile.ZIP_DEFLATED, True )
|
||||
else:
|
||||
archive = zipfile.ZipFile( tmpf, 'w', zipfile.ZIP_DEFLATED )
|
||||
archive.add = lambda x, y: archive.write( x, y.encode('CP437') )
|
||||
elif params.do_action == 'tgz':
|
||||
elif action == 'tgz':
|
||||
archive = util.streamball.StreamBall( 'w|gz' )
|
||||
elif params.do_action == 'tbz':
|
||||
elif action == 'tbz':
|
||||
archive = util.streamball.StreamBall( 'w|bz2' )
|
||||
except (OSError, zipfile.BadZipFile):
|
||||
error = True
|
||||
@@ -1321,7 +1321,7 @@ class LibraryCommon( BaseController ):
|
||||
msg = "Unable to create archive for download, please report this error"
|
||||
messagetype = 'error'
|
||||
if not error:
|
||||
if params.do_action == 'zip':
|
||||
if action == 'zip':
|
||||
archive.close()
|
||||
tmpfh = open( tmpf )
|
||||
# clean up now
|
||||
@@ -1335,11 +1335,11 @@ class LibraryCommon( BaseController ):
|
||||
messagetype = 'error'
|
||||
if not error:
|
||||
trans.response.set_content_type( "application/x-zip-compressed" )
|
||||
trans.response.headers[ "Content-Disposition" ] = "attachment; filename=GalaxyLibraryFiles.%s" % params.do_action
|
||||
trans.response.headers[ "Content-Disposition" ] = "attachment; filename=GalaxyLibraryFiles.%s" % action
|
||||
return tmpfh
|
||||
else:
|
||||
trans.response.set_content_type( "application/x-tar" )
|
||||
trans.response.headers[ "Content-Disposition" ] = "attachment; filename=GalaxyLibraryFiles.%s" % params.do_action
|
||||
trans.response.headers[ "Content-Disposition" ] = "attachment; filename=GalaxyLibraryFiles.%s" % action
|
||||
archive.wsgi_status = trans.response.wsgi_status()
|
||||
archive.wsgi_headeritems = trans.response.wsgi_headeritems()
|
||||
return archive.stream
|
||||
|
||||
@@ -472,12 +472,12 @@
|
||||
%if cntrller in [ 'library', 'requests' ]:
|
||||
${self.render_folder( 'library', library.root_folder, 0, created_ldda_ids, trans.security.encode_id( library.id ), hidden_folder_ids, tracked_datasets, show_deleted=show_deleted, parent=None, row_counter=row_counter, root_folder=True )}
|
||||
%if not library.deleted:
|
||||
${render_actions_on_multiple_items( 'library', default_action=default_action )}
|
||||
${render_actions_on_multiple_items()}
|
||||
%endif
|
||||
%elif cntrller in [ 'library_admin', 'requests_admin' ]:
|
||||
${self.render_folder( 'library_admin', library.root_folder, 0, created_ldda_ids, trans.security.encode_id( library.id ), [], tracked_datasets, show_deleted=show_deleted, parent=None, row_counter=row_counter, root_folder=True )}
|
||||
%if not library.deleted and not show_deleted:
|
||||
${render_actions_on_multiple_items( 'library_admin' )}
|
||||
${render_actions_on_multiple_items()}
|
||||
%endif
|
||||
%endif
|
||||
</table>
|
||||
|
||||
@@ -356,7 +356,7 @@
|
||||
%endif
|
||||
</%def>
|
||||
|
||||
<%def name="render_actions_on_multiple_items( cntrller, default_action=None )">
|
||||
<%def name="render_actions_on_multiple_items()">
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="4" style="padding-left: 42px;">
|
||||
|
||||
+20
-11
@@ -862,17 +862,14 @@ class TwillTestCase( unittest.TestCase ):
|
||||
# Copied from form_builder.CheckboxField
|
||||
if value == True:
|
||||
return True
|
||||
if isinstance( value, basestring ) and value.lower() in ( "yes", "true", "on" ):
|
||||
return True
|
||||
# This may look strange upon initial inspection, but see the comments in the get_html() method
|
||||
# above for clarification. Basically, if value is not True, then it will always be a list with
|
||||
# 2 input fields ( a checkbox and a hidden field ) if the checkbox is checked. If it is not
|
||||
# checked, then value will be only the hidden field.
|
||||
return isinstance( value, list ) and len( value ) == 2
|
||||
if isinstance( value, list ):
|
||||
value = value[0]
|
||||
return isinstance( value, basestring ) and value.lower() in ( "yes", "true", "on" )
|
||||
try:
|
||||
checkbox = control.get()
|
||||
checkbox.selected = is_checked( control_value )
|
||||
except Exception, e1:
|
||||
print "Attempting to set checkbox selected value threw exception: ", e1
|
||||
# if there's more than one checkbox, probably should use the behaviour for
|
||||
# ClientForm.ListControl ( see twill code ), but this works for now...
|
||||
for elem in control_value:
|
||||
@@ -885,6 +882,7 @@ class TwillTestCase( unittest.TestCase ):
|
||||
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 ~/parameters/basic.py
|
||||
if len( elem ) > 30:
|
||||
elem_name = '%s..%s' % ( elem[:17], elem[-11:] )
|
||||
@@ -1654,11 +1652,22 @@ class TwillTestCase( unittest.TestCase ):
|
||||
self.home()
|
||||
def download_archive_of_library_files( self, cntrller, library_id, ldda_ids, format ):
|
||||
self.home()
|
||||
self.visit_url( "%s/library_common/browse_library?cntrller=%s&id=%s" % ( self.url, cntrller, library_id ) )
|
||||
# Here it would be ideal to have twill set form values and submit the form, but
|
||||
# twill barfs on that due to the recently introduced page wrappers around the contents
|
||||
# of the browse_library.mako template which enable panel layout when visiting the
|
||||
# page from an external URL. By "barfs", I mean that twill somehow loses hod on the
|
||||
# cntrller param. We'll just simulate the form submission by building the URL manually.
|
||||
# Here's the old, better approach...
|
||||
#self.visit_url( "%s/library_common/browse_library?cntrller=%s&id=%s" % ( self.url, cntrller, library_id ) )
|
||||
#for ldda_id in ldda_ids:
|
||||
# tc.fv( "1", "ldda_ids", ldda_id )
|
||||
#tc.fv( "1", "do_action", format )
|
||||
#tc.submit( "action_on_datasets_button" )
|
||||
# Here's the new approach...
|
||||
url = "%s/library_common/act_on_multiple_datasets?cntrller=%s&library_id=%s&do_action=%s" % ( self.url, cntrller, library_id, format )
|
||||
for ldda_id in ldda_ids:
|
||||
tc.fv( "1", "ldda_ids", ldda_id )
|
||||
tc.fv( "1", "do_action", format )
|
||||
tc.submit( "action_on_datasets_button" )
|
||||
url += "&ldda_ids=%s" % ldda_id
|
||||
self.visit_url( url )
|
||||
tc.code( 200 )
|
||||
archive = self.write_temp_file( self.last_page(), suffix=format )
|
||||
self.home()
|
||||
|
||||
@@ -1596,18 +1596,15 @@ class TestSecurityAndLibraries( TwillTestCase ):
|
||||
self.home()
|
||||
self.logout()
|
||||
self.login( email=admin_user.email )
|
||||
"""
|
||||
TODO: debug this, somebody recently broke it
|
||||
def test_167_download_archive_of_library_files( self ):
|
||||
Testing downloading an archive of files from the library
|
||||
"""Testing downloading an archive of files from the library"""
|
||||
for format in ( 'tbz', 'tgz', 'zip' ):
|
||||
archive = self.download_archive_of_library_files( 'library',
|
||||
self.security.encode_id( library_one.id ),
|
||||
( self.security.encode_id( ldda_one.id ), self.security.encode_id( ldda_two.id ) ),
|
||||
format )
|
||||
archive = self.download_archive_of_library_files( cntrller='library',
|
||||
library_id=self.security.encode_id( library_one.id ),
|
||||
ldda_ids=[ self.security.encode_id( ldda_one.id ), self.security.encode_id( ldda_two.id ) ],
|
||||
format=format )
|
||||
self.check_archive_contents( archive, ( ldda_one, ldda_two ) )
|
||||
os.remove( archive )
|
||||
"""
|
||||
def test_170_mark_group_deleted( self ):
|
||||
"""Testing marking a group as deleted"""
|
||||
# Logged in as admin_user
|
||||
|
||||
Reference in New Issue
Block a user