[hg] galaxy 2416: Bug fixes for the new security and libraries f...
details: http://www.bx.psu.edu/hg/galaxy/rev/48e4b965545b changeset: 2416:48e4b965545b user: Greg Von Kuster <greg@bx.psu.edu> date: Tue May 26 14:32:18 2009 -0400 description: Bug fixes for the new security and libraries functional tests. 3 file(s) affected in this change: lib/galaxy/web/controllers/admin.py test/base/twilltestcase.py test/functional/test_security_and_libraries.py diffs (253 lines): diff -r 386e245f8076 -r 48e4b965545b lib/galaxy/web/controllers/admin.py --- a/lib/galaxy/web/controllers/admin.py Thu May 21 15:48:39 2009 -0400 +++ b/lib/galaxy/web/controllers/admin.py Tue May 26 14:32:18 2009 -0400 @@ -875,14 +875,21 @@ library_folder.deleted = True library_folder.purged = True library_folder.flush() - purge_folder( library.root_folder ) - library.purged = True - library.flush() - msg = "Library '%s' and all of its contents have been purged, datasets will be removed from disk via the cleanup_datasets script" % library.name - return trans.response.send_redirect( web.url_for( controller='admin', - action='deleted_libraries', - msg=util.sanitize_text( msg ), - messagetype='done' ) ) + if not library.deleted: + msg = "Library '%s' has not been marked deleted, so it cannot be purged" % ( library.name ) + return trans.response.send_redirect( web.url_for( controller='admin', + action='browse_libraries', + msg=util.sanitize_text( msg ), + messagetype='error' ) ) + else: + purge_folder( library.root_folder ) + library.purged = True + library.flush() + msg = "Library '%s' and all of its contents have been purged, datasets will be removed from disk via the cleanup_datasets script" % library.name + return trans.response.send_redirect( web.url_for( controller='admin', + action='deleted_libraries', + msg=util.sanitize_text( msg ), + messagetype='done' ) ) @web.expose @web.require_admin def folder( self, trans, id, library_id, **kwd ): @@ -1545,7 +1552,7 @@ messagetype=messagetype ) @web.expose @web.require_admin - def info_template( self, trans, library_id, id=None, num_fields=0, folder_id=None, ldda_id=None, library_dataset_id=None, **kwd ): + def info_template( self, trans, library_id, id=None, num_fields=0, folder_id=None, ldda_id=None, library_dataset_id=None, **kwd ): params = util.Params( kwd ) msg = util.restore_text( params.get( 'msg', '' ) ) messagetype = params.get( 'messagetype', 'done' ) diff -r 386e245f8076 -r 48e4b965545b test/base/twilltestcase.py --- a/test/base/twilltestcase.py Thu May 21 15:48:39 2009 -0400 +++ b/test/base/twilltestcase.py Tue May 26 14:32:18 2009 -0400 @@ -855,9 +855,14 @@ tc.fv( '1', 'new_element_name_0', ele_name_0 ) tc.fv( '1', 'new_element_name_1', ele_name_1 ) tc.submit( 'new_info_template_button' ) + self.check_page_for_string( 'The new information template has been created.' ) self.home() - def add_library_info_template_element( self, library_id, template_id, template_name, ele_name_1, ele_desc_1, - ele_name_2, ele_desc_2, new_ele_name='Fubar', new_ele_desc='This is the Fubar compnent' ): + def add_library_info_template_element( self, library_id, template_id, template_name, + ele_field_name_1, ele_name_1, + ele_field_desc_1, ele_desc_1, + ele_field_name_2, ele_name_2, + ele_field_desc_2, ele_desc_2, + new_ele_name='Fubar', new_ele_desc='This is the Fubar compnent' ): """Add a new element to an existing library info template""" self.home() url = "%s/admin/info_template?library_id=%s&id=%s&edit_template=True&num_fields=1&edit_info_template_button=Save" % \ @@ -868,10 +873,10 @@ tc.fv( '1', 'id', template_id ) tc.fv( '1', 'set_num_fields', '0' ) tc.fv( '1', 'name', template_name ) - tc.fv( '1', 'element_name_1', ele_name_1 ) - tc.fv( '1', 'element_description_1', ele_desc_1 ) - tc.fv( '1', 'element_name_2', ele_name_2 ) - tc.fv( '1', 'element_description_2', ele_desc_2 ) + tc.fv( '1', ele_field_name_1, ele_name_1 ) + tc.fv( '1', ele_field_desc_1, ele_desc_1 ) + tc.fv( '1', ele_field_name_2, ele_name_2 ) + tc.fv( '1', ele_field_desc_2, ele_desc_2 ) tc.fv( '1', 'new_element_name_0', new_ele_name ) tc.fv( '1', 'new_element_description_0', new_ele_desc ) tc.submit( 'edit_info_template_button' ) @@ -888,7 +893,8 @@ tc.fv( '2', ele_2_field_name, ele_2_contents ) tc.submit( 'create_new_info_button' ) self.home() - def edit_library_info_template( self, library_id, id, name, name_1, desc_1, name_2, desc_2 ): + def edit_library_info_template( self, library_id, id, name, ele_name_1, name_1, + ele_desc_1, desc_1, ele_name_2, name_2, ele_desc_2, desc_2 ): """Edit an existing library info template""" self.home() url = "%s/admin/info_template?library_id=%s&id=%s&edit_template=True" % ( self.url, library_id, id ) @@ -897,10 +903,10 @@ tc.fv( '1', 'id', id ) tc.fv( '1', 'set_num_fields', '0' ) tc.fv( '1', 'name', name ) - tc.fv( '1', 'element_name_1', name_1 ) - tc.fv( '1', 'element_description_1', desc_1 ) - tc.fv( '1', 'element_name_2', name_2 ) - tc.fv( '1', 'element_description_2', desc_2 ) + tc.fv( '1', ele_name_1, name_1 ) + tc.fv( '1', ele_desc_1, desc_1 ) + tc.fv( '1', ele_name_2, name_2 ) + tc.fv( '1', ele_desc_2, desc_2 ) tc.submit( 'edit_info_template_button' ) check_str = "Information template '%s' has been updated" % name self.check_page_for_string( check_str ) @@ -988,7 +994,6 @@ for pi in permissions_in: key = '%s_in' % pi url ="%s&%s=%s" % ( url, key, str( role_id ) ) - print url self.home() self.visit_url( "%s/%s" % ( self.url, url ) ) check_str = "Permissions updated for dataset '%s'" % ldda_name @@ -1046,12 +1051,7 @@ dbkey='hg18', message='', check_template_str1='', check_template_str2='', check_template_str3='' ): """Upload new version(s) of a dataset""" self.home() - filename = self.get_filename( filename ) - - url = "%s/admin/library_dataset_dataset_association?upload_option=upload_file&library_id=%s&folder_id=%s&replace_id=%s&message=%s" % \ - ( self.url, library_id, folder_id, library_dataset_id, message ) - print "####url: ", url - + filename = self.get_filename( filename ) self.visit_url( "%s/admin/library_dataset_dataset_association?upload_option=upload_file&library_id=%s&folder_id=%s&replace_id=%s&message=%s" % \ ( self.url, library_id, folder_id, library_dataset_id, message ) ) self.check_page_for_string( 'Upload files' ) diff -r 386e245f8076 -r 48e4b965545b test/functional/test_security_and_libraries.py --- a/test/functional/test_security_and_libraries.py Thu May 21 15:48:39 2009 -0400 +++ b/test/functional/test_security_and_libraries.py Tue May 26 14:32:18 2009 -0400 @@ -515,17 +515,30 @@ info_permissions.sort() assert actions == info_permissions, "Permissions for library_item_info id %s not correctly inherited from library %s" \ % ( library_item_info.id, library_one.name ) - # Need the current library_item_info_element.id - last_library_item_info_element_id = galaxy.model.LibraryItemInfoElement.query() \ - .order_by( desc( galaxy.model.LibraryItemInfoElement.table.c.id ) ).first() - if last_library_item_info_element_id is None: - last_library_item_info_element_id = 0 + element_ids = [] + if library_one.library_info_associations: + # We have a set of LibraryItemInfoElements + last_library_item_info_element = galaxy.model.LibraryItemInfoElement.query() \ + .order_by( desc( galaxy.model.LibraryItemInfoElement.table.c.id ) ).first() + if not last_library_item_info_element: + element_ids.append( 0 ) + element_ids.append( 1 ) + else: + element_ids.append( last_library_item_info_element.id + 1 ) + element_ids.append( last_library_item_info_element.id + 2 ) + else: + # We only have a set of LibraryItemInfoTemplateElements + for ele in library_one_template.elements: + element_ids.append( ele.id ) + element_ids.sort() # Add information to the library using the template - ele_1_field_name = "info_element_%s_%s" % ( str( library_one_template.id ), str( last_library_item_info_element_id + 1 ) ) + ele_1_field_name = "info_element_%s_%s" % ( str( library_one_template.id ), str( element_ids[0] ) ) ele_1_contents = 'hello' - ele_2_field_name = "info_element_%s_%s" % ( str( library_one_template.id ), str( last_library_item_info_element_id + 2 ) ) + ele_2_field_name = "info_element_%s_%s" % ( str( library_one_template.id ), str( element_ids[1] ) ) ele_2_contents = 'world' - self.edit_library_info( str( library_one.id ), library_one.name, ele_1_field_name, ele_1_contents, ele_2_field_name, ele_2_contents ) + self.edit_library_info( str( library_one.id ), library_one.name, + ele_1_field_name, ele_1_contents, + ele_2_field_name, ele_2_contents ) self.home() self.visit_url( '%s/admin/library?id=%s&information=True' % ( self.url, str( library_one.id ) ) ) self.check_page_for_string( ele_1_contents ) @@ -536,11 +549,17 @@ self.check_page_for_string( ele_2_contents ) # Edit the template new_name = 'Library Template 1 renamed' + new_ele_name_1_field = "element_name_%s" % element_ids[0] new_ele_name_1 = 'wind' + new_ele_desc_1_field = "element_description_%s" % element_ids[0] ele_desc_1 = 'This is the wind component' + new_ele_name_2_field = "element_name_%s" % element_ids[1] new_ele_name_2 = 'bag' + new_ele_desc_2_field = "element_description_%s" % element_ids[1] ele_desc_2 = 'This is the bag component' - self.edit_library_info_template( str( library_one.id ), library_one_template.id, new_name, new_ele_name_1, ele_desc_1, new_ele_name_2, ele_desc_2 ) + self.edit_library_info_template( str( library_one.id ), library_one_template.id, new_name, + new_ele_name_1_field, new_ele_name_1, new_ele_desc_1_field, ele_desc_1, + new_ele_name_2_field, new_ele_name_2, new_ele_desc_2_field, ele_desc_2 ) self.home() self.visit_url( '%s/admin/library?id=%s&information=True' % ( self.url, str( library_one.id ) ) ) self.check_page_for_string( new_ele_name_1 ) @@ -692,20 +711,34 @@ self.home() def test_105_add_template_element( self ): """Testing adding a new element to an existing library template""" + library_one_template.refresh() + element_ids = [] + for ele in library_one_template.elements: + element_ids.append( ele.id ) + element_ids.sort() + name = 'Library Template 1 renamed' + ele_field_name_1 = "element_name_%s" % element_ids[0] ele_name_1 = 'wind' + ele_field_desc_1 = "element_description_%s" % element_ids[0] ele_desc_1 = 'This is the wind component' + ele_field_name_2 = "element_name_%s" % element_ids[1] ele_name_2 = 'bag' + ele_field_desc_2 = "element_description_%s" % element_ids[1] ele_desc_2 = 'This is the bag component' new_ele_name = 'Fubar' new_ele_desc = 'This is the Fubar component' - library_one_template.refresh() + self.add_library_info_template_element( str( library_one.id ), str( library_one_template.id ), library_one_template.name, + ele_field_name_1, ele_name_1, + ele_field_desc_1, ele_desc_1, + ele_field_name_2, ele_name_2, + ele_field_desc_2, ele_desc_2, new_ele_name=new_ele_name, new_ele_desc=new_ele_desc ) @@ -1601,11 +1634,13 @@ self.undelete_role( str( role_two.id ), role_two.name ) def test_270_purge_library( self ): """Testing purging a library""" + self.home() + self.delete_library_item( str( library_one.id ), str( library_one.id ), library_one.name, library_item_type='library' ) self.purge_library( str( library_one.id ), library_one.name ) # Make sure the library was purged library_one.refresh() - if not library_one.purged: - raise AssertionError( 'The library id %s named "%s" has not been marked as purged.' % ( str( library_one.id ), library_one.name ) ) + if not ( library_one.deleted and library_one.purged ): + raise AssertionError( 'The library id %s named "%s" has not been marked as deleted and purged.' % ( str( library_one.id ), library_one.name ) ) def check_folder( library_folder ): for folder in library_folder.folders: folder.refresh() @@ -1635,15 +1670,6 @@ check_folder( library_one.root_folder ) def test_275_reset_data_for_later_test_runs( self ): """Reseting data to enable later test runs to pass""" - ################## - # Eliminate all templates and info associations - ################## - for lia in library_one.library_info_associations: - lia.delete() - lia.flush() - for lita in library_one.library_info_template_associations: - lita.delete() - lita.flush() ################## # Eliminate all non-private roles ##################
participants (1)
-
Greg Von Kuster