[hg] galaxy 2729: Bug fixes, enhancements, code refactoring and ...
details: http://www.bx.psu.edu/hg/galaxy/rev/8cbdd73ab68c changeset: 2729:8cbdd73ab68c user: Greg Von Kuster <greg@bx.psu.edu> date: Sat Sep 19 00:25:14 2009 -0400 description: Bug fixes, enhancements, code refactoring and re-introduction of functional tests for library templates. - Fixed bug where exception was thrown when chosing a role in the admin view - The contents of inherited templates will no longer be displayed in the inherited container - Old versions of library datasets will not be displayed in the lbrary browser - Added the job.traceback information to the dataset error report - Moved the get_form_wigets method the forms.py to the FormDefinition class, renaming it to get_wigets 15 file(s) affected in this change: lib/galaxy/model/__init__.py lib/galaxy/web/controllers/admin.py lib/galaxy/web/controllers/dataset.py lib/galaxy/web/controllers/forms.py lib/galaxy/web/controllers/library.py lib/galaxy/web/controllers/library_admin.py lib/galaxy/web/controllers/library_dataset.py lib/galaxy/web/controllers/requests.py lib/galaxy/web/controllers/requests_admin.py templates/admin/library/browse_library.mako templates/library/browse_library.mako templates/library/new_dataset.mako test/base/twilltestcase.py test/functional/test_forms_and_requests.py test/functional/test_security_and_libraries.py diffs (1993 lines): diff -r 9d615c906e6c -r 8cbdd73ab68c lib/galaxy/model/__init__.py --- a/lib/galaxy/model/__init__.py Fri Sep 18 22:41:11 2009 -0400 +++ b/lib/galaxy/model/__init__.py Sat Sep 19 00:25:14 2009 -0400 @@ -14,6 +14,7 @@ from galaxy.datatypes.metadata import MetadataCollection from galaxy.security import RBACAgent, get_permitted_actions from galaxy.util.hash_util import * +from galaxy.web.form_builder import * import logging log = logging.getLogger( __name__ ) @@ -686,10 +687,23 @@ self.name = name or "Unnamed library" self.description = description self.root_folder = root_folder - def get_info_association( self, restrict=False ): + def get_info_association( self, restrict=False, inherited=False ): if self.info_association: - return self.info_association[0] - return None + return self.info_association[0], inherited + return None, inherited + def get_template_widgets( self, trans, get_contents=True ): + # See if we have any associated templates - the returned value for + # inherited is not applicable at the library level + info_association, inherited = self.get_info_association() + if info_association: + template = info_association.template + if get_contents: + # See if we have any field contents + info = info_association.info + if info: + return template.get_widgets( trans.user, contents=info.content ) + return template.get_widgets( trans.user ) + return [] class LibraryFolder( object ): def __init__( self, name=None, description=None, item_count=0, order_id=None ): @@ -708,19 +722,35 @@ folder.parent_id = self.id folder.order_id = self.item_count self.item_count += 1 - def get_info_association( self, restrict=False ): + def get_info_association( self, restrict=False, inherited=False ): # If restrict is True, we will return this folder's info_association, not inheriting. # If restrict is False, we'll return the next available info_association in the - # inheritable hierarchy + # inheritable hierarchy. True is also returned if the info_association was inherited, + # and False if not. This enables us to eliminate displaying the any contents of the inherited + # template. if self.info_association: - return self.info_association[0] + return self.info_association[0], inherited if restrict: - return None + return None, inherited if self.parent: - return self.parent.get_info_association() + return self.parent.get_info_association( inherited=True ) if self.library_root: - return self.library_root[0].get_info_association() - return None + return self.library_root[0].get_info_association( inherited=True ) + return None, inherited + def get_template_widgets( self, trans, get_contents=True ): + # See if we have any associated templates + info_association, inherited = self.get_info_association() + if info_association: + template = info_association.template + # See if we have any field contents, but only if the info_association was + # not inherited ( we do not want to display the inherited contents ). + if not inherited and get_contents: + info = info_association.info + if info: + return template.get_widgets( trans.user, info.content ) + else: + return template.get_widgets( trans.user ) + return [] @property def active_library_datasets( self ): # This needs to be a list @@ -839,15 +869,31 @@ return ldda def clear_associated_files( self, metadata_safe = False, purge = False ): return - def get_info_association( self, restrict=False ): + def get_info_association( self, restrict=False, inherited=False ): # If restrict is True, we will return this ldda's info_association whether it # exists or not. If restrict is False, we'll return the next available info_association - # in the inheritable hierarchy + # in the inheritable hierarchy. True is also returned if the info_association was inherited, + # and False if not. This enables us to eliminate displaying the any contents of the inherited + # template. if self.info_association: - return self.info_association[0] + return self.info_association[0], inherited if restrict: - return None - return self.library_dataset.folder.get_info_association() + return None, inherited + return self.library_dataset.folder.get_info_association( inherited=True ) + def get_template_widgets( self, trans, get_contents=True ): + # See if we have any associated templates + info_association, inherited = self.get_info_association() + if info_association: + template = info_association.template + # See if we have any field contents, but only if the info_association was + # not inherited ( we do not want to display the inherited contents ). + if not inherited and get_contents: + info = info_association.info + if info: + return template.get_widgets( trans.user, info.content ) + else: + return template.get_widgets( trans.user ) + return [] class LibraryInfoAssociation( object ): def __init__( self, library, form_definition, info ): @@ -1030,6 +1076,62 @@ if f['layout'] == str(layout_index): fields_dict[i] = f return fields_dict + def get_widgets( self, user, contents=[], **kwd ): + ''' + Return the list of widgets that comprise a form definition, + including field contents if any. + ''' + params = util.Params( kwd ) + widgets = [] + for index, field in enumerate( self.fields ): + field_name = 'field_%i' % index + # determine the value of the field + if field_name in kwd: + # the user had already filled out this field and the same form is re-rendered + # due to some reason like required fields have been left out. + if field[ 'type' ] == 'CheckboxField': + value = CheckboxField.is_checked( util.restore_text( params.get( field_name, False ) ) ) + else: + value = util.restore_text( params.get( field_name, '' ) ) + elif contents: + # this field has a saved value + value = str( contents[ index ] ) + else: + # if none of the above, then leave the field empty + if field[ 'type' ] == 'CheckboxField': + # Since we do not have contents, set checkbox value to False + value = False + else: + # Set other field types to empty string + value = '' + # create the field widget + field_widget = eval( field[ 'type' ] )( field_name ) + if field[ 'type' ] == 'TextField': + field_widget.set_size( 40 ) + field_widget.value = value + elif field[ 'type' ] == 'TextArea': + field_widget.set_size( 3, 40 ) + field_widget.value = value + elif field['type'] == 'AddressField': + field_widget.user = user + field_widget.value = value + field_widget.params = params + elif field[ 'type' ] == 'SelectField': + for option in field[ 'selectlist' ]: + if option == value: + field_widget.add_option( option, option, selected=True ) + else: + field_widget.add_option( option, option ) + elif field[ 'type' ] == 'CheckboxField': + field_widget.checked = value + if field[ 'required' ] == 'required': + req = 'Required' + else: + req = 'Optional' + widgets.append( dict( label=field[ 'label' ], + widget=field_widget, + helptext='%s (%s)' % ( field[ 'helptext' ], req ) ) ) + return widgets class FormDefinitionCurrent( object ): def __init__(self, form_definition=None): diff -r 9d615c906e6c -r 8cbdd73ab68c lib/galaxy/web/controllers/admin.py --- a/lib/galaxy/web/controllers/admin.py Fri Sep 18 22:41:11 2009 -0400 +++ b/lib/galaxy/web/controllers/admin.py Sat Sep 19 00:25:14 2009 -0400 @@ -3,7 +3,6 @@ from galaxy import util, datatypes from galaxy.web.base.controller import * from galaxy.model.orm import * -from galaxy.web.controllers.forms import get_all_forms, get_form_widgets from galaxy.web.framework.helpers import time_ago, iff, grids import logging log = logging.getLogger( __name__ ) @@ -242,7 +241,7 @@ # whose DatasetPermissions is associated with the Role # [ ( LibraryDatasetDatasetAssociation [ action, action ] ) ] library_dataset_actions = {} - for dp in role.actions: + for dp in role.dataset_actions: for ldda in trans.app.model.LibraryDatasetDatasetAssociation \ .filter( trans.app.model.LibraryDatasetDatasetAssociation.dataset_id==dp.dataset_id ) \ .all(): diff -r 9d615c906e6c -r 8cbdd73ab68c lib/galaxy/web/controllers/dataset.py --- a/lib/galaxy/web/controllers/dataset.py Fri Sep 18 22:41:11 2009 -0400 +++ b/lib/galaxy/web/controllers/dataset.py Sat Sep 19 00:25:14 2009 -0400 @@ -35,6 +35,9 @@ ----------------------------------------------------------------------------- job info: ${info} +----------------------------------------------------------------------------- +job traceback: +${traceback} ----------------------------------------------------------------------------- (This is an automated message). """ @@ -76,6 +79,7 @@ tool_id=job.tool_id, stderr=job.stderr, stdout=job.stdout, + traceback=job.traceback, info=job.info ) ) frm = to_address # Check email a bit diff -r 9d615c906e6c -r 8cbdd73ab68c lib/galaxy/web/controllers/forms.py --- a/lib/galaxy/web/controllers/forms.py Fri Sep 18 22:41:11 2009 -0400 +++ b/lib/galaxy/web/controllers/forms.py Sat Sep 19 00:25:14 2009 -0400 @@ -500,10 +500,6 @@ Return all the latest forms from the form_definition_current table if all_versions is set to True. Otherwise return all the versions of all the forms from the form_definition table. - - TODO: when we add the concept of a form_definition_type ( e.g., - 'request_header', 'request_sample', 'library_template' ), filter - the query if received filter is not None. ''' if all_versions: return trans.app.model.FormDefinition.query().all() @@ -515,64 +511,3 @@ return [ fdc.latest_form for fdc in fdc_list ] else: return [ fdc.latest_form for fdc in fdc_list if fdc.latest_form.type == form_type ] - - - -def get_form_widgets( trans, form, contents=[], user=None, **kwd ): - ''' - Return the list of widgets that comprise a form definition, - including field contents if any. - ''' - params = util.Params( kwd ) - if not user: - user = trans.user - widgets = [] - for index, field in enumerate( form.fields ): - field_name = 'field_%i' % index - # determine the value of the field - if field_name in kwd: - # the user had already filled out this field and the same form is re-rendered - # due to some reason like required fields have been left out. - if field[ 'type' ] == 'CheckboxField': - value = CheckboxField.is_checked( util.restore_text( params.get( field_name, False ) ) ) - else: - value = util.restore_text( params.get( field_name, '' ) ) - elif contents: - # this field has a saved value - value = str(contents[ index ]) - else: - # if none of the above, then leave the field empty - if field[ 'type' ] == 'CheckboxField': - # Since we do not have contents, set checkbox value to False - value = False - else: - # Set other field types to empty string - value = '' - # create the field widget - field_widget = eval( field[ 'type' ] )( field_name ) - if field[ 'type' ] == 'TextField': - field_widget.set_size( 40 ) - field_widget.value = value - elif field[ 'type' ] == 'TextArea': - field_widget.set_size( 3, 40 ) - field_widget.value = value - elif field['type'] == 'AddressField': - field_widget.user = user - field_widget.value = value - field_widget.params = params - elif field[ 'type' ] == 'SelectField': - for option in field[ 'selectlist' ]: - if option == value: - field_widget.add_option( option, option, selected=True ) - else: - field_widget.add_option( option, option ) - elif field[ 'type' ] == 'CheckboxField': - field_widget.checked = value - if field[ 'required' ] == 'required': - req = 'Required' - else: - req = 'Optional' - widgets.append( dict( label=field[ 'label' ], - widget=field_widget, - helptext='%s (%s)' % ( field[ 'helptext' ], req ) ) ) - return widgets diff -r 9d615c906e6c -r 8cbdd73ab68c lib/galaxy/web/controllers/library.py --- a/lib/galaxy/web/controllers/library.py Fri Sep 18 22:41:11 2009 -0400 +++ b/lib/galaxy/web/controllers/library.py Sat Sep 19 00:25:14 2009 -0400 @@ -3,7 +3,7 @@ from galaxy.datatypes import sniff from galaxy import util from galaxy.util.odict import odict -from galaxy.web.controllers.forms import get_all_forms, get_form_widgets +from galaxy.web.controllers.forms import get_all_forms from galaxy.util.streamball import StreamBall import logging, tempfile, zipfile, tarfile, os, sys @@ -149,16 +149,7 @@ messagetype='error' ) ) if action == 'information': # See if we have any associated templates - if library.info_association: - template = library.info_association[0].template - # See if we have any field contents - info = library.info_association[0].info - if info: - widgets = get_form_widgets( trans, template, info.content ) - else: - widgets = get_form_widgets( trans, template ) - else: - widgets = [] + widgets = library.get_template_widgets( trans ) if params.get( 'rename_library_button', False ): old_name = library.name new_name = util.restore_text( params.name ) @@ -479,17 +470,7 @@ msg=util.sanitize_text( msg ), messagetype='error' ) ) # See if we have any associated templates - info_association = ldda.get_info_association() - if info_association: - template = info_association.template - # See if we have any field contents - info = info_association.info - if info: - widgets = get_form_widgets( trans, template, info.content ) - else: - widgets = get_form_widgets( trans, template ) - else: - widgets = [] + widgets = ldda.get_template_widgets( trans ) if action == 'permissions': if params.get( 'update_roles_button', False ): # The user clicked the Save button on the 'Associate With Roles' form @@ -782,6 +763,8 @@ msg=util.sanitize_text( msg ), messagetype='error' ) ) if not id or replace_dataset: + # See if we have any inherited templates, but do not inherit contents. + widgets = folder.get_template_widgets( trans, get_contents=False ) upload_option = params.get( 'upload_option', 'upload_file' ) # No dataset(s) specified, so display the upload form. Send list of data formats to the form # so the "extension" select list can be populated dynamically @@ -806,6 +789,7 @@ last_used_build=last_used_build, roles=roles, history=history, + widgets=widgets, msg=msg, messagetype=messagetype, replace_dataset=replace_dataset ) @@ -968,17 +952,7 @@ messagetype=messagetype ) elif action == 'information': # See if we have any associated templates - info_association = folder.get_info_association() - if info_association: - template = info_association.template - # See if we have any field contents - info = info_association.info - if info: - widgets = get_form_widgets( trans, template, info.content ) - else: - widgets = get_form_widgets( trans, template ) - else: - widgets = [] + widgets = folder.get_template_widgets( trans ) if params.get( 'rename_folder_button', False ): if trans.app.security_agent.can_modify_library_item( user, roles, folder ): old_name = folder.name diff -r 9d615c906e6c -r 8cbdd73ab68c lib/galaxy/web/controllers/library_admin.py --- a/lib/galaxy/web/controllers/library_admin.py Fri Sep 18 22:41:11 2009 -0400 +++ b/lib/galaxy/web/controllers/library_admin.py Sat Sep 19 00:25:14 2009 -0400 @@ -2,7 +2,7 @@ from galaxy import util from galaxy.web.base.controller import * from galaxy.model.orm import * -from galaxy.web.controllers.forms import get_all_forms, get_form_widgets +from galaxy.web.controllers.forms import get_all_forms # Older py compatibility try: set() @@ -96,17 +96,7 @@ return trans.fill_template( '/admin/library/new_library.mako', msg=msg, messagetype=messagetype ) elif action == 'information': # See if we have any associated templates - info_association = library.get_info_association() - if info_association: - template = info_association.template - # See if we have any field contents - info = info_association.info - if info: - widgets = get_form_widgets( trans, template, info.content ) - else: - widgets = get_form_widgets( trans, template ) - else: - widgets = [] + widgets = library.get_template_widgets( trans ) if params.get( 'rename_library_button', False ): old_name = library.name new_name = util.restore_text( params.name ) @@ -293,17 +283,7 @@ messagetype=messagetype ) elif action == 'information': # See if we have any associated templates - info_association = folder.get_info_association() - if info_association: - template = info_association.template - # See if we have any field contents - info = info_association.info - if info: - widgets = get_form_widgets( trans, template, info.content ) - else: - widgets = get_form_widgets( trans, template ) - else: - widgets = [] + widgets = folder.get_template_widgets( trans ) if params.get( 'rename_folder_button', False ): old_name = folder.name new_name = util.restore_text( params.name ) @@ -478,13 +458,8 @@ msg=util.sanitize_text( msg ), messagetype=messagetype ) ) elif not id or replace_dataset: - # See if we have any associated templates - info_association = folder.get_info_association() - if info_association: - template = info_association.template - widgets = get_form_widgets( trans, template ) - else: - widgets = [] + # See if we have any inherited templates, but do not inherit contents. + widgets = folder.get_template_widgets( trans, get_contents=False ) upload_option = params.get( 'upload_option', 'upload_file' ) # No dataset(s) specified, so display the upload form. Send list of data formats to the form # so the "extension" select list can be populated dynamically @@ -536,17 +511,7 @@ msg=util.sanitize_text( msg ), messagetype='error' ) ) # See if we have any associated templates - info_association = ldda.get_info_association() - if info_association: - template = info_association.template - # See if we have any field contents - info = info_association.info - if info: - widgets = get_form_widgets( trans, template, info.content ) - else: - widgets = get_form_widgets( trans, template ) - else: - widgets = [] + widgets = ldda.get_template_widgets( trans ) if action == 'permissions': if params.get( 'update_roles_button', False ): permissions = {} @@ -1019,8 +984,9 @@ # Since information templates are inherited, the template fields can be displayed on the information # page for a folder or library dataset when it has no info_association object. If the user has added # field contents on an inherited template via a parent's info_association, we'll need to create a new - # form_values and info_association for the current object. - info_association = library_item.get_info_association( restrict=True ) + # form_values and info_association for the current object. The value for the returned inherited variable + # is not applicable at this level. + info_association, inherited = library_item.get_info_association( restrict=True ) if info_association: template = info_association.template info = info_association.info @@ -1031,7 +997,7 @@ form_values.flush() else: # Inherit the next available info_association so we can get the template - info_association = library_item.get_info_association() + info_association, inherited = library_item.get_info_association() template = info_association.template # Create a new FormValues object form_values = trans.app.model.FormValues( template, field_contents ) diff -r 9d615c906e6c -r 8cbdd73ab68c lib/galaxy/web/controllers/library_dataset.py --- a/lib/galaxy/web/controllers/library_dataset.py Fri Sep 18 22:41:11 2009 -0400 +++ b/lib/galaxy/web/controllers/library_dataset.py Sat Sep 19 00:25:14 2009 -0400 @@ -205,7 +205,7 @@ template_field_contents = [] template = None folder = trans.app.model.LibraryFolder.get( folder_id ) - info_association = folder.get_info_association() + info_association, inherited = folder.get_info_association() if info_association: template = info_association.template for field_index in range( len( template.fields ) ): diff -r 9d615c906e6c -r 8cbdd73ab68c lib/galaxy/web/controllers/requests.py --- a/lib/galaxy/web/controllers/requests.py Fri Sep 18 22:41:11 2009 -0400 +++ b/lib/galaxy/web/controllers/requests.py Sat Sep 19 00:25:14 2009 -0400 @@ -9,7 +9,6 @@ from galaxy.web.form_builder import * from datetime import datetime, timedelta from cgi import escape, FieldStorage -from galaxy.web.controllers.forms import get_form_widgets log = logging.getLogger( __name__ ) @@ -480,7 +479,7 @@ libraries[ library ] = hidden_folder_ids libui = self.__library_ui(libraries, **kwd) widgets = widgets + libui - widgets = widgets + get_form_widgets(trans, request_type.request_form, contents=[], **kwd) + widgets = widgets + request_type.request_form.get_widgets( user, **kwd ) return trans.fill_template( '/requests/new_request.mako', select_request_type=select_request_type, request_type=request_type, @@ -722,7 +721,7 @@ libraries[ library ] = hidden_folder_ids libui = self.__library_ui(libraries, request, **kwd) widgets = widgets + libui - widgets = widgets + get_form_widgets(trans, request.type.request_form, request.values.content, **kwd) + widgets = widgets + request.type.request_form.get_widgets( user, request.values.content, **kwd ) return trans.fill_template( '/requests/edit_request.mako', select_request_type=select_request_type, request_type=request.type, diff -r 9d615c906e6c -r 8cbdd73ab68c lib/galaxy/web/controllers/requests_admin.py --- a/lib/galaxy/web/controllers/requests_admin.py Fri Sep 18 22:41:11 2009 -0400 +++ b/lib/galaxy/web/controllers/requests_admin.py Sat Sep 19 00:25:14 2009 -0400 @@ -7,7 +7,6 @@ import logging, tempfile, zipfile, tarfile, os, sys from galaxy.web.form_builder import * from datetime import datetime, timedelta -from galaxy.web.controllers.forms import get_form_widgets from galaxy.web.controllers.forms import get_all_forms log = logging.getLogger( __name__ ) @@ -178,7 +177,7 @@ # libraries selectbox libui = self.__library_ui(trans, request.user, request, **kwd) widgets = widgets + libui - widgets = widgets + get_form_widgets(trans, request.type.request_form, request.values.content, request.user, **kwd) + widgets = widgets + request.type.request_form.get_widgets( request.user, request.values.content, **kwd ) return trans.fill_template( '/admin/requests/edit_request.mako', select_request_type=select_request_type, request_type=request.type, @@ -687,7 +686,7 @@ # libraries selectbox libui = self.__library_ui(trans, user, **kwd) widgets = widgets + libui - widgets = widgets + get_form_widgets(trans, request_type.request_form, contents=[], user=user, **kwd) + widgets = widgets + request_type.request_form.get_widgets( user, **kwd ) return trans.fill_template( '/admin/requests/new_request.mako', select_request_type=select_request_type, request_type=request_type, diff -r 9d615c906e6c -r 8cbdd73ab68c templates/admin/library/browse_library.mako --- a/templates/admin/library/browse_library.mako Fri Sep 18 22:41:11 2009 -0400 +++ b/templates/admin/library/browse_library.mako Sat Sep 19 00:25:14 2009 -0400 @@ -85,48 +85,48 @@ else: current_version = False %> - <div class="historyItemWrapper historyItem historyItem-${ldda.state}" id="libraryItem-${ldda.id}"> - ## Header row for library items (name, state, action buttons) - <div class="historyItemTitleBar"> - <table cellspacing="0" cellpadding="0" border="0" width="100%"> - <tr> - <td width="*"> - %if selected: - <input type="checkbox" name="ldda_ids" value="${ldda.id}" checked/> - %else: - <input type="checkbox" name="ldda_ids" value="${ldda.id}"/> - %endif - <span class="libraryItemDeleted-${ldda.deleted}"> - <a href="${h.url_for( controller='library_admin', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, id=ldda.id, info=True, deleted=deleted, show_deleted=show_deleted )}"><b>${ldda.name[:50]}</b></a> - </span> - <a id="dataset-${ldda.id}-popup" class="popup-arrow" style="display: none;">▼</a> - %if not library.deleted and not folder.deleted and not library_dataset.deleted: - <div popupmenu="dataset-${ldda.id}-popup"> - <a class="action-button" href="${h.url_for( controller='library_admin', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, id=ldda.id, edit_info=True )}">Edit this dataset's information</a> - ## We're disabling the ability to add templates at the LDDA and LibraryDataset level, but will leave this here for possible future use - ##<a class="action-button" href="${h.url_for( controller='library_admin', action='info_template', library_id=library.id, library_dataset_id=library_dataset.id, new_template=True )}">Add an information template to this dataset</a> - <a class="action-button" href="${h.url_for( controller='library_admin', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, id=ldda.id, permissions=True )}">Edit this dataset's permissions</a> - %if current_version: + %if current_version: + <div class="historyItemWrapper historyItem historyItem-${ldda.state}" id="libraryItem-${ldda.id}"> + ## Header row for library items (name, state, action buttons) + <div class="historyItemTitleBar"> + <table cellspacing="0" cellpadding="0" border="0" width="100%"> + <tr> + <td width="*"> + %if selected: + <input type="checkbox" name="ldda_ids" value="${ldda.id}" checked/> + %else: + <input type="checkbox" name="ldda_ids" value="${ldda.id}"/> + %endif + <span class="libraryItemDeleted-${ldda.deleted}"> + <a href="${h.url_for( controller='library_admin', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, id=ldda.id, info=True, deleted=deleted, show_deleted=show_deleted )}"><b>${ldda.name[:50]}</b></a> + </span> + <a id="dataset-${ldda.id}-popup" class="popup-arrow" style="display: none;">▼</a> + %if not library.deleted and not folder.deleted and not library_dataset.deleted: + <div popupmenu="dataset-${ldda.id}-popup"> + <a class="action-button" href="${h.url_for( controller='library_admin', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, id=ldda.id, edit_info=True )}">Edit this dataset's information</a> + ## We're disabling the ability to add templates at the LDDA and LibraryDataset level, but will leave this here for possible future use + ##<a class="action-button" href="${h.url_for( controller='library_admin', action='info_template', library_id=library.id, library_dataset_id=library_dataset.id, new_template=True )}">Add an information template to this dataset</a> + <a class="action-button" href="${h.url_for( controller='library_admin', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, id=ldda.id, permissions=True )}">Edit this dataset's permissions</a> <a class="action-button" href="${h.url_for( controller='library_admin', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, replace_id=library_dataset.id )}">Upload a new version of this dataset</a> - %endif - %if ldda.has_data: - <a class="action-button" href="${h.url_for( controller='library_admin', action='download_dataset_from_folder', id=ldda.id, library_id=library.id )}">Download this dataset</a> - %endif - <a class="action-button" confirm="Click OK to delete dataset '${ldda.name}'." href="${h.url_for( controller='library_admin', action='delete_library_item', library_id=library.id, library_item_id=library_dataset.id, library_item_type='library_dataset' )}">Delete this dataset</a> - </div> - %elif not library.deleted and not folder.deleted and library_dataset.deleted: - <div popupmenu="dataset-${ldda.id}-popup"> - <a class="action-button" href="${h.url_for( controller='library_admin', action='undelete_library_item', library_id=library.id, library_item_id=library_dataset.id, library_item_type='library_dataset' )}">Undelete this dataset</a> - </div> - %endif - </td> - <td width="300">${ldda.message}</td> - <td width="150">${uploaded_by}</td> - <td width="60">${ldda.create_time.strftime( "%Y-%m-%d" )}</td> - </tr> - </table> + %if ldda.has_data: + <a class="action-button" href="${h.url_for( controller='library_admin', action='download_dataset_from_folder', id=ldda.id, library_id=library.id )}">Download this dataset</a> + %endif + <a class="action-button" confirm="Click OK to delete dataset '${ldda.name}'." href="${h.url_for( controller='library_admin', action='delete_library_item', library_id=library.id, library_item_id=library_dataset.id, library_item_type='library_dataset' )}">Delete this dataset</a> + </div> + %elif not library.deleted and not folder.deleted and library_dataset.deleted: + <div popupmenu="dataset-${ldda.id}-popup"> + <a class="action-button" href="${h.url_for( controller='library_admin', action='undelete_library_item', library_id=library.id, library_item_id=library_dataset.id, library_item_type='library_dataset' )}">Undelete this dataset</a> + </div> + %endif + </td> + <td width="300">${ldda.message}</td> + <td width="150">${uploaded_by}</td> + <td width="60">${ldda.create_time.strftime( "%Y-%m-%d" )}</td> + </tr> + </table> + </div> </div> - </div> + %endif </%def> <%def name="render_folder( folder, folder_pad, deleted, show_deleted, created_ldda_ids, library_id, root_folder=False )"> diff -r 9d615c906e6c -r 8cbdd73ab68c templates/library/browse_library.mako --- a/templates/library/browse_library.mako Fri Sep 18 22:41:11 2009 -0400 +++ b/templates/library/browse_library.mako Sat Sep 19 00:25:14 2009 -0400 @@ -91,52 +91,53 @@ uploaded_by = 'anonymous' if ldda == library_dataset.library_dataset_dataset_association: current_version = True + can_modify_library_dataset = trans.app.security_agent.can_modify_library_item( user, roles, library_dataset ) + can_manage_library_dataset = trans.app.security_agent.can_manage_library_item( user, roles, library_dataset ) else: current_version = False - can_modify_library_dataset = trans.app.security_agent.can_modify_library_item( user, roles, library_dataset ) - can_manage_library_dataset = trans.app.security_agent.can_manage_library_item( user, roles, library_dataset ) %> - - <tr class="datasetRow" - %if parent is not None: - parent="${parent}" - style="display: none;" + %if current_version: + <tr class="datasetRow" + %if parent is not None: + parent="${parent}" + style="display: none;" + %endif + > + <td style="padding-left: ${pad+20}px;"> + %if selected: + <input type="checkbox" name="ldda_ids" value="${ldda.id}" checked/> + %else: + <input type="checkbox" name="ldda_ids" value="${ldda.id}"/> + %endif + <a href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, id=ldda.id, info=True )}"><b>${ldda.name[:60]}</b></a> + <a id="dataset-${ldda.id}-popup" class="popup-arrow" style="display: none;">▼</a> + <div popupmenu="dataset-${ldda.id}-popup"> + %if can_modify_library_dataset: + <a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, id=ldda.id, edit_info=True )}">Edit this dataset's information</a> + %else: + <a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, id=ldda.id, information=True )}">View this dataset's information</a> + %endif + %if can_manage_library_dataset: + <a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, id=ldda.id, permissions=True )}">Edit this dataset's permissions</a> + %endif + %if can_modify_library_dataset: + <a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, replace_id=library_dataset.id )}">Upload a new version of this dataset</a> + %endif + %if ldda.has_data: + <a class="action-button" href="${h.url_for( controller='library', action='datasets', library_id=library.id, ldda_ids=str( ldda.id ), do_action='add' )}">Import this dataset into your current history</a> + <a class="action-button" href="${h.url_for( controller='library', action='download_dataset_from_folder', id=ldda.id, library_id=library.id )}">Download this dataset</a> + %endif + </div> + </td> + <td>${ldda.message}</td> + <td>${uploaded_by}</td> + <td>${ldda.create_time.strftime( "%Y-%m-%d" )}</td> + </tr> + <% + my_row = row_counter.count + row_counter.increment() + %> %endif - > - <td style="padding-left: ${pad+20}px;"> - %if selected: - <input type="checkbox" name="ldda_ids" value="${ldda.id}" checked/> - %else: - <input type="checkbox" name="ldda_ids" value="${ldda.id}"/> - %endif - <a href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, id=ldda.id, info=True )}"><b>${ldda.name[:60]}</b></a> - <a id="dataset-${ldda.id}-popup" class="popup-arrow" style="display: none;">▼</a> - <div popupmenu="dataset-${ldda.id}-popup"> - %if can_modify_library_dataset: - <a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, id=ldda.id, edit_info=True )}">Edit this dataset's information</a> - %else: - <a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, id=ldda.id, information=True )}">View this dataset's information</a> - %endif - %if can_manage_library_dataset: - <a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, id=ldda.id, permissions=True )}">Edit this dataset's permissions</a> - %endif - %if current_version and can_modify_library_dataset: - <a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library.id, folder_id=folder.id, replace_id=library_dataset.id )}">Upload a new version of this dataset</a> - %endif - %if ldda.has_data: - <a class="action-button" href="${h.url_for( controller='library', action='datasets', library_id=library.id, ldda_ids=str( ldda.id ), do_action='add' )}">Import this dataset into your current history</a> - <a class="action-button" href="${h.url_for( controller='library', action='download_dataset_from_folder', id=ldda.id, library_id=library.id )}">Download this dataset</a> - %endif - </div> - </td> - <td>${ldda.message}</td> - <td>${uploaded_by}</td> - <td>${ldda.create_time.strftime( "%Y-%m-%d" )}</td> - </tr> - <% - my_row = row_counter.count - row_counter.increment() - %> </%def> <%def name="render_folder( folder, folder_pad, created_ldda_ids, library_id, hidden_folder_ids, parent=None, row_counter=None, root_folder=False )"> diff -r 9d615c906e6c -r 8cbdd73ab68c templates/library/new_dataset.mako --- a/templates/library/new_dataset.mako Fri Sep 18 22:41:11 2009 -0400 +++ b/templates/library/new_dataset.mako Sat Sep 19 00:25:14 2009 -0400 @@ -170,7 +170,7 @@ </div> <div style="clear: both"></div> <% folder = trans.app.model.LibraryFolder.get( folder_id ) %> - %if widgets: + %if upload_option == 'upload_file' and widgets: ${render_template_info( folder, library_id, widgets )} %endif <div class="form-row"> diff -r 9d615c906e6c -r 8cbdd73ab68c test/base/twilltestcase.py --- a/test/base/twilltestcase.py Fri Sep 18 22:41:11 2009 -0400 +++ b/test/base/twilltestcase.py Sat Sep 19 00:25:14 2009 -0400 @@ -980,8 +980,6 @@ different scope in the tool) cannot be properly tested when they both exist at the same time. """ - # TODO: RC: enhance this so that all supported field types can be passed in - # and tested. If nothing is passed, all fields are TextField. self.home() self.visit_url( "%s/forms/new" % self.url ) self.check_page_for_string( 'Create a new form definition' ) @@ -1253,21 +1251,13 @@ self.check_page_for_string( check_str ) self.home() def add_library_dataset( self, filename, library_id, folder_id, folder_name, file_format='auto', - dbkey='hg18', roles=[], message='', root=False, check_template_str1='', check_template_str2='', - check_template_str3='' ): + 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/library_dataset_dataset_association?upload_option=upload_file&library_id=%s&folder_id=%s&message=%s" % \ ( self.url, library_id, folder_id, message ) ) self.check_page_for_string( 'Upload files' ) - # If we've been sent some template labels, make sure they are included in the upload form - if check_template_str1: - self.check_page_for_string( check_template_str1 ) - if check_template_str2: - self.check_page_for_string( check_template_str2 ) - if check_template_str3: - self.check_page_for_string( check_template_str3 ) tc.fv( "1", "folder_id", folder_id ) tc.formfile( "1", "file_data", filename ) tc.fv( "1", "file_format", file_format ) @@ -1275,6 +1265,9 @@ tc.fv( "1", "message", message.replace( '+', ' ' ) ) for role_id in roles: tc.fv( "1", "roles", role_id ) # form field 7 is the select list named out_groups, note the buttons... + # Add template field contents, if any... + if template_field_name1: + tc.fv( "1", template_field_name1, template_field_contents1 ) tc.submit( "new_dataset_button" ) if root: check_str = "Added 1 datasets to the library '%s' ( each is selected )." % folder_name @@ -1347,7 +1340,7 @@ self.check_page_for_string( check_str ) self.home() def upload_new_dataset_version( self, filename, library_id, folder_id, folder_name, library_dataset_id, ldda_name, file_format='auto', - dbkey='hg18', message='', check_template_str1='', check_template_str2='', check_template_str3='' ): + dbkey='hg18', message='', template_field_name1='', template_field_contents1='' ): """Upload new version(s) of a dataset""" self.home() filename = self.get_filename( filename ) @@ -1356,40 +1349,32 @@ self.check_page_for_string( 'Upload files' ) self.check_page_for_string( 'You are currently selecting a new file to replace' ) self.check_page_for_string( ldda_name ) - # If we've been sent some template labels, make sure they are included in the upload form - if check_template_str1: - self.check_page_for_string( check_template_str1 ) - if check_template_str2: - self.check_page_for_string( check_template_str2 ) - if check_template_str3: - self.check_page_for_string( check_template_str3 ) tc.formfile( "1", "file_data", filename ) tc.fv( "1", "file_format", file_format ) tc.fv( "1", "dbkey", dbkey ) tc.fv( "1", "message", message.replace( '+', ' ' ) ) + # Add template field contents, if any... + if template_field_name1: + tc.fv( "1", template_field_name1, template_field_contents1 ) tc.submit( "new_dataset_button" ) check_str = "Added 1 dataset versions to the library dataset '%s' in the folder '%s'." % ( ldda_name, folder_name ) self.check_page_for_string( check_str ) self.home() def upload_new_dataset_versions( self, library_id, folder_id, folder_name, library_dataset_id, ldda_name, file_format='auto', - dbkey='hg18', message='', check_template_str1='', check_template_str2='', check_template_str3='' ): + dbkey='hg18', message='', template_field_name1='', template_field_contents1='' ): """Upload new version(s) of a dataset using a directory of files""" self.home() self.visit_url( "%s/library_admin/library_dataset_dataset_association?upload_option=upload_directory&library_id=%s&folder_id=%s&replace_id=%s" \ % ( self.url, library_id, folder_id, library_dataset_id ) ) self.check_page_for_string( 'Upload a directory of files' ) self.check_page_for_string( 'You are currently selecting a new file to replace' ) - # If we've been sent some template labels, make sure they are included in the upload form - if check_template_str1: - self.check_page_for_string( check_template_str1 ) - if check_template_str2: - self.check_page_for_string( check_template_str2 ) - if check_template_str3: - self.check_page_for_string( check_template_str3 ) tc.fv( "1", "file_format", file_format ) tc.fv( "1", "dbkey", dbkey ) tc.fv( "1", "message", message.replace( '+', ' ' ) ) tc.fv( "1", "server_dir", "library" ) + # Add template field contents, if any... + if template_field_name1: + tc.fv( "1", template_field_name1, template_field_contents1 ) tc.submit( "new_dataset_button" ) check_str = "Added 3 dataset versions to the library dataset '%s' in the folder '%s'." % ( ldda_name, folder_name ) self.check_page_for_string( check_str ) @@ -1406,19 +1391,12 @@ self.check_page_for_string( check_str ) self.home() def add_dir_of_files_from_admin_view( self, library_id, folder_id, file_format='auto', dbkey='hg18', roles_tuple=[], - message='', check_str_after_submit='', check_str1='', check_str2='', check_str3='' ): + message='', check_str_after_submit='', template_field_name1='', template_field_contents1='' ): """Add a directory of datasets to a folder""" # roles is a list of tuples: [ ( role_id, role_description ) ] self.home() self.visit_url( "%s/library_admin/library_dataset_dataset_association?upload_option=upload_directory&library_id=%s&folder_id=%s" % ( self.url, library_id, folder_id ) ) self.check_page_for_string( 'Upload a directory of files' ) - # If we've been sent some template labels, make sure they are included in the upload form - if check_str1: - self.check_page_for_string( check_str1 ) - if check_str2: - self.check_page_for_string( check_str2 ) - if check_str3: - self.check_page_for_string( check_str3 ) tc.fv( "1", "folder_id", folder_id ) tc.fv( "1", "file_format", file_format ) tc.fv( "1", "dbkey", dbkey ) @@ -1426,24 +1404,20 @@ tc.fv( "1", "server_dir", "library" ) for role_tuple in roles_tuple: tc.fv( "1", "roles", role_tuple[1] ) # role_tuple[1] is the role name + # Add template field contents, if any... + if template_field_name1: + tc.fv( "1", template_field_name1, template_field_contents1 ) tc.submit( "new_dataset_button" ) if check_str_after_submit: self.check_page_for_string( check_str_after_submit ) self.home() def add_dir_of_files_from_libraries_view( self, library_id, folder_id, selected_dir, file_format='auto', dbkey='hg18', roles_tuple=[], - message='', check_str_after_submit='', check_str1='', check_str2='', check_str3='' ): + message='', check_str_after_submit='', template_field_name1='', template_field_contents1='' ): """Add a directory of datasets to a folder""" # roles is a list of tuples: [ ( role_id, role_description ) ] self.home() self.visit_url( "%s/library/library_dataset_dataset_association?upload_option=upload_directory&library_id=%s&folder_id=%s" % ( self.url, library_id, folder_id ) ) self.check_page_for_string( 'Upload a directory of files' ) - # If we've been sent some template labels, make sure they are included in the upload form - if check_str1: - self.check_page_for_string( check_str1 ) - if check_str2: - self.check_page_for_string( check_str2 ) - if check_str3: - self.check_page_for_string( check_str3 ) tc.fv( "1", "folder_id", folder_id ) tc.fv( "1", "file_format", file_format ) tc.fv( "1", "dbkey", dbkey ) @@ -1451,6 +1425,9 @@ tc.fv( "1", "server_dir", selected_dir ) for role_tuple in roles_tuple: tc.fv( "1", "roles", role_tuple[1] ) # role_tuple[1] is the role name + # Add template field contents, if any... + if template_field_name1: + tc.fv( "1", template_field_name1, template_field_contents1 ) tc.submit( "new_dataset_button" ) if check_str_after_submit: self.check_page_for_string( check_str_after_submit ) diff -r 9d615c906e6c -r 8cbdd73ab68c test/functional/test_forms_and_requests.py --- a/test/functional/test_forms_and_requests.py Fri Sep 18 22:41:11 2009 -0400 +++ b/test/functional/test_forms_and_requests.py Sat Sep 19 00:25:14 2009 -0400 @@ -41,7 +41,7 @@ global form_one_name name = form_one_name desc = "This is Form One's description" - formtype = 'Sequencing Request Form' + formtype = galaxy.model.FormDefinition.types.REQUEST self.create_form( name=name, desc=desc, formtype=formtype ) self.home() self.visit_page( 'forms/manage' ) diff -r 9d615c906e6c -r 8cbdd73ab68c test/functional/test_security_and_libraries.py --- a/test/functional/test_security_and_libraries.py Fri Sep 18 22:41:11 2009 -0400 +++ b/test/functional/test_security_and_libraries.py Sat Sep 19 00:25:14 2009 -0400 @@ -475,15 +475,23 @@ library_one.refresh() self.rename_library( str( library_one.id ), library_one.name, name=name, description=description ) library_one.refresh() - """ - def test_075_library_template_features( self ): - Testing adding a template to a library, along with template features on the admin side + def test_075_library_template_features( self ): + """Testing adding a template to a library, then filling in the contents""" # Make sure a form exists - self.create_form( name='Form One', description='This is Form One' ) - current_form = galaxy.model.FormDefinitionCurrent.filter( galaxy.model.FormDefinitionCurrent.table.c.deleted==False ) \ - .order_by( desc( galaxy.model.FormDefinitionCurrent.table.c.create_time ) ).first() + form_name = 'Library template Form One' + form_desc = 'This is Form One' + form_type = galaxy.model.FormDefinition.types.LIBRARY_INFO_TEMPLATE + self.create_form( name=form_name, desc=form_desc, formtype=form_type ) global form_one - form_one = current_form.latest_form + form_one = None + fdcs = galaxy.model.FormDefinitionCurrent.filter( galaxy.model.FormDefinitionCurrent.table.c.deleted==False ) \ + .order_by( galaxy.model.FormDefinitionCurrent.table.c.create_time.desc() ) \ + .all() + for fdc in fdcs: + if form_name == fdc.latest_form.name: + form_one = fdc.latest_form + break + assert form_one is not None, 'Problem retrieving form named (%s) from the database' % form_name # Add a new information template to the library template_name = 'Library Template 1' self.add_library_info_template( str( library_one.id ), @@ -491,32 +499,46 @@ str( form_one.id ), form_one.name ) # Make sure the template fields are displayed on the library information page - self.home() + field_dict = form_one.fields[ 0 ] + global form_one_field_label + form_one_field_label = '%s' % str( field_dict.get( 'label', 'Field 0' ) ) + global form_one_field_help + form_one_field_help = '%s' % str( field_dict.get( 'helptext', 'Field 0 help' ) ) + global form_one_field_required + form_one_field_required = '%s' % str( field_dict.get( 'required', 'optional' ) ).capitalize() + # Add information to the library using the template + global form_one_field_name + form_one_field_name = 'field_0' + contents = '%s library contents' % form_one_field_label self.visit_url( '%s/library_admin/library?id=%s&information=True' % ( self.url, str( library_one.id ) ) ) - num_fields = len( form_one.fields ) - for index in range( num_fields ): - label_check_str = form_one.fields[ index ][ 'label' ] - help_check_str = form_one.fields[ index ][ 'helptext' ] - required_check_str = form_one.fields[ index ][ 'required' ].capitalize() - self.check_page_for_string( label_check_str ) - self.check_page_for_string( help_check_str ) - self.check_page_for_string( required_check_str ) - # Add information to the library using the template - for index in range( num_fields ): - field_name = 'field_%i' % index - contents = '%s contents' % form_one.fields[ index ][ 'label' ] - # There are 2 forms on this page and the template is the 2nd form - tc.fv( '2', field_name, contents ) + # There are 2 forms on this page and the template is the 2nd form + tc.fv( '2', form_one_field_name, contents ) tc.submit( 'edit_info_button' ) - self.check_page_for_string ( 'The information has been updated.' ) - self.home() - # TODO: add more testing for full feature coverage - """ - def test_080_add_public_dataset_to_root_folder( self ): - """Testing adding a public dataset to the root folder""" + # For some reason, the following check: + # self.check_page_for_string ( 'The information has been updated.' ) + # ...throws the following exception - I have not idea why! + # self.check_page_for_string ( 'The information has been updated.' ) + # TypeError: 'str' object is not callable + # The work-around is to not make ANY self.check_page_for_string() calls until the next method + def test_080_edit_template_contents_admin_view( self ): + """Test editing template contents on the admin side""" + # First make sure the templlate contents from the previous method were correctly saved + contents = '%s library contents' % form_one_field_label + contents_edited = contents + ' edited' + self.visit_url( '%s/library_admin/library?id=%s&information=True' % ( self.url, str( library_one.id ) ) ) + self.check_page_for_string( contents ) + # Edit the contents and then save them + tc.fv( '2', form_one_field_name, contents_edited ) + tc.submit( 'edit_info_button' ) + self.check_page_for_string( 'The information has been updated.' ) + self.check_page_for_string( contents_edited ) + def test_085_add_public_dataset_to_root_folder( self ): + """Testing adding a public dataset to the root folder, making sure library template is inherited""" actions = [ v.action for k, v in galaxy.model.Library.permitted_actions.items() ] actions.sort() 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', str( library_one.id ), str( library_one.root_folder.id ), @@ -524,7 +546,9 @@ file_format='bed', dbkey='hg18', message=message.replace( ' ', '+' ), - root=True ) + root=True, + template_field_name1=form_one_field_name, + template_field_contents1=template_contents ) global ldda_one ldda_one = galaxy.model.LibraryDatasetDatasetAssociation.query() \ .order_by( desc( galaxy.model.LibraryDatasetDatasetAssociation.table.c.create_time ) ).first() @@ -550,17 +574,11 @@ if not dp.action == galaxy.model.Dataset.permitted_actions.DATASET_MANAGE_PERMISSIONS.action: raise AssertionError( 'The DatasetPermissions.action for dataset id %d is "%s", but it should be "manage permissions"' \ % ( ldda_one.dataset.id, dp.action ) ) - ## TODO: temporarily eliminating templates until we have the new forms features done - # Make sure the library template was inherited by the ldda - """ + # Make sure the library template contents were correctly saved self.home() self.visit_url( "%s/library_admin/library_dataset_dataset_association?edit_info=True&library_id=%s&folder_id=%s&id=%s" % \ ( self.url, str( library_one.id ), str( library_one.root_folder.id ), str( ldda_one.id ) ) ) - self.check_page_for_string( 'wind' ) - self.check_page_for_string( 'This is the wind component' ) - self.check_page_for_string( 'bag' ) - self.check_page_for_string( 'This is the bag component' ) - """ + self.check_page_for_string( template_contents ) # Make sure other users can access the dataset from the Libraries view self.logout() self.login( email=regular_user2.email ) @@ -570,23 +588,6 @@ self.logout() self.login( email=admin_user.email ) self.home() - """ - ## TODO: temporarily eliminating templates until we have the new forms features done - def test_085_editing_dataset_information( self ): - Testing editing dataset template element information - # Need the current library_item_info_element.id - last_library_item_info_element = galaxy.model.LibraryItemInfoElement.query() \ - .order_by( desc( galaxy.model.LibraryItemInfoElement.table.c.id ) ).first() - global ldda_one_ele_2_field_name - ldda_one_ele_2_field_name = "info_element_%s" % str( last_library_item_info_element.id ) - ele_2_contents = 'pipe' - global ldda_one_ele_1_field_name - ldda_one_ele_1_field_name = "info_element_%s" % ( str( last_library_item_info_element.id - 1 ) ) - ele_1_contents = 'blown' - self.edit_ldda_template_element_info( str( library_one.id ), str( library_one.root_folder.id ), str( ldda_one.id ), - ldda_one.name, ldda_one_ele_1_field_name, ele_1_contents, ldda_one_ele_2_field_name, ele_2_contents ) - self.home() - """ def test_090_add_new_folder_to_root_folder( self ): """Testing adding a folder to a library root folder""" root_folder = library_one.root_folder @@ -602,42 +603,25 @@ self.visit_url( '%s/library_admin/browse_library?id=%s' % ( self.url, str( library_one.id ) ) ) self.check_page_for_string( name ) self.check_page_for_string( description ) - ## TODO: temporarily eliminating templates until we have the new forms features done - # Make sure the library template is inherited - """ self.home() self.visit_url( '%s/library_admin/folder?id=%s&library_id=%s&information=True' % ( self.url, str( folder_one.id ), str( library_one.id ) ) ) - self.check_page_for_string( 'wind' ) - self.check_page_for_string( 'This is the wind component' ) - self.check_page_for_string( 'bag' ) - self.check_page_for_string( 'This is the bag component' ) - """ - self.home() - """ - ## TODO: temporarily eliminating templates until we have the new forms features done - def test_095_add_folder_template( self ): - Testing adding a new folder template to a folder - # Add a new information template to the folder - template_name = 'Folder Template 1' - ele_name_0 = 'Fu' - ele_help_0 = 'This is the Fu component'.replace( ' ', '+' ) - ele_name_1 = 'Bar' - ele_help_1 = 'This is the Bar component'.replace( ' ', '+' ) - self.home() - self.add_folder_info_template( str( library_one.id ), library_one.name, str( folder_one.id ), folder_one.name, - name=template_name, num_fields='2', ele_name_0=ele_name_0, ele_help_0=ele_help_0, - ele_name_1=ele_name_1, ele_help_1=ele_help_1 ) - self.home() - self.visit_url( '%s/library_admin/folder?id=%s&library_id=%s&information=True' % ( self.url, str( folder_one.id ), str( library_one.id ) ) ) - self.check_page_for_string( ele_name_0 ) - check_str = ele_help_0.replace( '+', ' ' ) - self.check_page_for_string( check_str ) - self.check_page_for_string( ele_name_1 ) - check_str = ele_help_1.replace( '+', ' ' ) - self.check_page_for_string( check_str ) - self.home() - """ - def test_100_add_subfolder_to_folder( self ): + # Make sure the template was inherited + self.check_page_for_string( form_one_field_name ) + # Make sure the template contents were NOT inherited + contents = '%s library contents' % form_one_field_label + try: + self.check_page_for_string( contents ) + raise AssertionError, "Library level template contents were displayed in the folders inherited template fields" + except: + pass + # Add contents to the inherited template + template_contents = "%s contents for Folder One" % form_one_field_label + # There are 2 forms on this page and the template is the 2nd form + tc.fv( '2', form_one_field_name, template_contents ) + tc.submit( 'edit_info_button' ) + self.check_page_for_string( 'The information has been updated.' ) + self.check_page_for_string( template_contents ) + def test_095_add_subfolder_to_folder( self ): """Testing adding a folder to a library folder""" name = "Folder One's Subfolder" description = "This is the Folder One's subfolder" @@ -651,101 +635,25 @@ self.visit_url( '%s/library_admin/browse_library?id=%s' % ( self.url, str( library_one.id ) ) ) self.check_page_for_string( name ) self.check_page_for_string( description ) - ## TODO: temporarily eliminating templates until we have the new forms features done - # Make sure the parent folder's template is inherited self.home() - """ - self.visit_url( '%s/library_admin/folder?id=%s&library_id=%s&information=True' % ( self.url, str( folder_one.id ), str( library_one.id ) ) ) - self.check_page_for_string( 'Fu' ) - self.check_page_for_string( 'This is the Fu component' ) - self.check_page_for_string( 'Bar' ) - self.check_page_for_string( 'This is the Bar component' ) - # Make sure the library template is not inherited + self.visit_url( '%s/library_admin/folder?id=%s&library_id=%s&information=True' % ( self.url, str( subfolder_one.id ), str( library_one.id ) ) ) + # Make sure the template was inherited + self.check_page_for_string( form_one_field_name ) + # Make sure the template contents were NOT inherited + contents = "%s contents for Folder One" % form_one_field_label try: - self.check_page_for_string( 'wind' ) - raise AssertionError( 'Library template inherited by folder when it should not have been.' ) + self.check_page_for_string( contents ) + raise AssertionError, "Parent folder level template contents were displayed in the sub-folders inherited template fields" except: pass - self.home() - """ - ## TODO: temporarily eliminating templates until we have the new forms features done - """ - 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' - 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 ) - # Make sure the new template element shows up on the existing library info page - self.home() - self.visit_url( '%s/library_admin/library?id=%s&information=True' % ( self.url, str( library_one.id ) ) ) - self.check_page_for_string( library_one.name ) - self.check_page_for_string( library_one.description ) - self.check_page_for_string( 'wind' ) - self.check_page_for_string( 'hello' ) - self.check_page_for_string( 'This is the wind component' ) - self.check_page_for_string( 'bag' ) - self.check_page_for_string( 'world' ) - self.check_page_for_string( 'This is the bag component' ) - self.check_page_for_string( 'Fubar' ) - self.check_page_for_string( 'This is the Fubar component' ) - # Make sure the new template element does not show up on existing info pages for folder_one since it has its own template - self.home() - self.visit_url( '%s/library_admin/folder?id=%s&library_id=%s&information=True' % ( self.url, str( folder_one.id ), str( library_one.id ) ) ) - self.check_page_for_string( 'Fu' ) - self.check_page_for_string( 'This is the Fu component' ) - self.check_page_for_string( 'Bar' ) - self.check_page_for_string( 'This is the Bar component' ) - try: - self.check_page_for_string( 'Fubar' ) - raise AssertionError( 'Changed library template inherited by folder "%s" when folder had an associated template of its own' ) - except: - pass - # Make sure the new template element shows up on existing info pages for ldda_one since it is contained in the root folder - self.home() - self.visit_url( "%s/library_admin/library_dataset_dataset_association?edit_info=True&library_id=%s&folder_id=%s&id=%s" % \ - ( self.url, str( library_one.id ), str( folder_one.id ), str( ldda_one.id ) ) ) - # Visiting the above page will have resulted in the creation of a new LibraryItemInfoElement, so we'll retrieve it - # for later use - last_library_item_info_element = galaxy.model.LibraryItemInfoElement.query() \ - .order_by( desc( galaxy.model.LibraryItemInfoElement.table.c.id ) ).first() - global ldda_one_ele_3_field_name - ldda_one_ele_3_field_name = "info_element_%s" % str( last_library_item_info_element.id ) - self.check_page_for_string( 'wind' ) - self.check_page_for_string( 'This is the wind component' ) - self.check_page_for_string( 'bag' ) - self.check_page_for_string( 'This is the bag component' ) - self.check_page_for_string( 'Fubar' ) - self.check_page_for_string( 'This is the Fubar component' ) - self.home() - """ - def test_110_add_2nd_new_folder_to_root_folder( self ): + # Add contents to the inherited template + template_contents = "%s contents for Folder One's Subfolder" % form_one_field_label + # There are 2 forms on this page and the template is the 2nd form + tc.fv( '2', form_one_field_name, template_contents ) + tc.submit( 'edit_info_button' ) + self.check_page_for_string( 'The information has been updated.' ) + self.check_page_for_string( template_contents ) + def test_100_add_2nd_new_folder_to_root_folder( self ): """Testing adding a 2nd folder to a library root folder""" root_folder = library_one.root_folder name = "Folder Two" @@ -760,24 +668,24 @@ self.visit_url( '%s/library_admin/browse_library?id=%s' % ( self.url, str( library_one.id ) ) ) self.check_page_for_string( name ) self.check_page_for_string( description ) - ## TODO: temporarily eliminating templates until we have the new forms features done - # Make sure the changed library template is inherited to the new folder - """ self.home() - self.visit_url( '%s/library_admin/folder?id=%s&library_id=%s&information=True' % ( self.url, str( folder_two.id ), str( library_one.id ) ) ) - self.check_page_for_string( 'wind' ) - self.check_page_for_string( 'This is the wind component' ) - self.check_page_for_string( 'bag' ) - self.check_page_for_string( 'This is the bag component' ) - self.check_page_for_string( 'Fubar' ) - self.check_page_for_string( 'This is the Fubar component' ) - """ - self.home() - def test_115_add_public_dataset_to_root_folders_2nd_subfolder( self ): + self.visit_url( '%s/library_admin/folder?id=%s&library_id=%s&information=True' % ( self.url, str( subfolder_one.id ), str( library_one.id ) ) ) + # Make sure the template was inherited + self.check_page_for_string( form_one_field_name ) + # Make sure the template contents were NOT inherited + contents = '%s library contents' % form_one_field_label + try: + self.check_page_for_string( contents ) + raise AssertionError, "Parent folder level template contents were displayed in the sub-folders inherited template fields" + except: + pass + def test_105_add_public_dataset_to_root_folders_2nd_subfolder( self ): """Testing adding a public dataset to the root folder's 2nd sub-folder""" actions = [ v.action for k, v in galaxy.model.Library.permitted_actions.items() ] actions.sort() 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', str( library_one.id ), str( folder_two.id ), @@ -785,7 +693,9 @@ file_format='bed', dbkey='hg18', message=message.replace( ' ', '+' ), - root=False ) + root=False, + template_field_name1=form_one_field_name, + template_field_contents1=template_contents ) global ldda_two ldda_two = galaxy.model.LibraryDatasetDatasetAssociation.query() \ .order_by( desc( galaxy.model.LibraryDatasetDatasetAssociation.table.c.create_time ) ).first() @@ -795,64 +705,18 @@ self.check_page_for_string( "2.bed" ) self.check_page_for_string( message ) self.check_page_for_string( admin_user.email ) - ## TODO: temporarily eliminating templates until we have the new forms features done - """ - def test_120_add_template_to_root_folders_2nd_subfolder( self ): - Testing adding a template to the root folder's 2nd sub-folder - # Before adding the folder template, the inherited library template should be displayed - self.home() - self.visit_url( "%s/library_admin/library_dataset_dataset_association?edit_info=True&library_id=%s&folder_id=%s&id=%s" % \ - ( self.url, str( library_one.id ), str( folder_two.id ), str( ldda_two.id ) ) ) - self.check_page_for_string( 'wind' ) - self.check_page_for_string( 'This is the wind component' ) - self.check_page_for_string( 'bag' ) - self.check_page_for_string( 'This is the bag component' ) - self.check_page_for_string( 'Fubar' ) - self.check_page_for_string( 'This is the Fubar component' ) - self.home() - # Add a new folde template - template_name = 'Folder 2 Template' - ele_name_0 = 'kill' - ele_help_0 = 'This is the kill component'.replace( ' ', '+' ) - ele_name_1 = 'bill' - ele_help_1 = 'This is the bill component'.replace( ' ', '+' ) - self.home() - self.add_folder_info_template( str( library_one.id ), library_one.name, str( folder_two.id ), folder_two.name, - name=template_name, num_fields='2', ele_name_0=ele_name_0, ele_help_0=ele_help_0, - ele_name_1=ele_name_1, ele_help_1=ele_help_1 ) - # Make sure the new template id displayed on the folder information page - self.home() - self.visit_url( '%s/library_admin/folder?id=%s&library_id=%s&information=True' % ( self.url, str( folder_two.id ), str( library_one.id ) ) ) - self.check_page_for_string( ele_name_0 ) - check_str = ele_help_0.replace( '+', ' ' ) - self.check_page_for_string( check_str ) - self.check_page_for_string( ele_name_1 ) - check_str = ele_help_1.replace( '+', ' ' ) - self.check_page_for_string( check_str ) - # The library dataset ldda_two had previously inherited the library template prior to the new folder template - # being introduced, so the library template should still be displayed on the ldda information page - self.home() - self.visit_url( "%s/library_admin/library_dataset_dataset_association?edit_info=True&library_id=%s&folder_id=%s&id=%s" % \ - ( self.url, str( library_one.id ), str( folder_two.id ), str( ldda_two.id ) ) ) - self.check_page_for_string( 'wind' ) - self.check_page_for_string( 'This is the wind component' ) - self.check_page_for_string( 'bag' ) - self.check_page_for_string( 'This is the bag component' ) - self.check_page_for_string( 'Fubar' ) - self.check_page_for_string( 'This is the Fubar component' ) - # Make sure the new folder template is not displayed - try: - self.check_page_for_string( 'kill' ) - raise AssertionError( 'New folder template elements incorrectly included in information page for ldda "%s"' % ldda_two.name ) - except: - pass - self.home() - """ - def test_125_add_2nd_public_dataset_to_root_folders_2nd_subfolder( self ): + # Make sure the library template contents were correctly saved + self.home() + self.visit_url( "%s/library_admin/library_dataset_dataset_association?edit_info=True&library_id=%s&folder_id=%s&id=%s" % \ + ( self.url, str( library_one.id ), str( folder_two.id ), str( ldda_two.id ) ) ) + self.check_page_for_string( template_contents ) + def test_110_add_2nd_public_dataset_to_root_folders_2nd_subfolder( self ): """Testing adding a 2nd public dataset to the root folder's 2nd sub-folder""" actions = [ v.action for k, v in galaxy.model.Library.permitted_actions.items() ] actions.sort() 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', str( library_one.id ), str( folder_two.id ), @@ -860,7 +724,9 @@ file_format='bed', dbkey='hg18', message=message.replace( ' ', '+' ), - root=False ) + root=False, + template_field_name1=form_one_field_name, + template_field_contents1=template_contents ) global ldda_three ldda_three = galaxy.model.LibraryDatasetDatasetAssociation.query() \ .order_by( desc( galaxy.model.LibraryDatasetDatasetAssociation.table.c.create_time ) ).first() @@ -870,26 +736,12 @@ self.check_page_for_string( "3.bed" ) self.check_page_for_string( message ) self.check_page_for_string( admin_user.email ) - ## TODO: temporarily eliminating templates until we have the new forms features done - """ - def test_130_editing_dataset_information_with_new_folder_template( self ): - Testing editing dataset template element information with new inherited folder template - # Need the current library_item_info_element.id - last_library_item_info_element = galaxy.model.LibraryItemInfoElement.query() \ - .order_by( desc( galaxy.model.LibraryItemInfoElement.table.c.id ) ).first() - # Make sure the changed inherited template is included in the ldda information - ele_2_field_name = "info_element_%s" % str( last_library_item_info_element.id ) - ele_2_contents = 'II' - ele_2_help = 'This is the bill component' - ele_1_field_name = "info_element_%s" % ( str( last_library_item_info_element.id - 1 ) ) - ele_1_contents = 'Volume' - ele_1_help = 'This is the kill component' - self.edit_ldda_template_element_info( str( library_one.id ), str( folder_two.id ), str( ldda_three.id ), - ldda_three.name, ele_1_field_name, ele_1_contents, ele_2_field_name, ele_2_contents, - ele_1_help=ele_1_help, ele_2_help=ele_2_help ) - self.home() - """ - def test_135_add_dataset_with_private_role_restriction_to_folder( self ): + # Make sure the library template contents were correctly saved + self.home() + self.visit_url( "%s/library_admin/library_dataset_dataset_association?edit_info=True&library_id=%s&folder_id=%s&id=%s" % \ + ( self.url, str( library_one.id ), str( folder_two.id ), str( ldda_three.id ) ) ) + self.check_page_for_string( template_contents ) + def test_115_add_dataset_with_private_role_restriction_to_folder( self ): """Testing adding a dataset with a private role restriction to a folder""" # Add a dataset restricted by the following: # DATASET_MANAGE_PERMISSIONS = "test@bx.psu.edu" via DefaultUserPermissions @@ -905,10 +757,8 @@ # setting is useless if test@bx.psu.edu is not an admin. This should be corrected, # by displaying a warning message on the permissions form. message ='This is a test of the fourth dataset uploaded' - ele_name_0 = 'Fu' - ele_name_1 = 'Bar' - ## TODO: temporarily eliminating templates until we have the new forms features done - """ + # 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', str( library_one.id ), str( folder_one.id ), @@ -918,18 +768,8 @@ roles=[ str( regular_user1_private_role.id ) ], message=message.replace( ' ', '+' ), root=False, - check_template_str1=ele_name_0, - check_template_str2=ele_name_1 ) - """ - self.add_library_dataset( '4.bed', - str( library_one.id ), - str( folder_one.id ), - folder_one.name, - file_format='bed', - dbkey='hg18', - roles=[ str( regular_user1_private_role.id ) ], - message=message.replace( ' ', '+' ), - root=False ) + template_field_name1=form_one_field_name, + template_field_contents1=template_contents ) global ldda_four ldda_four = galaxy.model.LibraryDatasetDatasetAssociation.query() \ .order_by( desc( galaxy.model.LibraryDatasetDatasetAssociation.table.c.create_time ) ).first() @@ -940,7 +780,12 @@ self.check_page_for_string( message ) self.check_page_for_string( admin_user.email ) self.home() - def test_140_accessing_dataset_with_private_role_restriction( self ): + # Make sure the library template contents were correctly saved + self.home() + self.visit_url( "%s/library_admin/library_dataset_dataset_association?edit_info=True&library_id=%s&folder_id=%s&id=%s" % \ + ( self.url, str( library_one.id ), str( folder_one.id ), str( ldda_four.id ) ) ) + self.check_page_for_string( template_contents ) + def test_120_accessing_dataset_with_private_role_restriction( self ): """Testing accessing a dataset with a private role restriction""" # admin_user should not be able to see 2.bed from the analysis view's access libraries self.home() @@ -998,7 +843,7 @@ self.logout() self.login( email=admin_user.email ) self.home() - def test_145_change_dataset_access_permission( self ): + def test_125_change_dataset_access_permission( self ): """Testing changing the access permission on a dataset with a private role restriction""" # We need admin_user to be able to access 2.bed permissions_in = [ k for k, v in galaxy.model.Dataset.permitted_actions.items() ] + \ @@ -1012,41 +857,15 @@ self.visit_url( '%s/library/browse_library?id=%s' % ( self.url, str( library_one.id ) ) ) self.check_page_for_string( ldda_four.name ) self.home() - ## TODO: temporarily eliminating templates until we have the new forms features done - """ - def test_150_editing_restricted_datasets_information( self ): - Testing editing a restricted library dataset's template element information - ele_1_contents = '' - ele_2_contents = '' - ele_3_contents = 'Adding Fubar text' - self.edit_ldda_template_element_info( str( library_one.id ), str( library_one.root_folder.id ), str( ldda_one.id ), - ldda_one.name, ldda_one_ele_1_field_name, ele_1_contents, ldda_one_ele_2_field_name, ele_2_contents, - ele_1_help='This is the wind component'.replace( ' ', '+' ), - ele_2_help='This is the bag component'.replace( ' ', '+' ), - ele_3_field_name=ldda_one_ele_3_field_name, ele_3_contents=ele_3_contents.replace( ' ', '+' ) ) - # Check the updated information from the libraries view - self.home() - self.visit_url( '%s/library/library_dataset_dataset_association?info=True&library_id=%s&folder_id=%s&id=%s' \ - % ( self.url, str( library_one.id ), str( library_one.root_folder.id ), str( ldda_one.id ) ) ) - self.check_page_for_string( ele_3_contents ) - try: - self.check_page_for_string( 'blown' ) - raise AssertionError( 'Element contents were not correctly eliminated when the information was edited for ldda %s' % ldda_one.name) - except: - pass - self.home() - """ - def test_155_add_dataset_with_role_associated_with_group_and_users( self ): + def test_130_add_dataset_with_role_associated_with_group_and_users( self ): """Testing adding a dataset with a role that is associated with a group and users""" self.login( email='test@bx.psu.edu' ) # Add a dataset restricted by role_two, which is currently associated as follows: # groups: group_two # users: test@bx.psu.edu, test1@bx.psu.edu via group_two message = 'Testing adding a dataset with a role that is associated with a group and users' - ele_name_0 = 'Fu' - ele_name_1 = 'Bar' - ## TODO: temporarily eliminating templates until we have the new forms features done - """ + # 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', str( library_one.id ), str( folder_one.id ), @@ -1056,18 +875,8 @@ roles=[ str( role_two.id ) ], message=message.replace( ' ', '+' ), root=False, - check_template_str1=ele_name_0, - check_template_str2=ele_name_1 ) - """ - self.add_library_dataset( '5.bed', - str( library_one.id ), - str( folder_one.id ), - folder_one.name, - file_format='bed', - dbkey='hg17', - roles=[ str( role_two.id ) ], - message=message.replace( ' ', '+' ), - root=False ) + template_field_name1=form_one_field_name, + template_field_contents1=template_contents ) global ldda_five ldda_five = galaxy.model.LibraryDatasetDatasetAssociation.query() \ .order_by( desc( galaxy.model.LibraryDatasetDatasetAssociation.table.c.create_time ) ).first() @@ -1078,7 +887,12 @@ self.check_page_for_string( message ) self.check_page_for_string( admin_user.email ) self.home() - def test_160_accessing_dataset_with_role_associated_with_group_and_users( self ): + # Make sure the library template contents were correctly saved + self.home() + self.visit_url( "%s/library_admin/library_dataset_dataset_association?edit_info=True&library_id=%s&folder_id=%s&id=%s" % \ + ( self.url, str( library_one.id ), str( folder_one.id ), str( ldda_five.id ) ) ) + self.check_page_for_string( template_contents ) + def test_135_accessing_dataset_with_role_associated_with_group_and_users( self ): """Testing accessing a dataset with a role that is associated with a group and users""" # admin_user should be able to see 5.bed since she is associated with role_two self.home() @@ -1152,7 +966,7 @@ pass self.logout() self.login( email='test@bx.psu.edu' ) - def test_165_copy_dataset_from_history_to_subfolder( self ): + def test_140_copy_dataset_from_history_to_subfolder( self ): """Testing copying a dataset from the current history to a subfolder""" self.new_history() self.upload_file( "6.bed" ) @@ -1173,18 +987,19 @@ ldda_six = galaxy.model.LibraryDatasetDatasetAssociation.query() \ .order_by( desc( galaxy.model.LibraryDatasetDatasetAssociation.table.c.create_time ) ).first() assert ldda_six is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda_six from the database' + self.home() # Make sure the correct template was inherited - ## TODO: temporarily eliminating templates until we have the new forms features done - self.home() - """ - self.visit_url( "%s/library_admin/library_dataset_dataset_association?edit_info=True&library_id=%s&folder_id=%s&id=%s" % \ - ( self.url, str( library_one.id ), str( subfolder_one.id ), str( ldda_six.id ) ) ) - self.check_page_for_string( 'Fu' ) - self.check_page_for_string( 'This is the Fu component' ) - self.check_page_for_string( 'Bar' ) - self.check_page_for_string( 'This is the Bar component' ) - """ - def test_170_editing_dataset_attribute_info( self ): + self.visit_url( '%s/library/library_dataset_dataset_association?edit_info=True&library_id=%s&folder_id=%s&id=%s' \ + % ( self.url, str( library_one.id ), str( subfolder_one.id ), str( ldda_six.id ) ) ) + self.check_page_for_string( form_one_field_name ) + # Make sure the template contents were NOT inherited + contents = "%s contents for Folder One's Subfolder" % form_one_field_label + try: + self.check_page_for_string( contents ) + raise AssertionError, "Parent folder template contents were displayed in the sub-folders inherited template fields" + except: + pass + def test_145_editing_dataset_attribute_info( self ): """Testing editing a datasets attribute information""" new_ldda_name = '6.bed ( version 1 )' self.edit_ldda_attribute_info( str( library_one.id ), str( subfolder_one.id ), str( ldda_six.id ), ldda_six.name, new_ldda_name ) @@ -1193,11 +1008,21 @@ self.visit_url( '%s/library_admin/browse_library?id=%s' % ( self.url, str( library_one.id ) ) ) self.check_page_for_string( ldda_six.name ) self.home() - def test_175_uploading_new_dataset_version( self ): + # Make sure the template contents were NOT inherited + self.visit_url( '%s/library/library_dataset_dataset_association?edit_info=True&library_id=%s&folder_id=%s&id=%s' \ + % ( self.url, str( library_one.id ), str( subfolder_one.id ), str( ldda_six.id ) ) ) + self.check_page_for_string( form_one_field_name ) + contents = "%s contents for Folder One's Subfolder" % form_one_field_label + try: + self.check_page_for_string( contents ) + raise AssertionError, "Parent folder template contents were displayed in the sub-folders inherited template fields" + except: + pass + def test_150_uploading_new_dataset_version( self ): """Testing uploading a new version of a dataset""" message = 'Testing uploading a new version of a dataset' - ## TODO: temporarily eliminating templates until we have the new forms features done - """ + # The form_one template should be inherited to the library dataset upload form. + template_contents = "%s contents for %s new version of 6.bed" % ( form_one_field_label, folder_one.name ) self.upload_new_dataset_version( '6.bed', str( library_one.id ), str( subfolder_one.id ), @@ -1207,39 +1032,31 @@ file_format='auto', dbkey='hg18', message=message.replace( ' ', '+' ), - check_template_str1='Fu', - check_template_str2='Bar' ) - """ - self.upload_new_dataset_version( '6.bed', - str( library_one.id ), - str( subfolder_one.id ), - str( subfolder_one.name ), - str( ldda_six.library_dataset.id ), - ldda_six.name, - file_format='auto', - dbkey='hg18', - message=message.replace( ' ', '+' ) ) + template_field_name1=form_one_field_name, + template_field_contents1=template_contents ) global ldda_six_version_two ldda_six_version_two = galaxy.model.LibraryDatasetDatasetAssociation.query() \ .order_by( desc( galaxy.model.LibraryDatasetDatasetAssociation.table.c.create_time ) ).first() assert ldda_six_version_two is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda_six_version_two from the database' self.home() - self.visit_url( "%s/library_admin/library_dataset_dataset_association?info=True&library_id=%s&folder_id=%s&id=%s" % \ + self.visit_url( "%s/library_admin/library_dataset_dataset_association?edit_info=True&library_id=%s&folder_id=%s&id=%s" % \ ( self.url, str( library_one.id ), str( subfolder_one.id ), str( ldda_six_version_two.id ) ) ) self.check_page_for_string( 'This is the latest version of this library dataset' ) # Make sure the correct template was inherited - ## TODO: temporarily eliminating templates until we have the new forms features done - """ - self.check_page_for_string( 'Fu' ) - self.check_page_for_string( 'This is the Fu component' ) - self.check_page_for_string( 'Bar' ) - self.check_page_for_string( 'This is the Bar component' ) - check_str = 'Expired versions of %s' % ldda_six_version_two.name - self.check_page_for_string( check_str ) - self.check_page_for_string( ldda_six.name ) - """ - self.home() - # Make sure th permissions are the same + self.check_page_for_string( template_contents ) + # Make sure it does not include any inherited contents + contents = "%s contents for Folder One's Subfolder" % form_one_field_label + try: + self.check_page_for_string( contents ) + raise AssertionError, "Parent folder template contents were displayed in the sub-folders inherited template fields" + except: + pass + # There are 4 forms on this page and the template is the 4th form + tc.fv( '4', form_one_field_name, template_contents ) + tc.submit( 'edit_info_button' ) + self.check_page_for_string( 'The information has been updated.' ) + self.check_page_for_string( template_contents ) + # Make sure the permissions are the same ldda_six.refresh() if len( ldda_six.actions ) != len( ldda_six_version_two.actions ): raise AssertionError( 'ldda "%s" actions "%s" != ldda "%s" actions "%s"' \ @@ -1256,47 +1073,55 @@ ( self.url, str( library_one.id ), str( subfolder_one.id ), str( ldda_six.id ) ) ) self.check_page_for_string( 'This is an expired version of this library dataset' ) self.home() - def test_180_uploading_new_dataset_versions( self ): + # Make sure ldda_six is no longer displayed in the library + self.visit_url( '%s/library_admin/browse_library?id=%s' % ( self.url, str( library_one.id ) ) ) + try: + self.check_page_for_string( ldda_six.name ) + raise AssertionError, "Old version of library dataset %s is displayed in library" % ldda_six.name + except: + pass + self.home() + def test_155_uploading_new_dataset_versions( self ): """Testing uploading new versions of a dataset using a directory of files""" message = 'Testing uploading new versions of a dataset using a directory of files' + # The form_one template should be inherited to the library dataset upload form. + template_contents = "%s contents for %s 5th new version of 6.bed" % ( form_one_field_label, folder_one.name ) ldda_six_version_two.refresh() - ## TODO: temporarily eliminating templates until we have the new forms features done - """ - self.upload_new_dataset_versions( str( library_one.id ), - str( subfolder_one.id ), - str( subfolder_one.name ), - str( ldda_six_version_two.library_dataset.id ), - ldda_six_version_two.name, - file_format='auto', - dbkey='hg18', - message=message.replace( ' ', '+' ), - check_template_str1='Fu', - check_template_str2='Bar' ) - """ - self.upload_new_dataset_versions( str( library_one.id ), - str( subfolder_one.id ), - str( subfolder_one.name ), - str( ldda_six_version_two.library_dataset.id ), - ldda_six_version_two.name, - file_format='auto', - dbkey='hg18', - message=message.replace( ' ', '+' ) ) + self.upload_new_dataset_version( '6.bed', + str( library_one.id ), + str( subfolder_one.id ), + str( subfolder_one.name ), + str( ldda_six_version_two.library_dataset.id ), + ldda_six_version_two.name, + file_format='auto', + dbkey='hg18', + message=message.replace( ' ', '+' ), + template_field_name1=form_one_field_name, + template_field_contents1=template_contents ) global ldda_six_version_five ldda_six_version_five = galaxy.model.LibraryDatasetDatasetAssociation.query() \ .order_by( desc( galaxy.model.LibraryDatasetDatasetAssociation.table.c.create_time ) ).first() assert ldda_six_version_five is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda_six_version_five from the database' self.home() - self.visit_url( "%s/library_admin/library_dataset_dataset_association?info=True&library_id=%s&folder_id=%s&id=%s" % \ + self.visit_url( "%s/library_admin/library_dataset_dataset_association?edit_info=True&library_id=%s&folder_id=%s&id=%s" % \ ( self.url, str( library_one.id ), str( subfolder_one.id ), str( ldda_six_version_five.id ) ) ) self.check_page_for_string( 'This is the latest version of this library dataset' ) # Make sure the correct template was inherited - ## TODO: temporarily eliminating templates until we have the new forms features done - """ - self.check_page_for_string( 'Fu' ) - self.check_page_for_string( 'This is the Fu component' ) - self.check_page_for_string( 'Bar' ) - self.check_page_for_string( 'This is the Bar component' ) - """ + self.check_page_for_string( template_contents ) + # Make sure it does not include any inherited contents + contents = "%s contents for Folder One's Subfolder" % form_one_field_label + try: + self.check_page_for_string( contents ) + raise AssertionError, "Parent folder template contents were displayed in the sub-folders inherited template fields" + except: + pass + # There are 4 forms on this page and the template is the 4th form + tc.fv( '4', form_one_field_name, template_contents ) + tc.submit( 'edit_info_button' ) + self.check_page_for_string( 'The information has been updated.' ) + self.check_page_for_string( template_contents ) + self.visit_url( "%s/library_admin/library_dataset_dataset_association?info=True&library_id=%s&folder_id=%s&id=%s" % \ + ( self.url, str( library_one.id ), str( subfolder_one.id ), str( ldda_six_version_five.id ) ) ) check_str = 'Expired versions of %s' % ldda_six_version_five.name self.check_page_for_string( check_str ) self.check_page_for_string( ldda_six.name ) @@ -1318,32 +1143,24 @@ ( self.url, str( library_one.id ), str( subfolder_one.id ), str( ldda_six_version_two.id ) ) ) self.check_page_for_string( 'This is an expired version of this library dataset' ) self.home() - def test_185_upload_directory_of_files_from_admin_view( self ): + def test_160_upload_directory_of_files_from_admin_view( self ): """Testing uploading a directory of files to a root folder from the Admin view""" message = 'This is a test for uploading a directory of files' + template_contents = "%s contents for directory of 3 datasets in %s" % ( form_one_field_label, folder_one.name ) roles_tuple = [ ( str( role_one.id ), role_one.name ) ] check_str = "Added 3 datasets to the library '%s' ( each is selected )." % library_one.root_folder.name - ## TODO: temporarily eliminating templates until we have the new forms features done - """ - self.add_dir_of_files_from_admin_view( str( library_one.id ), - str( library_one.root_folder.id ), - roles_tuple=roles_tuple, - message=message.replace( '+', ' ' ), - check_str=check_str, - check_template_str1='wind', - check_template_str2='bag', - check_template_str3='Fubar' ) - """ self.add_dir_of_files_from_admin_view( str( library_one.id ), str( library_one.root_folder.id ), roles_tuple=roles_tuple, - message=message.replace( '+', ' ' ) ) + message=message.replace( '+', ' ' ), + template_field_name1=form_one_field_name, + template_field_contents1=template_contents ) self.home() self.visit_page( 'library_admin/browse_library?id=%s' % ( str( library_one.id ) ) ) self.check_page_for_string( admin_user.email ) self.check_page_for_string( message ) self.home() - def test_190_change_permissions_on_datasets_uploaded_from_library_dir( self ): + def test_165_change_permissions_on_datasets_uploaded_from_library_dir( self ): """Testing changing the permissions on datasets uploaded from a directory""" # It would be nice if twill functioned such that the above test resulted in a # form with the uploaded datasets selected, but it does not ( they're not checked ), @@ -1451,7 +1268,7 @@ pass check_edit_page2( latest_3_lddas ) self.home() - def test_195_upload_directory_of_files_from_libraries_view( self ): + def test_170_upload_directory_of_files_from_libraries_view( self ): """Testing uploading a directory of files to a root folder from the Data Libraries view""" # admin_user will not have the option sto upload a directory of files from the # Libraries view since a sub-directory named the same as their email is not contained @@ -1483,7 +1300,6 @@ str( library_one.root_folder.id ), 'run1', check_str_after_submit=check_str_after_submit, - check_str1=check_str1, message=message.replace( '+', ' ' ) ) self.home() self.visit_page( 'library/browse_library?id=%s' % ( str( library_one.id ) ) ) @@ -1492,7 +1308,8 @@ self.home() self.logout() self.login( email=admin_user.email ) - def test_200_mark_group_deleted( self ): + + def test_175_mark_group_deleted( self ): """Testing marking a group as deleted""" self.home() self.visit_url( '%s/admin/groups' % self.url ) @@ -1506,13 +1323,13 @@ raise AssertionError( '%s incorrectly lost all members when it was marked as deleted.' % group_two.name ) if not group_two.roles: raise AssertionError( '%s incorrectly lost all role associations when it was marked as deleted.' % group_two.name ) - def test_205_undelete_group( self ): + def test_180_undelete_group( self ): """Testing undeleting a deleted group""" self.undelete_group( str( group_two.id ), group_two.name ) group_two.refresh() if group_two.deleted: raise AssertionError( '%s was not correctly marked as not deleted.' % group_two.name ) - def test_210_mark_role_deleted( self ): + def test_185_mark_role_deleted( self ): """Testing marking a role as deleted""" self.home() self.visit_url( '%s/admin/roles' % self.url ) @@ -1526,10 +1343,10 @@ raise AssertionError( '%s incorrectly lost all user associations when it was marked as deleted.' % role_two.name ) if not role_two.groups: raise AssertionError( '%s incorrectly lost all group associations when it was marked as deleted.' % role_two.name ) - def test_215_undelete_role( self ): + def test_190_undelete_role( self ): """Testing undeleting a deleted role""" self.undelete_role( str( role_two.id ), role_two.name ) - def test_220_mark_dataset_deleted( self ): + def test_195_mark_dataset_deleted( self ): """Testing marking a library dataset as deleted""" self.home() self.delete_library_item( str( library_one.id ), str( ldda_two.library_dataset.id ), ldda_two.name, library_item_type='library_dataset' ) @@ -1542,13 +1359,13 @@ except: pass self.home() - def test_225_display_deleted_dataset( self ): + def test_200_display_deleted_dataset( self ): """Testing displaying deleted dataset""" self.home() self.visit_url( "%s/library_admin/browse_library?id=%s&show_deleted=True" % ( self.url, str( library_one.id ) ) ) self.check_page_for_string( ldda_two.name ) self.home() - def test_230_hide_deleted_dataset( self ): + def test_205_hide_deleted_dataset( self ): """Testing hiding deleted dataset""" self.home() self.visit_url( "%s/library_admin/browse_library?id=%s&show_deleted=False" % ( self.url, str( library_one.id ) ) ) @@ -1558,7 +1375,7 @@ except: pass self.home() - def test_235_mark_folder_deleted( self ): + def test_210_mark_folder_deleted( self ): """Testing marking a library folder as deleted""" self.home() self.delete_library_item( str( library_one.id ), str( folder_two.id ), folder_two.name, library_item_type='folder' ) @@ -1570,7 +1387,7 @@ except: pass self.home() - def test_240_mark_folder_undeleted( self ): + def test_215_mark_folder_undeleted( self ): """Testing marking a library folder as undeleted""" self.home() self.undelete_library_item( str( library_one.id ), str( folder_two.id ), folder_two.name, library_item_type='folder' ) @@ -1585,7 +1402,7 @@ except: pass self.home() - def test_245_mark_library_deleted( self ): + def test_220_mark_library_deleted( self ): """Testing marking a library as deleted""" self.home() # First mark folder_two as deleted to further test state saving when we undelete the library @@ -1595,7 +1412,7 @@ self.visit_page( 'library_admin/deleted_libraries' ) self.check_page_for_string( library_one.name ) self.home() - def test_240_mark_library_undeleted( self ): + def test_225_mark_library_undeleted( self ): """Testing marking a library as undeleted""" self.home() self.undelete_library_item( str( library_one.id ), str( library_one.id ), library_one.name, library_item_type='library' ) @@ -1609,7 +1426,7 @@ except: pass self.home() - def test_250_purge_user( self ): + def test_230_purge_user( self ): """Testing purging a user account""" self.mark_user_deleted( user_id=self.security.encode_id( regular_user3.id ), email=regular_user3.email ) regular_user3.refresh() @@ -1641,7 +1458,7 @@ role = galaxy.model.Role.get( ura.role_id ) if role.type != 'private': raise AssertionError( 'UserRoleAssociations for user %s are not related with the private role.' % regular_user3.email ) - def test_255_manually_unpurge_user( self ): + def test_235_manually_unpurge_user( self ): """Testing manually un-purging a user account""" # Reset the user for later test runs. The user's private Role and DefaultUserPermissions for that role # should have been preserved, so all we need to do is reset purged and deleted. @@ -1649,7 +1466,7 @@ regular_user3.purged = False regular_user3.deleted = False regular_user3.flush() - def test_260_purge_group( self ): + def test_240_purge_group( self ): """Testing purging a group""" group_id = str( group_two.id ) self.mark_group_deleted( group_id, group_two.name ) @@ -1664,7 +1481,7 @@ raise AssertionError( "Purging the group did not delete the GroupRoleAssociations for group_id '%s'" % group_id ) # Undelete the group for later test runs self.undelete_group( group_id, group_two.name ) - def test_265_purge_role( self ): + def test_245_purge_role( self ): """Testing purging a role""" role_id = str( role_two.id ) self.mark_role_deleted( role_id, role_two.name ) @@ -1689,14 +1506,14 @@ dp = galaxy.model.DatasetPermissions.filter( galaxy.model.DatasetPermissions.table.c.role_id == role_id ).all() if dp: raise AssertionError( "Purging the role did not delete the DatasetPermissionss for role_id '%s'" % role_id ) - def test_270_manually_unpurge_role( self ): + def test_250_manually_unpurge_role( self ): """Testing manually un-purging a role""" # Manually unpurge, then undelete the role for later test runs # TODO: If we decide to implement the GUI feature for un-purging a role, replace this with a method call role_two.purged = False role_two.flush() self.undelete_role( str( role_two.id ), role_two.name ) - def test_275_purge_library( self ): + def test_255_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' ) @@ -1732,7 +1549,7 @@ raise AssertionError( 'The library_dataset id %s named "%s" has not been marked as deleted.' % \ ( str( library_dataset.id ), library_dataset.name ) ) check_folder( library_one.root_folder ) - def test_280_reset_data_for_later_test_runs( self ): + def test_260_reset_data_for_later_test_runs( self ): """Reseting data to enable later test runs to pass""" ################## # Eliminate all non-private roles
participants (1)
-
Greg Von Kuster