'Add a new template to an item - for library items, the template will ALWAYS BE SET TO INHERITABLE here.  If you want to
dis-inherit your template, call the manage_library_template_inheritance() below immediately after you call this
method in your test code.  Templates added to Requesttype objects are always inherited to samples.'

def add_template(self, cntrller, item_type, form_type, form_id, form_name, library_id=None, folder_id=None, ldda_id=None, request_type_id=None, sample_id=None):

    params = dict(cntrller=cntrller, item_type=item_type, form_type=form_type, library_id=library_id)
    url = '/library_common/add_template'
    if (item_type == 'folder'):
        params['folder_id'] = folder_id
    elif (item_type == 'ldda'):
        params['ldda_id'] = ldda_id
    self.visit_url(url, params)
    self.check_page_for_string('Select    a    template    for    the')
    self.refresh_form('form_id', form_id)
    tc.fv('select_template', 'inheritable', '1')
    tc.submit('add_template_button')
    self.check_page_for_string = ('A    template    based    on    the    form    "%s"    has    been    added    to    this' % form_name)
