details: http://www.bx.psu.edu/hg/galaxy/rev/5024f44ab7f7 changeset: 2816:5024f44ab7f7 user: Greg Von Kuster <greg@bx.psu.edu> date: Fri Oct 02 08:55:01 2009 -0400 description: A couple bug fixes, additional functional tests for the Data Libraries features. 4 file(s) affected in this change: lib/galaxy/web/controllers/library_common.py templates/base_panels.mako test/base/twilltestcase.py test/functional/test_security_and_libraries.py diffs (269 lines): diff -r 80d4b33c85ca -r 5024f44ab7f7 lib/galaxy/web/controllers/library_common.py --- a/lib/galaxy/web/controllers/library_common.py Thu Oct 01 15:07:22 2009 -0400 +++ b/lib/galaxy/web/controllers/library_common.py Fri Oct 02 08:55:01 2009 -0400 @@ -266,7 +266,7 @@ if cntrller == 'library_admin': tmplt = '/admin/library/select_info_template.mako' else: - tmplt = '/ibrary/select_info_template.mako' + tmplt = '/library/select_info_template.mako' return trans.fill_template( tmplt, library_item_name=library_item.name, library_item_desc=library_item_desc, diff -r 80d4b33c85ca -r 5024f44ab7f7 templates/base_panels.mako --- a/templates/base_panels.mako Thu Oct 01 15:07:22 2009 -0400 +++ b/templates/base_panels.mako Fri Oct 02 08:55:01 2009 -0400 @@ -113,7 +113,7 @@ $(this).ajaxSubmit( { iframe: true } ); if ( $(this).find("input[name='folder_id']").val() != undefined ) { var library_id = $(this).find("input[name='library_id']").val(); - if ( location.pathname.indexOf( 'library_admin' ) ) { + if ( location.pathname.indexOf( 'library_admin' ) != -1 ) { $("iframe#galaxy_main").attr("src","${h.url_for( controller='library_admin', action='browse_library' )}?obj_id=" + library_id + "&created_ldda_ids=" + async_datasets); } else { $("iframe#galaxy_main").attr("src","${h.url_for( controller='library', action='browse_library' )}?obj_id=" + library_id + "&created_ldda_ids=" + async_datasets); diff -r 80d4b33c85ca -r 5024f44ab7f7 test/base/twilltestcase.py --- a/test/base/twilltestcase.py Thu Oct 01 15:07:22 2009 -0400 +++ b/test/base/twilltestcase.py Fri Oct 02 08:55:01 2009 -0400 @@ -1209,12 +1209,12 @@ check_str = "Information template '%s' has been updated" % name self.check_page_for_string( check_str ) self.home() - def add_folder_info_template( self, cntrller, library_id, library_name, folder_id, folder_name, num_fields='2', + def add_folder_info_template( self, controller, cntrller, library_id, library_name, folder_id, folder_name, num_fields='2', name='Folder Template 1', ele_name_0='Fu', ele_help_0='', ele_name_1='Bar', ele_help_1='' ): """Add a new info template to a folder""" self.home() - url = "%s/library_admin/info_template?cntrller=%s&library_id=%s&response_action='folder'&create_info_template_button=Go" % \ - ( self.url, cntrller, library_id, folder_id ) + url = "%s/%s/info_template?cntrller=%s&library_id=%s&response_action='folder'&create_info_template_button=Go" % \ + ( self.url, controller, cntrller, library_id, folder_id ) self.home() self.visit_url( url ) check_str = "Create a new information template for folder '%s'" % folder_name @@ -1229,14 +1229,27 @@ tc.fv( '1', 'new_element_description_1', ele_help_1.replace( '+', ' ' ) ) tc.submit( 'new_info_template_button' ) self.home() - def add_folder( self, library_id, folder_id, name='Folder One', description='This is Folder One' ): + def add_folder( self, controller, library_id, folder_id, name='Folder One', description='This is Folder One' ): """Create a new folder""" self.home() - self.visit_url( "%s/library_admin/folder?library_id=%s&obj_id=%s&new=True" % ( self.url, library_id, folder_id ) ) + self.visit_url( "%s/%s/folder?library_id=%s&obj_id=%s&new=True" % \ + ( self.url, controller, library_id, folder_id ) ) self.check_page_for_string( 'Create a new folder' ) tc.fv( "1", "name", name ) # form field 1 is the field named name... tc.fv( "1", "description", description ) # form field 2 is the field named description... tc.submit( "new_folder_button" ) + self.home() + def edit_folder_info( self, controller, folder_id, library_id, name, new_name, description ): + """Add information to a library using an existing template with 2 elements""" + self.home() + self.visit_url( "%s/%s/folder?obj_id=%s&library_id=%s&information=True" % \ + ( self.url, controller, folder_id, library_id) ) + self.check_page_for_string( "Edit folder name and description" ) + tc.fv( '1', "name", new_name ) + tc.fv( '1', "description", description ) + tc.submit( 'rename_folder_button' ) + check_str = "Folder '%s' has been renamed to '%s'" % ( name, new_name ) + self.check_page_for_string( check_str ) self.home() def rename_folder( self, library_id, folder_id, old_name, name='Folder One Renamed', description='This is Folder One Re-described' ): """Rename a Folder""" @@ -1251,13 +1264,14 @@ check_str = "Folder '%s' has been renamed to '%s'" % ( old_name, name ) self.check_page_for_string( check_str ) self.home() - def add_library_dataset( self, filename, library_id, folder_id, folder_name, file_type='auto', - dbkey='hg18', roles=[], message='', root=False, template_field_name1='', template_field_contents1='' ): + def add_library_dataset( self, controller, filename, library_id, folder_id, folder_name, + file_type='auto', dbkey='hg18', roles=[], message='', root=False, + template_field_name1='', template_field_contents1='' ): """Add a dataset to a folder""" filename = self.get_filename( filename ) self.home() - self.visit_url( "%s/library_admin/upload_library_dataset?upload_option=upload_file&library_id=%s&folder_id=%s&message=%s" % \ - ( self.url, library_id, folder_id, message ) ) + self.visit_url( "%s/%s/upload_library_dataset?upload_option=upload_file&library_id=%s&folder_id=%s&message=%s" % \ + ( self.url, controller, library_id, folder_id, message ) ) self.check_page_for_string( 'Upload files' ) tc.fv( "1", "folder_id", folder_id ) tc.formfile( "1", "files_0|file_data", filename ) @@ -1274,7 +1288,7 @@ check_str = "Added 1 datasets to the library '%s' ( each is selected )." % folder_name else: check_str = "Added 1 datasets to the folder '%s' ( each is selected )." % folder_name - self.check_page_for_string( check_str ) + data = self.last_page() self.library_wait( library_id ) self.home() def set_library_dataset_permissions( self, library_id, folder_id, ldda_id, ldda_name, role_ids_str, permissions_in, permissions_out ): diff -r 80d4b33c85ca -r 5024f44ab7f7 test/functional/test_security_and_libraries.py --- a/test/functional/test_security_and_libraries.py Thu Oct 01 15:07:22 2009 -0400 +++ b/test/functional/test_security_and_libraries.py Fri Oct 02 08:55:01 2009 -0400 @@ -540,7 +540,8 @@ message = 'Testing adding a public dataset to the root folder' # The form_one template should be inherited to the library dataset upload form. template_contents = "%s contents for root folder 1.bed" % form_one_field_label - self.add_library_dataset( '1.bed', + self.add_library_dataset( 'library_admin', + '1.bed', str( library_one.id ), str( library_one.root_folder.id ), library_one.root_folder.name, @@ -594,7 +595,11 @@ root_folder = library_one.root_folder name = "Root Folder's Folder One" description = "This is the root folder's Folder One" - self.add_folder( str( library_one.id ), str( root_folder.id ), name=name, description=description ) + self.add_folder( 'library_admin', + str( library_one.id ), + str( root_folder.id ), + name=name, + description=description ) global folder_one folder_one = galaxy.model.LibraryFolder.filter( and_( galaxy.model.LibraryFolder.table.c.parent_id==root_folder.id, galaxy.model.LibraryFolder.table.c.name==name, @@ -626,7 +631,7 @@ """Testing adding a folder to a library folder""" name = "Folder One's Subfolder" description = "This is the Folder One's subfolder" - self.add_folder( str( library_one.id ), str( folder_one.id ), name=name, description=description ) + self.add_folder( 'library_admin', str( library_one.id ), str( folder_one.id ), name=name, description=description ) global subfolder_one subfolder_one = galaxy.model.LibraryFolder.filter( and_( galaxy.model.LibraryFolder.table.c.parent_id==folder_one.id, galaxy.model.LibraryFolder.table.c.name==name, @@ -659,7 +664,7 @@ root_folder = library_one.root_folder name = "Folder Two" description = "This is the root folder's Folder Two" - self.add_folder( str( library_one.id ), str( root_folder.id ), name=name, description=description ) + self.add_folder( 'library_admin', str( library_one.id ), str( root_folder.id ), name=name, description=description ) global folder_two folder_two = galaxy.model.LibraryFolder.filter( and_( galaxy.model.LibraryFolder.table.c.parent_id==root_folder.id, galaxy.model.LibraryFolder.table.c.name==name, @@ -687,7 +692,8 @@ message = "Testing adding a public dataset to the folder named %s" % folder_two.name # The form_one template should be inherited to the library dataset upload form. template_contents = "%s contents for %s 2.bed" % ( form_one_field_label, folder_two.name ) - self.add_library_dataset( '2.bed', + self.add_library_dataset( 'library_admin', + '2.bed', str( library_one.id ), str( folder_two.id ), folder_two.name, @@ -718,7 +724,8 @@ message = "Testing adding a 2nd public dataset to the folder named %s" % folder_two.name # The form_one template should be inherited to the library dataset upload form. template_contents = "%s contents for %s 3.bed" % ( form_one_field_label, folder_two.name ) - self.add_library_dataset( '3.bed', + self.add_library_dataset( 'library_admin', + '3.bed', str( library_one.id ), str( folder_two.id ), folder_two.name, @@ -760,7 +767,8 @@ message ='This is a test of the fourth dataset uploaded' # The form_one template should be inherited to the library dataset upload form. template_contents = "%s contents for %s 4.bed" % ( form_one_field_label, folder_one.name ) - self.add_library_dataset( '4.bed', + self.add_library_dataset( 'library_admin', + '4.bed', str( library_one.id ), str( folder_one.id ), folder_one.name, @@ -867,7 +875,8 @@ message = 'Testing adding a dataset with a role that is associated with a group and users' # The form_one template should be inherited to the library dataset upload form. template_contents = "%s contents for %s 5.bed" % ( form_one_field_label, folder_one.name ) - self.add_library_dataset( '5.bed', + self.add_library_dataset( 'library_admin', + '5.bed', str( library_one.id ), str( folder_one.id ), folder_one.name, @@ -1580,7 +1589,8 @@ galaxy.model.Library.table.c.deleted==False ) ).first() assert library_two is not None, 'Problem retrieving library named "%s" from the database' % name # Add a dataset to the library - self.add_library_dataset( '7.bed', + self.add_library_dataset( 'library_admin', + '7.bed', str( library_two.id ), str( library_two.root_folder.id ), library_two.root_folder.name, @@ -1628,11 +1638,57 @@ self.visit_url( '%s/library/browse_libraries' % self.url ) self.check_page_for_string( name ) self.logout() - # Login as regular_user1 and make sure they can see the library + # Login as regular_user2 and make sure they can see the library self.login( email=regular_user2.email ) self.visit_url( '%s/library/browse_libraries' % self.url ) self.check_page_for_string( name ) - # TODO: add more tests here to cover adding, modifying, managing permissions from the Librarys persoective as a regular user + # Add a dataset to the library + message = 'Testing adding 1.bed to Library Three root folder' + self.add_library_dataset( 'library', + '1.bed', + str( library_three.id ), + str( library_three.root_folder.id ), + library_three.root_folder.name, + file_type='bed', + dbkey='hg18', + message=message.replace( ' ', '+' ), + root=True ) + # Add a folder to the library + name = "Root Folder's Folder X" + description = "This is the root folder's Folder X" + self.add_folder( 'library', + str( library_three.id ), + str( library_three.root_folder.id ), + name=name, + description=description ) + folder_x = galaxy.model.LibraryFolder.filter( and_( galaxy.model.LibraryFolder.table.c.parent_id==library_three.root_folder.id, + galaxy.model.LibraryFolder.table.c.name==name, + galaxy.model.LibraryFolder.table.c.description==description ) ).first() + # Modify the folder's information + new_name = "Root Folder's Folder Y" + new_description = "This is the root folder's Folder Y" + self.edit_folder_info( 'library', str( folder_x.id ), str( library_three.id ), name, new_name, new_description ) + folder_x.refresh() + # Add a dataset to the folder + name2 = "Folder Y subfolder" + description2 = "Folder Y subfolder description" + self.add_library_dataset( 'library', + '2.bed', + str( library_three.id ), + str( folder_x.id ), + folder_x.name, + file_type='bed', + dbkey='hg18', + message=message.replace( ' ', '+' ), + root=False ) + ldda_x = galaxy.model.LibraryDatasetDatasetAssociation.query() \ + .order_by( desc( galaxy.model.LibraryDatasetDatasetAssociation.table.c.create_time ) ).first() + assert ldda_x is not None, 'Problem retrieving ldda_x from the database' + # Log in as regular_user1 + self.logout() + self.login( email=regular_user1.email ) + self.visit_url( '%s/library/browse_library?obj_id=%s' % ( self.url, str( library_three.id ) ) ) + self.check_page_for_string( ldda_x.name ) self.logout() self.login( email=admin_user.email ) self.delete_library_item( str( library_three.id ), str( library_three.id ), library_three.name, library_item_type='library' ) @@ -1671,11 +1727,11 @@ # Reset DefaultHistoryPermissions for regular_user1 ##################### self.logout() - self.login( email='test1@bx.psu.edu' ) + self.login( email=regular_user1.email ) # Change DefaultHistoryPermissions for regular_user1 back to the default permissions_in = [ 'DATASET_MANAGE_PERMISSIONS' ] permissions_out = [ 'DATASET_ACCESS' ] role_id = str( regular_user1_private_role.id ) self.user_set_default_permissions( permissions_in=permissions_in, permissions_out=permissions_out, role_id=role_id ) self.logout() - self.login( email='test@bx.psu.edu' ) + self.login( email=admin_user.email )