From 11957ed5fa6a3ea0ef51394578de9c0dbf79c5cc Mon Sep 17 00:00:00 2001 From: Greg Von Kuster Date: Wed, 15 Dec 2010 17:00:29 -0500 Subject: [PATCH] Fixed as many of the issues as could be found throughout the framework due to the migration of FormValues.content from a list to a dictionary in change set 4744 b73ad3906e24. --- lib/galaxy/model/__init__.py | 23 +++- lib/galaxy/tools/actions/upload_common.py | 10 +- lib/galaxy/web/base/controller.py | 126 ++++++++++++------ lib/galaxy/web/controllers/library_common.py | 15 ++- lib/galaxy/web/controllers/requests_common.py | 6 +- lib/galaxy/web/controllers/user.py | 32 ++--- templates/requests/common/view_sample.mako | 22 +-- test/base/twilltestcase.py | 35 +++-- test/functional/test_library_templates.py | 106 +++++++++------ test/functional/test_sample_tracking.py | 15 +-- test/functional/test_user_info.py | 18 +-- 11 files changed, 248 insertions(+), 160 deletions(-) diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py index 608a18e5c76..40ab40b8b87 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -1510,8 +1510,13 @@ class FormDefinition( object, APIItem ): widgets = [] for index, field in enumerate( self.fields ): field_type = field[ 'type' ] - field_name = 'field_%i' % index - # determine the value of the field + if 'name' in field: + field_name = field[ 'name' ] + else: + # Default to names like field_0, field_1, etc for backward compatibility + # (not sure this is necessary)... + field_name = 'field_%i' % index + # Determine the value of the field if field_name in kwd: # The form was submitted via refresh_on_change if field_type == 'CheckboxField': @@ -1525,20 +1530,24 @@ class FormDefinition( object, APIItem ): except: # If there was an error getting the saved value, we'll still # display the widget, but it will be empty. - if field_type == 'CheckboxField': + if field_type == 'AddressField': + value = 'none' + elif 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 = '' + value = '' else: - # if none of the above, then leave the field empty - if field_type == 'CheckboxField': + # If none of the above, then leave the field empty + if field_type == 'AddressField': + value = 'none' + elif field_type == 'CheckboxField': # Since we do not have contents, set checkbox value to False value = False else: # Set other field types to the default value of the field - value = field.get('default', '') + value = field.get( 'default', '' ) # Create the field widget field_widget = eval( field_type )( field_name ) if field_type == 'TextField': diff --git a/lib/galaxy/tools/actions/upload_common.py b/lib/galaxy/tools/actions/upload_common.py index 22c1e91bff0..1fe9deb59e5 100644 --- a/lib/galaxy/tools/actions/upload_common.py +++ b/lib/galaxy/tools/actions/upload_common.py @@ -37,23 +37,23 @@ def persist_uploads( params ): def handle_library_params( trans, params, folder_id, replace_dataset=None ): # FIXME: the received params has already been parsed by util.Params() by the time it reaches here, # so no complex objects remain. This is not good because it does not allow for those objects to be - # manipulated here. The receivd params should be the original kwd from the initial request. + # manipulated here. The received params should be the original kwd from the initial request. library_bunch = util.bunch.Bunch() library_bunch.replace_dataset = replace_dataset library_bunch.message = params.get( 'ldda_message', '' ) # See if we have any template field contents - library_bunch.template_field_contents = [] + library_bunch.template_field_contents = {} template_id = params.get( 'template_id', None ) library_bunch.folder = trans.sa_session.query( trans.app.model.LibraryFolder ).get( trans.security.decode_id( folder_id ) ) # We are inheriting the folder's info_association, so we may have received inherited contents or we may have redirected # here after the user entered template contents ( due to errors ). if template_id not in [ None, 'None' ]: library_bunch.template = trans.sa_session.query( trans.app.model.FormDefinition ).get( template_id ) - for field_index in range( len( library_bunch.template.fields ) ): - field_name = 'field_%i' % field_index + for field in library_bunch.template.fields: + field_name = field[ 'name' ] if params.get( field_name, False ): field_value = util.restore_text( params.get( field_name, '' ) ) - library_bunch.template_field_contents.append( field_value ) + library_bunch.template_field_contents[ field_name ] = field_value else: library_bunch.template = None library_bunch.roles = [] diff --git a/lib/galaxy/web/base/controller.py b/lib/galaxy/web/base/controller.py index 5feb9d915c9..e2e374da4f0 100644 --- a/lib/galaxy/web/base/controller.py +++ b/lib/galaxy/web/base/controller.py @@ -289,6 +289,7 @@ class UsesFormDefinitions: return forms @web.expose def add_template( self, trans, cntrller, item_type, form_type, **kwd ): + log.debug("#### IN add_template, kwd: %s" % str( kwd )) params = util.Params( kwd ) form_id = params.get( 'form_id', 'none' ) message = util.restore_text( params.get( 'message', '' ) ) @@ -364,7 +365,7 @@ class UsesFormDefinitions: if params.get( 'add_template_button', False ): if form_id not in [ None, 'None', 'none' ]: form = trans.sa_session.query( trans.app.model.FormDefinition ).get( trans.security.decode_id( form_id ) ) - form_values = trans.app.model.FormValues( form, [] ) + form_values = trans.app.model.FormValues( form, {} ) trans.sa_session.add( form_values ) trans.sa_session.flush() if item_type == 'library': @@ -417,6 +418,7 @@ class UsesFormDefinitions: decoded_form_id = trans.security.decode_id( form_id ) except: decoded_form_id = None + log.debug("#### IN add_template, decoded_form_id: %s" % str( decoded_form_id )) if decoded_form_id: for form in forms: if decoded_form_id == form.id: @@ -443,6 +445,7 @@ class UsesFormDefinitions: ldda_id=ldda_id, inheritable_checked=inheritable, show_deleted=show_deleted ) ) + log.debug("#### IN add_template, widgets: %s" % str( widgets )) return trans.fill_template( '/common/select_template.mako', **new_kwd ) @web.expose @@ -502,6 +505,7 @@ class UsesFormDefinitions: info_association = rtra.run template = info_association.template info = info_association.info + log.debug("&&&&&&&&In edit_template, info: %s" % str( info )) form_values = trans.sa_session.query( trans.app.model.FormValues ).get( info.id ) if edited: # The form on which the template is based has been edited, so we need to update the @@ -540,6 +544,7 @@ class UsesFormDefinitions: return trans.response.send_redirect( web.url_for( controller='forms', action='edit_form_definition', **vars ) ) @web.expose def edit_template_info( self, trans, cntrller, item_type, form_type, **kwd ): + log.debug(">>>>>>>>>>>In edit_template_info, kwd: %s" % str( kwd )) # Edit the contents of the template fields without altering the template itself. params = util.Params( kwd ) # form_type must be one of: RUN_DETAILS_TEMPLATE, LIBRARY_INFO_TEMPLATE @@ -586,17 +591,21 @@ class UsesFormDefinitions: status='error' ) ) # We need the type of each template field widget widgets = item.get_template_widgets( trans ) + log.debug(">>>>>>>>>>>In edit_template_info, widgets: %s" % str( widgets )) # The list of widgets may include an AddressField which we need to save if it is new for index, widget_dict in enumerate( widgets ): + log.debug(">>>>>>>>>>>In edit_template_info, index: %s" % str( index )) + log.debug(">>>>>>>>>>>In edit_template_info, widget_dict: %s" % str( widget_dict )) widget = widget_dict[ 'widget' ] if isinstance( widget, AddressField ): - value = util.restore_text( params.get( 'field_%i' % index, '' ) ) + #value = util.restore_text( params.get( 'field_%i' % index, '' ) ) + value = util.restore_text( params.get( widget.name, '' ) ) if value == 'new': if params.get( 'edit_info_button', False ): - if self.field_param_values_ok( index, 'AddressField', **kwd ): + if self.field_param_values_ok( widget.name, 'AddressField', **kwd ): # Save the new address address = trans.app.model.UserAddress( user=trans.user ) - self.save_widget_field( trans, address, index, **kwd ) + self.save_widget_field( trans, address, widget.name, **kwd ) widget.value = str( address.id ) else: message = 'Required fields are missing contents.' @@ -627,13 +636,17 @@ class UsesFormDefinitions: elif isinstance( widget, CheckboxField ): # We need to check the value from kwd since util.Params would have munged the list if # the checkbox is checked. - value = kwd.get( 'field_%i' % index, '' ) + #value = kwd.get( 'field_%i' % index, '' ) + value = kwd.get( widget.name, '' ) if CheckboxField.is_checked( value ): widget.value = 'true' else: - widget.value = util.restore_text( params.get( 'field_%i' % index, '' ) ) + #widget.value = util.restore_text( params.get( 'field_%i' % index, '' ) ) + widget.value = util.restore_text( params.get( widget.name, '' ) ) + log.debug(">>>>>>>>>>>In edit_template_info, widget.value: %s" % str( widget.value )) # Save updated template field contents field_contents = self.clean_field_contents( widgets, **kwd ) + log.debug(">>>>>>>>>>>In edit_template_info, field_contents: %s" % str( field_contents )) if field_contents: if in_library: # In in a library, since information templates are inherited, the template fields can be displayed @@ -654,7 +667,7 @@ class UsesFormDefinitions: # create a SampleRunAssociation using the inherited template from the RequestType. if isinstance( assoc, trans.model.RequestTypeRunAssociation ): form_definition = assoc.run.template - new_form_values = trans.model.FormValues( form_definition, [] ) + new_form_values = trans.model.FormValues( form_definition, {} ) trans.sa_session.add( new_form_values ) trans.sa_session.flush() new_run = trans.model.Run( form_definition, new_form_values ) @@ -671,12 +684,26 @@ class UsesFormDefinitions: if info_association: template = info_association.template info = info_association.info + log.debug(">>>>>>>>>>>In edit_template_info, info: %s" % str( info )) + log.debug(">>>>>>>>>>>In edit_template_info, info.content: %s" % str( info.content )) form_values = trans.sa_session.query( trans.app.model.FormValues ).get( info.id ) + log.debug(">>>>>>>>>>>In edit_template_info, form_values.content 1: %s" % str( form_values.content )) # Update existing content only if it has changed - if form_values.content != field_contents: - form_values.content = field_contents + flush_required = False + for field_contents_key, field_contents_value in field_contents.items(): + log.debug(">>>>>>>>>>>In edit_template_info, field_contents_key: %s" % str( field_contents_key )) + log.debug(">>>>>>>>>>>In edit_template_info, field_contents_value: %s" % str( field_contents_value )) + if field_contents_key in form_values.content: + if form_values.content[ field_contents_key ] != field_contents_value: + flush_required = True + form_values.content[ field_contents_key ] = field_contents_value + else: + flush_required = True + form_values.content[ field_contents_key ] = field_contents_value + if flush_required: trans.sa_session.add( form_values ) trans.sa_session.flush() + log.debug(">>>>>>>>>>>In edit_template_info, form_values.content 2: %s" % str( form_values.content )) else: if in_library: # Inherit the next available info_association so we can get the template @@ -802,10 +829,14 @@ class UsesFormDefinitions: # Return True if any of the fields in widgets contain contents, widgets is a list of dictionaries that looks something like: # [{'widget': , 'helptext': 'Field 0 help (Optional)', 'label': 'Field 0'}] for i, field in enumerate( widgets ): + #log.debug("VVVVVVVV In widget_fields_have_contents, field: %s" % str( field )) + #log.debug("VVVVVVVV In widget_fields_have_contents, field[ 'widget' ]: %s" % str( field[ 'widget' ] )) + #log.debug("VVVVVVVV In widget_fields_have_contents, field[ 'widget' ].value: %s" % str( field[ 'widget' ].value )) if ( isinstance( field[ 'widget' ], TextArea ) or isinstance( field[ 'widget' ], TextField ) ) and field[ 'widget' ].value: + #log.debug("VVVVVVVV In widget_fields_have_contents, returning True...." ) return True if isinstance( field[ 'widget' ], SelectField ) and field[ 'widget' ].options: - for option_label, option_value, selected in field['widget'].options: + for option_label, option_value, selected in field[ 'widget' ].options: if selected: return True if isinstance( field[ 'widget' ], CheckboxField ) and field[ 'widget' ].checked: @@ -814,11 +845,14 @@ class UsesFormDefinitions: return True if isinstance( field[ 'widget' ], HistoryField ) and str( field[ 'widget' ].value ).lower() not in [ 'none' ]: return True + #log.debug("VVVVVVVV In widget_fields_have_contents, str( field[ 'widget' ].value ).lower(): *%s*" % str( str( field[ 'widget' ].value ).lower() )) if isinstance( field[ 'widget' ], AddressField ) and str( field[ 'widget' ].value ).lower() not in [ 'none' ]: return True return False def clean_field_contents( self, widgets, **kwd ): - field_contents = [] + log.debug("=====In clean_field_contents, widgets: %s" % str( widgets )) + log.debug("=====In clean_field_contents, kwd: %s" % str( kwd )) + field_contents = {} for index, widget_dict in enumerate( widgets ): widget = widget_dict[ 'widget' ] value = kwd.get( widget.name, '' ) @@ -828,65 +862,74 @@ class UsesFormDefinitions: elif isinstance( widget, AddressField ): # If the address was new, is has already been saved and widget.value is the new address.id value = widget.value - field_contents.append( util.restore_text( value ) ) + field_contents[ widget.name ] = util.restore_text( value ) + log.debug("=====In clean_field_contents, returning field_contents: %s" % str( field_contents )) return field_contents - def field_param_values_ok( self, index, widget_type, **kwd ): + def field_param_values_ok( self, widget_name, widget_type, **kwd ): + log.debug("++++++In field_param_values_ok, widget_name: %s" % str( widget_name )) + log.debug("++++++In field_param_values_ok, widget_type: %s" % str( widget_type )) + log.debug("++++++In field_param_values_ok, kwd: %s" % str( kwd )) # Make sure required fields have contents, etc params = util.Params( kwd ) if widget_type == 'AddressField': - if not util.restore_text( params.get( 'field_%i_short_desc' % index, '' ) ) \ - or not util.restore_text( params.get( 'field_%i_name' % index, '' ) ) \ - or not util.restore_text( params.get( 'field_%i_institution' % index, '' ) ) \ - or not util.restore_text( params.get( 'field_%i_address' % index, '' ) ) \ - or not util.restore_text( params.get( 'field_%i_city' % index, '' ) ) \ - or not util.restore_text( params.get( 'field_%i_state' % index, '' ) ) \ - or not util.restore_text( params.get( 'field_%i_postal_code' % index, '' ) ) \ - or not util.restore_text( params.get( 'field_%i_country' % index, '' ) ): + if not util.restore_text( params.get( '%s_short_desc' % widget_name, '' ) ) \ + or not util.restore_text( params.get( '%s_name' % widget_name, '' ) ) \ + or not util.restore_text( params.get( '%s_institution' % widget_name, '' ) ) \ + or not util.restore_text( params.get( '%s_address' % widget_name, '' ) ) \ + or not util.restore_text( params.get( '%s_city' % widget_name, '' ) ) \ + or not util.restore_text( params.get( '%s_state' % widget_name, '' ) ) \ + or not util.restore_text( params.get( '%s_postal_code' % widget_name, '' ) ) \ + or not util.restore_text( params.get( '%s_country' % widget_name, '' ) ): return False return True - def save_widget_field( self, trans, field_obj, index, **kwd ): + def save_widget_field( self, trans, field_obj, widget_name, **kwd ): + log.debug("<<<<<<< -
- - ${sample.library.name} -
-
-
- - ${sample.folder.name} -
-
+ %if sample.library: +
+ + ${sample.library.name} +
+
+
+ + ${sample.folder.name} +
+
+ %endif
${sample.request.name} diff --git a/test/base/twilltestcase.py b/test/base/twilltestcase.py index d46ab95528f..b6f3fe257d7 100644 --- a/test/base/twilltestcase.py +++ b/test/base/twilltestcase.py @@ -780,8 +780,9 @@ class TwillTestCase( unittest.TestCase ): if user_info_select: # The user_info_select SelectField requires a refresh_on_change self.refresh_form( 'user_info_select', user_info_select ) - for index, info_value in enumerate( user_info_values ): - tc.fv( "1", "field_%i" % index, info_value ) + for index, info_value in enumerate( user_info_values ): + field_index = index + 1 + tc.fv( "1", "%i_field_name" % field_index, info_value ) tc.submit( "create_user_button" ) def edit_user_info( self, new_email='', new_username='', password='', new_password='', info_values=[], strings_displayed=[], strings_displayed_after_submit=[] ): @@ -801,7 +802,8 @@ class TwillTestCase( unittest.TestCase ): tc.submit( "change_password_button" ) if info_values: for index, info_value in enumerate( info_values ): - tc.fv( "user_info", "field_%i" % index, info_value ) + field_index = index + 1 + tc.fv( "user_info", "%i_field_name" % field_index, info_value ) tc.submit( "edit_user_info_button" ) for check_str in strings_displayed_after_submit: self.check_page_for_string( check_str ) @@ -1345,14 +1347,15 @@ class TwillTestCase( unittest.TestCase ): self.home() # Form stuff - def create_form( self, name, desc, form_type, field_type='TextField', form_layout_name='', - num_fields=1, num_options=0, strings_displayed=[], strings_displayed_after_submit=[] ): + def create_form( self, name, description, form_type, field_type='TextField', form_layout_name='', + num_fields=1, num_options=0, field_name='1_field_name', strings_displayed=[], + strings_displayed_after_submit=[] ): """Create a new form definition.""" self.visit_url( "%s/forms/create_form_definition" % self.url ) for check_str in strings_displayed: self.check_page_for_string( check_str ) tc.fv( "1", "name", name ) - tc.fv( "1", "description", desc ) + tc.fv( "1", "description", description ) tc.fv( "1", "form_type_select_field", form_type ) tc.submit( "create_form_button" ) if form_type == "Sequencing Sample Form": @@ -1387,6 +1390,7 @@ class TwillTestCase( unittest.TestCase ): tc.fv( "1", option_field_name, option_field_value ) else: tc.fv( "1", "field_type_0", field_type ) + tc.fv( "1", 'field_name_0', field_name ) tc.fv( "1", field_default, field_default_contents ) # All done... now save tc.submit( "save_changes_button" ) @@ -1516,7 +1520,8 @@ class TwillTestCase( unittest.TestCase ): tc.fv( "1", "name", name ) tc.fv( "1", "desc", desc ) for index, field_value_tuple in enumerate( field_value_tuples ): - field_name = "field_%i" % index + field_index = index + 1 + field_name = "%i_field_name" % field_index field_value, refresh_on_change = field_value_tuple if refresh_on_change: # Only the AddressField type has a refresh on change setup on selecting an option @@ -1559,7 +1564,8 @@ class TwillTestCase( unittest.TestCase ): if new_desc: tc.fv( "1", "desc", new_desc ) for index, field_value in enumerate( new_fields ): - tc.fv( "1", "field_%i" % index, field_value ) + field_name_index = index + 1 + tc.fv( "1", "%i_field_name" % field_name_index, field_value ) tc.submit( "edit_basic_request_info_button" ) for check_str in strings_displayed_after_submit: self.check_page_for_string( check_str ) @@ -1904,7 +1910,7 @@ class TwillTestCase( unittest.TestCase ): check_str = "The new folder named '%s' has been added to the data library." % name self.check_page_for_string( check_str ) self.home() - def folder_info( self, cntrller, folder_id, library_id, name='', new_name='', description='', + def folder_info( self, cntrller, folder_id, library_id, name='', new_name='', description='', template_refresh_field_name='1_field_name', template_refresh_field_contents='', template_fields=[], strings_displayed=[], strings_not_displayed=[], strings_displayed_after_submit=[], strings_not_displayed_after_submit=[] ): """Add information to a library using an existing template with 2 elements""" @@ -1926,7 +1932,7 @@ class TwillTestCase( unittest.TestCase ): # A template containing an AddressField is displayed on the form, so we need to refresh the form # with the received template_refresh_field_contents. There are 2 forms on the folder_info page # when in edit mode, and the 2nd one is the one we want. - self.refresh_form( "field_0", template_refresh_field_contents, form_no=2 ) + self.refresh_form( template_refresh_field_name, template_refresh_field_contents, form_no=2 ) if template_fields: # We have an information template associated with the folder, so # there are 2 forms on this page and the template is the 2nd form @@ -1947,7 +1953,8 @@ class TwillTestCase( unittest.TestCase ): def upload_library_dataset( self, cntrller, library_id, folder_id, filename='', server_dir='', replace_id='', upload_option='upload_file', file_type='auto', dbkey='hg18', space_to_tab='', link_data_only='', dont_preserve_dirs='', roles=[], ldda_message='', hda_ids='', - template_refresh_field_contents='', template_fields=[], show_deleted='False', strings_displayed=[] ): + template_refresh_field_name='1_field_name', template_refresh_field_contents='', template_fields=[], + show_deleted='False', strings_displayed=[] ): """Add datasets to library using any upload_option""" # NOTE: due to the library_wait() method call at the end of this method, no tests should be done # for strings_displayed_after_submit. @@ -1961,7 +1968,7 @@ class TwillTestCase( unittest.TestCase ): if template_refresh_field_contents: # A template containing an AddressField is displayed on the upload form, so we need to refresh the form # with the received template_refresh_field_contents. - self.refresh_form( "field_0", template_refresh_field_contents ) + self.refresh_form( template_refresh_field_name, template_refresh_field_contents ) for tup in template_fields: tc.fv( "1", tup[0], tup[1] ) tc.fv( "1", "library_id", library_id ) @@ -2024,7 +2031,7 @@ class TwillTestCase( unittest.TestCase ): for check_str in strings_displayed: self.check_page_for_string( check_str ) self.home() - def ldda_edit_info( self, cntrller, library_id, folder_id, ldda_id, ldda_name, new_ldda_name='', + def ldda_edit_info( self, cntrller, library_id, folder_id, ldda_id, ldda_name, new_ldda_name='', template_refresh_field_name='1_field_name', template_refresh_field_contents='', template_fields=[], strings_displayed=[], strings_not_displayed=[] ): """Edit library_dataset_dataset_association information, optionally template element information""" self.visit_url( "%s/library_common/ldda_edit_info?cntrller=%s&library_id=%s&folder_id=%s&id=%s" % \ @@ -2040,7 +2047,7 @@ class TwillTestCase( unittest.TestCase ): # A template containing an AddressField is displayed on the upload form, so we need to refresh the form # with the received template_refresh_field_contents. There are 4 forms on this page, and the template is # contained in the 4th form named "edit_info". - self.refresh_form( "field_0", template_refresh_field_contents, form_no=4 ) + self.refresh_form( template_refresh_field_name, template_refresh_field_contents, form_no=4 ) if template_fields: # We have an information template associated with the folder, so # there are 2 forms on this page and the template is the 2nd form diff --git a/test/functional/test_library_templates.py b/test/functional/test_library_templates.py index 9f814c1f24f..5b095e46ea6 100644 --- a/test/functional/test_library_templates.py +++ b/test/functional/test_library_templates.py @@ -36,6 +36,7 @@ class TestLibraryFeatures( TwillTestCase ): """Testing creating several LibraryInformationTemplate form definitions""" # Logged in as admin_user for type in [ 'AddressField', 'CheckboxField', 'SelectField', 'TextArea', 'TextField', 'WorkflowField' ]: + field_name = type.lower() form_desc = '%s description' % type num_options = 0 if type == 'SelectField': @@ -43,23 +44,44 @@ class TestLibraryFeatures( TwillTestCase ): num_options = 2 # Create form for library template self.create_form( name=type, - desc=form_desc, + description=form_desc, form_type=galaxy.model.FormDefinition.types.LIBRARY_INFO_TEMPLATE, field_type=type, - num_options=num_options ) + num_options=num_options, + field_name=field_name ) # Get all of the new form definitions for later use global AddressField_form AddressField_form = get_form( 'AddressField' ) + # NOTE: each of these names need to be the same as field_name defined above + # for each type. + global address_field_name + address_field_name = 'addressfield' + global CheckboxField_form CheckboxField_form = get_form( 'CheckboxField' ) + global checkbox_field_name + checkbox_field_name = 'checkboxfield' + global SelectField_form SelectField_form = get_form( 'SelectField' ) + global select_field_name + select_field_name = 'selectfield' + global TextArea_form TextArea_form = get_form( 'TextArea' ) + global textarea_name + textarea_name = 'textarea' + global TextField_form TextField_form = get_form( 'TextField' ) + global textfield_name + textfield_name = 'textfield' + global WorkflowField_form WorkflowField_form = get_form( 'WorkflowField' ) + global workflow_field_name + workflow_field_name = 'workflowfield' + def test_010_create_libraries( self ): """Testing creating a new library for each template""" # Logged in as admin_user @@ -118,9 +140,10 @@ class TestLibraryFeatures( TwillTestCase ): self.security.encode_id( library1.id ), strings_displayed=[ folder1.name, folder1.description ] ) # Make sure the template and contents were inherited to folder1 - self.folder_info( 'library_admin', - self.security.encode_id( folder1.id ), - self.security.encode_id( library1.id ), + self.folder_info( cntrller='library_admin', + folder_id=self.security.encode_id( folder1.id ), + library_id=self.security.encode_id( library1.id ), + template_refresh_field_name=address_field_name, strings_displayed=[ AddressField_form.name, 'This is an inherited template and is not required to be used with this folder' ] ) def test_030_add_dataset_to_folder1( self ): @@ -138,16 +161,17 @@ class TestLibraryFeatures( TwillTestCase ): filename=filename, file_type='bed', dbkey='hg18', + template_refresh_field_name=address_field_name, ldda_message=ldda_message, template_refresh_field_contents='new', - template_fields=[ ( 'field_0_short_desc', short_desc ), - ( 'field_0_name', 'Dick' ), - ( 'field_0_institution', 'PSU' ), - ( 'field_0_address', '32 O Street' ), - ( 'field_0_city', 'Anywhere' ), - ( 'field_0_state', 'AK' ), - ( 'field_0_postal_code', '0000000' ), - ( 'field_0_country', 'USA' ) ], + template_fields=[ ( '%s_short_desc' % address_field_name, short_desc ), + ( '%s_name' % address_field_name, 'Dick' ), + ( '%s_institution' % address_field_name, 'PSU' ), + ( '%s_address' % address_field_name, '32 O Street' ), + ( '%s_city' % address_field_name, 'Anywhere' ), + ( '%s_state' % address_field_name, 'AK' ), + ( '%s_postal_code' % address_field_name, '0000000' ), + ( '%s_country' % address_field_name, 'USA' ) ], strings_displayed=[ 'Upload files' ] ) global user_address1 user_address1 = get_user_address( admin_user, short_desc ) @@ -174,15 +198,16 @@ class TestLibraryFeatures( TwillTestCase ): self.security.encode_id( folder1.id ), self.security.encode_id( ldda1.id ), ldda1.name, + template_refresh_field_name=address_field_name, template_refresh_field_contents='new', - template_fields=[ ( 'field_0_short_desc', short_desc ), - ( 'field_0_name', 'Richard' ), - ( 'field_0_institution', 'PSU' ), - ( 'field_0_address', '32 O Street' ), - ( 'field_0_city', 'Anywhere' ), - ( 'field_0_state', 'AK' ), - ( 'field_0_postal_code', '0000000' ), - ( 'field_0_country', 'USA' ) ], + template_fields=[ ( '%s_short_desc' % address_field_name, short_desc ), + ( '%s_name' % address_field_name, 'Richard' ), + ( '%s_institution' % address_field_name, 'PSU' ), + ( '%s_address' % address_field_name, '32 O Street' ), + ( '%s_city' % address_field_name, 'Anywhere' ), + ( '%s_state' % address_field_name, 'AK' ), + ( '%s_postal_code' % address_field_name, '0000000' ), + ( '%s_country' % address_field_name, 'USA' ) ], strings_displayed=[ short_desc ] ) global user_address2 user_address2 = get_user_address( admin_user, short_desc ) @@ -190,9 +215,10 @@ class TestLibraryFeatures( TwillTestCase ): def test_040_edit_contents_of_folder1_template( self ): """Testing editing the contents of folder1 AddressField template""" # Make sure the template and contents were inherited to folder1 - self.folder_info( 'library_admin', - self.security.encode_id( folder1.id ), - self.security.encode_id( library1.id ), + self.folder_info( cntrller='library_admin', + folder_id=self.security.encode_id( folder1.id ), + library_id=self.security.encode_id( library1.id ), + template_refresh_field_name=address_field_name, template_refresh_field_contents=str( user_address2.id ), strings_displayed=[ AddressField_form.name, 'This is an inherited template and is not required to be used with this folder' ], @@ -208,14 +234,16 @@ class TestLibraryFeatures( TwillTestCase ): filename=filename, file_type='bed', dbkey='hg18', + template_refresh_field_name=address_field_name, ldda_message=ldda_message, strings_displayed=[ 'Upload files' ] ) # Make sure user_address2 is associated with ldda. - self.ldda_edit_info( 'library_admin', - self.security.encode_id( library1.id ), - self.security.encode_id( folder1.id ), - self.security.encode_id( ldda1.id ), - ldda1.name, + self.ldda_edit_info( cntrller='library_admin', + library_id=self.security.encode_id( library1.id ), + folder_id=self.security.encode_id( folder1.id ), + ldda_id=self.security.encode_id( ldda1.id ), + ldda_name=ldda1.name, + template_refresh_field_name=address_field_name, strings_displayed=[ user_address2.desc ] ) def test_050_add_template_to_library2( self ): """ Testing add an inheritable template containing an CheckboxField to library2""" @@ -229,7 +257,7 @@ class TestLibraryFeatures( TwillTestCase ): # Check the CheckboxField to make sure the template contents are inherited self.library_info( 'library_admin', self.security.encode_id( library2.id ), - template_fields = [ ( 'field_0', '1' ) ] ) + template_fields = [ ( checkbox_field_name, '1' ) ] ) def test_055_add_folder2_to_library2( self ): """Testing adding a folder to library2""" # Logged in as admin_user @@ -257,7 +285,7 @@ class TestLibraryFeatures( TwillTestCase ): self.folder_info( cntrller='library_admin', folder_id=self.security.encode_id( folder2.id ), library_id=self.security.encode_id( library2.id ), - template_fields=[ ( "field_0", '1' ) ], + template_fields=[ ( checkbox_field_name, '1' ) ], strings_displayed=[ CheckboxField_form.name, 'This is an inherited template and is not required to be used with this folder' ] ) def test_070_add_ldda_to_folder2( self ): @@ -301,7 +329,7 @@ class TestLibraryFeatures( TwillTestCase ): # SelectField option names are zero-based self.library_info( 'library_admin', self.security.encode_id( library3.id ), - template_fields=[ ( 'field_0', 'Option1' ) ] ) + template_fields=[ ( select_field_name, 'Option1' ) ] ) def test_085_add_folder3_to_library3( self ): """Testing adding a folder to library3""" # Logged in as admin_user @@ -329,7 +357,7 @@ class TestLibraryFeatures( TwillTestCase ): self.folder_info( cntrller='library_admin', folder_id=self.security.encode_id( folder3.id ), library_id=self.security.encode_id( library3.id ), - template_fields=[ ( "field_0", 'Option1' ) ], + template_fields=[ ( select_field_name, 'Option1' ) ], strings_displayed=[ SelectField_form.name, 'This is an inherited template and is not required to be used with this folder', 'Option1' ] ) @@ -371,7 +399,7 @@ class TestLibraryFeatures( TwillTestCase ): folder_id=self.security.encode_id( folder3.id ), upload_option='import_from_history', hda_ids=self.security.encode_id( hda.id ), - strings_displayed=[ '' ] ) + strings_displayed=[ '' % select_field_name ] ) ldda = get_latest_ldda_by_name( filename ) assert ldda is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda from the database' self.browse_library( 'library_admin', @@ -397,7 +425,7 @@ class TestLibraryFeatures( TwillTestCase ): # Select the 2nd option in the SelectField to make sure the template contents are inherited self.library_info( 'library_admin', self.security.encode_id( library4.id ), - template_fields=[ ('field_0', 'This text should be inherited' ) ] ) + template_fields=[ ( textarea_name, 'This text should be inherited' ) ] ) def test_110_add_folder4_to_library4( self ): """Testing adding a folder to library4""" # Logged in as admin_user @@ -419,7 +447,7 @@ class TestLibraryFeatures( TwillTestCase ): self.folder_info( cntrller='library_admin', folder_id=self.security.encode_id( folder4.id ), library_id=self.security.encode_id( library4.id ), - template_fields=[ ( "field_0", 'This text should be inherited' ) ], + template_fields=[ ( textarea_name, 'This text should be inherited' ) ], strings_displayed=[ TextArea_form.name, 'This is an inherited template and is not required to be used with this folder', 'This text should be inherited' ] ) @@ -463,7 +491,7 @@ class TestLibraryFeatures( TwillTestCase ): # Select the 2nd option in the SelectField to make sure the template contents are inherited self.library_info( 'library_admin', self.security.encode_id( library5.id ), - template_fields=[ ( 'field_0', 'This text should be inherited' ) ] ) + template_fields=[ ( textfield_name, 'This text should be inherited' ) ] ) def test_130_add_folder5_to_library5( self ): """Testing adding a folder to library5""" # Logged in as admin_user @@ -485,7 +513,7 @@ class TestLibraryFeatures( TwillTestCase ): self.folder_info( cntrller='library_admin', folder_id=self.security.encode_id( folder5.id ), library_id=self.security.encode_id( library5.id ), - template_fields=[ ( "field_0", 'This text should be inherited' ) ], + template_fields=[ ( textfield_name, 'This text should be inherited' ) ], strings_displayed=[ TextField_form.name, 'This is an inherited template and is not required to be used with this folder', 'This text should be inherited' ] ) @@ -592,7 +620,7 @@ class TestLibraryFeatures( TwillTestCase ): self.folder_info( cntrller='library_admin', folder_id=self.security.encode_id( folder6.id ), library_id=self.security.encode_id( library6.id ), - template_fields=[ ( "field_0", 'none' ) ], + template_fields=[ ( workflow_field_name, 'none' ) ], strings_displayed=[ WorkflowField_form.name, 'This is an inherited template and is not required to be used with this folder', 'none' ] ) diff --git a/test/functional/test_sample_tracking.py b/test/functional/test_sample_tracking.py index 2f4f1a6bcb2..306dfedd62c 100644 --- a/test/functional/test_sample_tracking.py +++ b/test/functional/test_sample_tracking.py @@ -4,9 +4,7 @@ from base.twilltestcase import * from base.test_db_util import * class TestFormsAndSampleTracking( TwillTestCase ): - # # ====== Setup Users, Groups & Roles required for this test suite ========= - # def test_000_initiate_users( self ): """Ensuring all required user accounts exist""" self.logout() @@ -169,9 +167,10 @@ class TestFormsAndSampleTracking( TwillTestCase ): tmp_desc = "Temp form description" form_type = galaxy.model.FormDefinition.types.REQUEST self.create_form( name=tmp_name, - desc=tmp_desc, + description=tmp_desc, form_type=form_type, num_fields=0, + field_name='1_field_name', strings_displayed=[ 'Create a new form definition' ], strings_displayed_after_submit=[ tmp_name, tmp_desc, form_type ] ) tmp_form = get_form( tmp_name ) @@ -223,10 +222,11 @@ class TestFormsAndSampleTracking( TwillTestCase ): global sample_form_layout_grid_name sample_form_layout_grid_name = 'Layout Grid1' self.create_form( name=name, - desc=desc, + description=desc, form_type=form_type, form_layout_name=sample_form_layout_grid_name, num_fields=0, + field_name='1_field_name', strings_displayed=[ 'Create a new form definition' ], strings_displayed_after_submit=[ "The form '%s' has been updated with the changes." % name ] ) tmp_form = get_form( name ) @@ -313,9 +313,7 @@ class TestFormsAndSampleTracking( TwillTestCase ): pass self.logout() self.login( email=admin_user.email ) - # - # ====== Sequencing request test methods - User perspective ================ - # + # ====== Sequencing request test methods - regular user perspective ================ def test_025_create_request( self ): """Testing creating a sequencing request as a regular user""" # logged in as admin_user @@ -536,9 +534,7 @@ class TestFormsAndSampleTracking( TwillTestCase ): strings_displayed_count=strings_displayed_count, strings_not_displayed=[ request1.states.COMPLETE, request1.states.REJECTED ] ) - # # ====== Sequencing request test methods - Admin perspective ================ - # def test_050_receive_request_as_admin( self ): """Testing receiving a sequencing request and assigning it barcodes""" # logged in as regular_user1 @@ -852,7 +848,6 @@ class TestFormsAndSampleTracking( TwillTestCase ): sample1_dataset.transfer_status.NOT_STARTED ] self.view_sample_dataset( sample_dataset_id=self.security.encode_id( sample1_dataset.id ), strings_displayed=strings_displayed ) - def test_999_reset_data_for_later_test_runs( self ): """Reseting data to enable later test runs to pass""" # Logged in as admin_user diff --git a/test/functional/test_user_info.py b/test/functional/test_user_info.py index f1b7c47997e..3b94d324500 100644 --- a/test/functional/test_user_info.py +++ b/test/functional/test_user_info.py @@ -40,23 +40,23 @@ class TestUserInfo( TwillTestCase ): desc = "This is Student user info form's description" form_type = get_user_info_form_definition() self.create_form( name=name, - desc=desc, + description=desc, form_type=form_type, num_fields=0, strings_displayed=[ 'Create a new form definition' ], strings_displayed_after_submit=[ name, desc, form_type ] ) tmp_form = get_form( name ) # Add fields to the form - field_dicts = [ dict( name='Affiliation', + field_dicts = [ dict( label='Affiliation', desc='The type of organization you are affiliated with', type='SelectField', required='optional', selectlist=[ 'Educational', 'Research', 'Commercial' ] ), - dict( name='Name of Organization', + dict( label='Name of Organization', desc='', type='TextField', required='optional' ), - dict( name='Contact for feedback', + dict( label='Contact for feedback', desc='', type='CheckboxField', required='optional' ) ] @@ -74,23 +74,23 @@ class TestUserInfo( TwillTestCase ): name = "Researcher" desc = "This is Researcher user info form's description" self.create_form( name=name, - desc=desc, + description=desc, form_type=form_type, num_fields=0, strings_displayed=[ 'Create a new form definition' ], strings_displayed_after_submit=[ name, desc, form_type ] ) tmp_form = get_form( name ) # Add fields to the form - field_dicts = [ dict( name='Affiliation', + field_dicts = [ dict( label='Affiliation', desc='The type of organization you are affiliated with', type='SelectField', required='optional', selectlist=[ 'Educational', 'Research', 'Commercial' ] ), - dict( name='Name of Organization', + dict( label='Name of Organization', desc='', type='TextField', required='optional' ), - dict( name='Contact for feedback', + dict( label='Contact for feedback', desc='', type='CheckboxField', required='optional' ) ] @@ -131,7 +131,7 @@ class TestUserInfo( TwillTestCase ): self.edit_user_info( strings_displayed=[ "Manage User Information", user_info_values[0], user_info_values[1], - '' ] ) + '' ] ) def test_015_user_reqistration_single_user_info_forms( self ): """Testing user registration with a single user info form""" # Logged in as regular_user_11