def test_005_create_library_templates(self):
        """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':
                # Pass number of options we want in our SelectField
                num_options = 2
            # Create form for library template
            strings_displayed_after_submit = [
                "The form '%s' has been updated with the changes." % type
            ]
            self.create_form(
                name=type,
                description=form_desc,
                form_type=galaxy.model.FormDefinition.types.
                LIBRARY_INFO_TEMPLATE,
                field_type=type,
                num_options=num_options,
                field_name=field_name,
                strings_displayed_after_submit=strings_displayed_after_submit)
        # 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_005_create_library_templates( self ):
        """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':
                # Pass number of options we want in our SelectField
                num_options = 2
            # Create form for library template
            strings_displayed_after_submit = [ "The form '%s' has been updated with the changes." % type ]
            self.create_form( name=type,
                              description=form_desc,
                              form_type=galaxy.model.FormDefinition.types.LIBRARY_INFO_TEMPLATE,
                              field_type=type,
                              num_options=num_options,
                              field_name=field_name,
                              strings_displayed_after_submit=strings_displayed_after_submit )
        # 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_005_create_user_info_forms(self):
     """Testing creating a new user info form and editing it"""
     # Logged in as admin_user
     # Create a the first form
     name = "Student"
     desc = "This is Student user info form's description"
     form_type = get_user_info_form_definition()
     self.create_form(
         name=name,
         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('Student')
     # Add fields to the form
     field_dicts = [
         dict(label='Affiliation',
              desc='The type of  organization you are affiliated with',
              type='SelectField',
              required='optional',
              selectlist=['Educational', 'Research', 'Commercial'],
              name='affiliation'),
         dict(label='Name of Organization',
              desc='',
              type='TextField',
              required='optional',
              name='name_of_oganization'),
         dict(label='Contact for feedback',
              desc='',
              type='CheckboxField',
              required='optional',
              name='contact_for_feedback')
     ]
     self.edit_form(
         id=self.security.encode_id(tmp_form.current.id),
         field_dicts=field_dicts,
         field_index=len(tmp_form.fields),
         strings_displayed=['Edit form definition "Student"'],
         strings_displayed_after_submit=[
             "The form 'Student' has been updated with the changes."
         ])
     # Get the form_definition object for later tests
     global form_one
     form_one = get_form('Student')
     assert form_one is not None, 'Problem retrieving form named "Student" from the database'
     assert len(form_one.fields) == len(tmp_form.fields) + len(field_dicts)
     # Create the second form
     name = "Researcher"
     desc = "This is Researcher user info form's description"
     self.create_form(
         name=name,
         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('Researcher')
     # Add fields to the form
     self.edit_form(
         id=self.security.encode_id(tmp_form.current.id),
         field_dicts=field_dicts,
         field_index=len(tmp_form.fields),
         strings_displayed=['Edit form definition "Researcher"'],
         strings_displayed_after_submit=[
             "The form 'Researcher' has been updated with the changes."
         ])
     # Get the form_definition object for later tests
     global form_two
     form_two = get_form('Researcher')
     assert form_two is not None, 'Problem retrieving form named "Researcher" from the database'
     assert len(form_two.fields) == len(tmp_form.fields) + len(field_dicts)
 def test_005_create_user_info_forms( self ):
     """Testing creating a new user info form and editing it"""
     # Logged in as admin_user
     # Create a the first form
     name = "Student"
     desc = "This is Student user info form's description"
     form_type = get_user_info_form_definition()
     self.create_form( name=name,
                       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( 'Student' )
     # Add fields to the form
     field_dicts = [ dict( label='Affiliation',
                           desc='The type of  organization you are affiliated with',
                           type='SelectField',
                           required='optional',
                           selectlist=[ 'Educational', 'Research', 'Commercial' ],
                           name='affiliation' ),
                     dict( label='Name of Organization',
                           desc='',
                           type='TextField',
                           required='optional',
                           name='name_of_oganization' ),
                     dict( label='Contact for feedback',
                           desc='',
                           type='CheckboxField',
                           required='optional',
                           name='contact_for_feedback' ) ]
     self.edit_form( id=self.security.encode_id( tmp_form.current.id ),
                     field_dicts=field_dicts,
                     field_index=len( tmp_form.fields ),
                     strings_displayed=[ 'Edit form definition "Student"' ],
                     strings_displayed_after_submit=[ "The form 'Student' has been updated with the changes." ] )
     # Get the form_definition object for later tests
     global form_one
     form_one = get_form( 'Student' )
     assert form_one is not None, 'Problem retrieving form named "Student" from the database'
     assert len( form_one.fields ) == len( tmp_form.fields ) + len( field_dicts )
     # Create the second form
     name = "Researcher"
     desc = "This is Researcher user info form's description"
     self.create_form( name=name,
                       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( 'Researcher' )
     # Add fields to the form
     self.edit_form( id=self.security.encode_id( tmp_form.current.id ),
                     field_dicts=field_dicts,
                     field_index=len( tmp_form.fields ),
                     strings_displayed=[ 'Edit form definition "Researcher"' ],
                     strings_displayed_after_submit=[ "The form 'Researcher' has been updated with the changes." ] )
     # Get the form_definition object for later tests
     global form_two
     form_two = get_form( 'Researcher' )
     assert form_two is not None, 'Problem retrieving form named "Researcher" from the database'
     assert len( form_two.fields ) == len( tmp_form.fields ) + len( field_dicts )