details: http://www.bx.psu.edu/hg/galaxy/rev/e85d660c46ee changeset: 1493:e85d660c46ee user: Greg Von Kuster greg@bx.psu.edu date: Fri Sep 05 16:36:51 2008 -0400 description: More fixes for twill 0.9, the annotation profiler tests do not yet pass, but all else should work now, more tests coming soon.
7 file(s) affected in this change:
test/base/twilltestcase.py test/functional/__init__.py test/functional/test_metadata_editing.py tools/annotation_profiler/annotation_profiler.xml tools/filters/joiner.xml tools/new_operations/intersect.xml tools/new_operations/subtract.xml
diffs (289 lines):
diff -r d7e7804572fd -r e85d660c46ee test/base/twilltestcase.py --- a/test/base/twilltestcase.py Thu Sep 04 12:19:32 2008 -0400 +++ b/test/base/twilltestcase.py Fri Sep 05 16:36:51 2008 -0400 @@ -1,8 +1,7 @@ import pkg_resources -pkg_resources.require('twill') +pkg_resources.require( "twill==0.9" )
-import StringIO -import os, sys, random, filecmp, time, unittest, urllib, logging, difflib, zipfile +import StringIO, os, sys, random, filecmp, time, unittest, urllib, logging, difflib, zipfile from itertools import *
import twill @@ -18,7 +17,7 @@
# Dial ClientCookie logging down (very noisy) logging.getLogger( "ClientCookie.cookies" ).setLevel( logging.WARNING ) -#log = logging.getLogger( __name__ ) +log = logging.getLogger( __name__ )
class TwillTestCase( unittest.TestCase ):
@@ -244,8 +243,14 @@ self.assertEqual(len(elems), 1) self.visit_page( "delete?id=%s" % elems[0].get('id') )
- def edit_metadata( self, hid=None, form=1, **kwd ): - """Edits the metadata associated with a history item. There are currently 3 forms on the edit page.""" + def edit_metadata( self, hid=None, form_no=0, **kwd ): + """ + Edits the metadata associated with a history item.""" + # There are currently 4 forms on the edit page: + # 0. name="edit_attributes" + # 1. name="auto_detect" + # 2. name="convert_data" + # 3. name="change_datatype" data_list = self.get_history() self.assertTrue( data_list ) if hid is None: # take last hid @@ -253,12 +258,16 @@ hid = elem.get('hid') self.assertTrue( hid ) self.visit_page( 'edit?hid=%d' % hid ) - if form == 1: button = "save" #Edit Attributes form - elif form == 2: button = "detect" #Auto-detect Metadata Attributes - elif form == 3: button = "convert_data" #Convert to new format form - elif form == 4: button = "change" #Change data type form + if form_no == 0: + button = "save" #Edit Attributes form + elif form_no == 1: + button = "detect" #Auto-detect Metadata Attributes + elif form_no == 2: + button = "convert_data" #Convert to new format form + elif form_no == 3: + button = "change" #Change data type form if kwd: - self.submit_form(form=form, button=button, **kwd) + self.submit_form( form_no=form_no, button=button, **kwd)
def get_dataset_ids_in_history( self ): """Returns the ids of datasets in a history""" @@ -406,23 +415,24 @@
def showforms( self ): """Shows form, helpful for debugging new tests""" - return tc.browser.showforms() + return tc.showforms()
- def submit_form( self, form=1, button="runtool_btn", **kwd ): - """Populates and submits a form from the keyword arguments""" - #Check for onchange attribute, submit a change if required - for i, f in enumerate( tc.showforms() ): - if i == form - 1: + def submit_form( self, form_no=0, button="runtool_btn", **kwd ): + """Populates and submits a form from the keyword arguments.""" + for i, f in enumerate( self.showforms() ): + if i == form_no: break + # An HTMLForm contains a sequence of Controls. Supported control classes are: + # TextControl, FileControl, ListControl, RadioControl, CheckboxControl, SelectControl, + # SubmitControl, ImageControl for i, control in enumerate( f.controls ): try: + # Check for refresh_on_change attribute, submit a change if required if 'refresh_on_change' in control.attrs.keys(): changed = False for elem in kwd[control.name]: - """ - For DataToolParameter, control.value is the index of the DataToolParameter select list, - but elem is the filename. The following loop gets the filename of that index. - """ + # For DataToolParameter, control.value is the index of the DataToolParameter select list, + # but elem is the filename. The following loop gets the filename of that index. param_text = '' for param in tc.show().split('<select'): param = ('<select' + param.split('select>')[0] + 'select>').replace('selected', 'selected="yes"') @@ -433,52 +443,56 @@ param_text = option.text.strip() break break - if elem not in control.value and param_text.find(elem) == -1 : changed = True break if changed: - # Clear Control and set to proper value - the command: - # formvalue <formnum> <fieldname> <value> - # sets the given field in the given form to the given value. - # For read-only form widgets/controls, the click may be recorded for use by submit, - # but the value is not changed unless the 'config' command has changed the default behavior. + # Clear Control and set to proper value control.clear() - for elem in kwd[control.name]: - tc.formvalue(str(form), str(i+1), str(elem) ) - #Create a new submit control, allows form to refresh, instead of going to next page - control = ClientForm.SubmitControl('SubmitControl','___refresh_grouping___',{'name':'refresh_grouping'}) + # kwd[control.name] should be a singlelist + for elem in kwd[ control.name ]: + tc.fv( f.name, control.name, str( elem ) ) + # Create a new submit control, allows form to refresh, instead of going to next page + control = ClientForm.SubmitControl( 'SubmitControl', '___refresh_grouping___', {'name':'refresh_grouping'} ) control.add_to_form( f ) control.fixup() - #submit for refresh - tc.submit('___refresh_grouping___') - #start over submit_form() - return self.submit_form(form, button, **kwd) + # Submit for refresh + tc.submit( '___refresh_grouping___' ) + return self.submit_form( form_no=form_no, button=button, **kwd ) except Exception, e: - # Log.debug("In submit_form, caught exception: %s" %str( e )) + log.debug( "In submit_form, continuing, but caught exception: %s" % str( e ) ) continue - for key, value in kwd.items(): - # needs to be able to handle multiple values per key - if not isinstance(value, list): - value = [ value ] - for i, control in enumerate( f.controls ): - if control.name == key: - control.clear() - if control.is_of_kind("text"): - # set the given field in the given form to the given value. - tc.formvalue(str(form), str(i+1), ",".join(value) ) - else: - try: - for elem in value: - tc.formvalue(str(form), str(i+1), str(elem) ) - except Exception, exc: - errmsg = "Attempting to set field '%s' to value '%s' threw exception: '%s'\n" % ( str( key ), str( elem ), str( exc ) ) - errmsg += "control: %s\n" % str( control ) - errmsg += "If the above control is a DataToolparameter whose data type class does not include a sniff() method,\n" - errmsg += "make sure to include a proper 'ftype' attribute to the tag for the control within the <test> tag set.\n" - raise AssertionError( errmsg ) - break - tc.submit(button) + # No refresh_on_change attribute found in current form, so process as usual + for control_name, control_value in kwd.items(): + if not isinstance( control_value, list ): + control_value = [ control_value ] + try: + control = f.find_control( name=control_name ) + except: + # This assumes we always want the first control of the given name, + # which may not be ideal... + control = f.find_control( name=control_name, nr=0 ) + control.clear() + if control.is_of_kind( "text" ): + tc.fv( f.name, control.name, ",".join( control_value ) ) + elif control.is_of_kind( "list" ): + try: + if control.is_of_kind( "multilist" ): + for elem in control_value: + control.get( name=elem ).selected = True + else: # control.is_of_kind( "singlelist" ) + for elem in control_value: + tc.fv( f.name, control.name, str( elem ) ) + except Exception, exc: + errmsg = "Attempting to set field '%s' to value '%s' in form '%s' threw exception: %s\n" % ( control_name, str( control_value ), f.name, str( exc ) ) + errmsg += "control: %s\n" % str( control ) + errmsg += "If the above control is a DataToolparameter whose data type class does not include a sniff() method,\n" + errmsg += "make sure to include a proper 'ftype' attribute to the tag for the control within the <test> tag set.\n" + raise AssertionError( errmsg ) + else: + # Add conditions for other control types here when necessary. + pass + tc.submit( button )
def visit_page( self, page ): tc.go("./%s" % page) @@ -493,8 +507,8 @@ tool_id = tool_id.replace(" ", "+") """Runs the tool 'tool_id' and passes it the key/values from the *kwd""" self.visit_url( "%s/tool_runner/index?tool_id=%s" % (self.url, tool_id) ) - tc.find('runtool_btn') - self.submit_form(**kwd) + tc.find( 'runtool_btn' ) + self.submit_form( **kwd )
def wait( self, maxiter=20 ): """Waits for the tools to finish""" diff -r d7e7804572fd -r e85d660c46ee test/functional/__init__.py --- a/test/functional/__init__.py Thu Sep 04 12:19:32 2008 -0400 +++ b/test/functional/__init__.py Fri Sep 05 16:36:51 2008 -0400 @@ -2,7 +2,7 @@
import pkg_resources
-pkg_resources.require( "twill==0.8.3" ) +pkg_resources.require( "twill==0.9" ) pkg_resources.require( "Paste" ) pkg_resources.require( "PasteDeploy" ) pkg_resources.require( "Cheetah" ) diff -r d7e7804572fd -r e85d660c46ee test/functional/test_metadata_editing.py --- a/test/functional/test_metadata_editing.py Thu Sep 04 12:19:32 2008 -0400 +++ b/test/functional/test_metadata_editing.py Fri Sep 05 16:36:51 2008 -0400 @@ -9,17 +9,17 @@ self.check_history_for_string('? bed') self.check_metadata_for_string('1.bed uploaded file unspecified (?) chromCol value="1" selected endCol value="3" is_strandCol value="true" checked', hid=1) """test editing attributes""" - self.edit_metadata(hid=1, form=1, name='Testdata', info="Uploaded my file", dbkey='hg16', startCol='6') + self.edit_metadata(hid=1, form_no=0, name='Testdata', info="Uploaded my file", dbkey='hg16', startCol='6') self.check_metadata_for_string('Testdata bed Uploaded my file hg16 "bed" selected="yes" "startCol" value="6" selected', hid=1) """test Auto-detecting attributes""" - self.edit_metadata(hid=1, form=2) + self.edit_metadata(hid=1, form_no=1) self.check_metadata_for_string('Testdata bed Uploaded my file hg16 "bed" selected="yes" "startCol" value="2" selected', hid=1) """test converting formats""" - self.edit_metadata(hid=1, form=3, target_type='gff') + self.edit_metadata(hid=1, form_no=2, target_type='gff') self.check_history_for_string('hg16 Testdata Convert BED to GFF') self.check_metadata_for_string('"gff" selected="yes"', hid=1) """test changing data type""" - self.edit_metadata(hid=1, form=4, datatype='gff3') + self.edit_metadata(hid=1, form_no=3, datatype='gff3') self.check_history_for_string('hg16 Testdata Convert BED to GFF format: gff3') self.delete_history_item( 1 ) def test_9999_clean_up( self ): diff -r d7e7804572fd -r e85d660c46ee tools/annotation_profiler/annotation_profiler.xml --- a/tools/annotation_profiler/annotation_profiler.xml Thu Sep 04 12:19:32 2008 -0400 +++ b/tools/annotation_profiler/annotation_profiler.xml Fri Sep 05 16:36:51 2008 -0400 @@ -30,7 +30,7 @@ <test> <param name="input1" value="3.bed" dbkey="hg18"/> <param name="keep_empty" value=""/> - <param name="summary" value="-S"/> + <param name="summary" value="Summary"/> <param name="table_names" value="acembly,affyGnf1h,affyHuEx1,knownAlt,knownGene,mrna,multiz17way,multiz28way,refGene,snp126"/> <output name="out_file1" file="annotation_profiler_2.out" /> </test> diff -r d7e7804572fd -r e85d660c46ee tools/filters/joiner.xml --- a/tools/filters/joiner.xml Thu Sep 04 12:19:32 2008 -0400 +++ b/tools/filters/joiner.xml Fri Sep 05 16:36:51 2008 -0400 @@ -33,8 +33,8 @@ <param name="input2" value="2.bed"/> <param name="field1" value="2"/> <param name="field2" value="2"/> - <param name="unmatched" value="-u"/> - <param name="partial" value="-p"/> + <param name="unmatched" value="Yes"/> + <param name="partial" value="Yes"/> <output name="out_file1" file="joiner_out2.bed"/> </test> </tests> diff -r d7e7804572fd -r e85d660c46ee tools/new_operations/intersect.xml --- a/tools/new_operations/intersect.xml Thu Sep 04 12:19:32 2008 -0400 +++ b/tools/new_operations/intersect.xml Fri Sep 05 16:36:51 2008 -0400 @@ -33,7 +33,7 @@ <param name="input1" value="1.bed" /> <param name="input2" value="2.bed" /> <param name="min" value="10" /> - <param name="returntype" value="-p" /> + <param name="returntype" value="Overlapping pieces of Intervals" /> <output name="output" file="gops_intersect_p_out.bed" /> </test> <test> diff -r d7e7804572fd -r e85d660c46ee tools/new_operations/subtract.xml --- a/tools/new_operations/subtract.xml Thu Sep 04 12:19:32 2008 -0400 +++ b/tools/new_operations/subtract.xml Fri Sep 05 16:36:51 2008 -0400 @@ -43,7 +43,7 @@ <param name="input1" value="1.bed" /> <param name="input2" value="2.bed" /> <param name="min" value="10" /> - <param name="returntype" value="-p" /> + <param name="returntype" value="Non-overlapping pieces of intervals" /> <output name="output" file="gops-subtract-p.dat" /> </test> </tests>
galaxy-dev@lists.galaxyproject.org