From ea9a819235362156d26e614d6e6bf3322f97b408 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Thu, 8 Mar 2007 18:14:50 +0000 Subject: [PATCH] Working on getting tests going again. Modified the history.xml template to only return active datasets so deletes should test correctly again. --- lib/galaxy/tools/__init__.py | 11 ++++--- lib/galaxy/tools/test.py | 13 ++------ templates/history.xml | 2 +- test/functional/test_3A_GetData.py | 50 +++++++++++++++--------------- test/functional/test_toolbox.py | 29 +++++------------ 5 files changed, 42 insertions(+), 63 deletions(-) diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index baf8829599b..b7dc54adab4 100644 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -8,7 +8,7 @@ from cookbook.patterns import Bunch from galaxy import util, jobs from elementtree import ElementTree from parameters import * -from galaxy.tools.test import ToolTestBuilder, BadToolTest +from galaxy.tools.test import ToolTestBuilder log = logging.getLogger( __name__ ) @@ -245,8 +245,8 @@ class Tool: self.tests = [] for i, test_elem in enumerate( tests_elem.findall( 'test' ) ): name = test_elem.get( 'name', 'Test-%d' % (i+1) ) + test = ToolTestBuilder( self, name ) try: - test = ToolTestBuilder( self, name ) for param_elem in test_elem.findall( "param" ): attrib = dict( param_elem.attrib ) if 'values' in attrib: @@ -265,10 +265,11 @@ class Tool: if file is None: raise Exception( "Test output does not have a 'file'") test.add_output( name, file ) - self.tests.append( test ) except Exception, e: - self.tests.append( BadToolTest( self, name, e ) ) - + test.error = True + test.exception = e + self.tests.append( test ) + def parse_page( self, input_elem, enctypes ): param_map = odict() for param_elem in input_elem.findall("param"): diff --git a/lib/galaxy/tools/test.py b/lib/galaxy/tools/test.py index b85c31d2edf..d9269e2ce2e 100644 --- a/lib/galaxy/tools/test.py +++ b/lib/galaxy/tools/test.py @@ -14,18 +14,11 @@ class ToolTestBuilder( object ): self.required_files = [] self.inputs = [] self.outputs = [] + self.error = False + self.exception = None def add_param( self, name, value, extra ): if isinstance( self.tool.param_map[name], parameters.DataToolParameter ): self.required_files.append( ( value, extra ) ) self.inputs.append( ( name, value, extra ) ) def add_output( self, name, file ): - self.outputs.append( ( name, file ) ) - -class BadToolTest( object ): - """ - Represents a tool test that failed to parse - """ - def __init__( self, tool, name, exception=None ): - self.tool = tool - self.name = name - self.exception = exception \ No newline at end of file + self.outputs.append( ( name, file ) ) \ No newline at end of file diff --git a/templates/history.xml b/templates/history.xml index bd6e36d9561..7d0437e5982 100644 --- a/templates/history.xml +++ b/templates/history.xml @@ -1,6 +1,6 @@ -#for $data in $history.datasets +#for $data in $history.active_datasets $data.blurb diff --git a/test/functional/test_3A_GetData.py b/test/functional/test_3A_GetData.py index fa75b550d6d..b2d2f522b6d 100644 --- a/test/functional/test_3A_GetData.py +++ b/test/functional/test_3A_GetData.py @@ -28,29 +28,29 @@ class UcscTests(TwillTestCase): self.wait() self.check_data('3A_GetData_ucsc_bed_range.dat', hid=1) - def test_30_Biomart_Uniprot(self): - """3A_GetData: Connection to Biomart""" - #All this test does, is check to see if biomart is accessible through Galaxy. A dataset is never retrieved or checked. - - # some button indices are hardcoded (twill limitation) - self.run_tool('biomart') - - self.submit_form(form='mainform', button='get_count_button', - dataBase='default____UNIPROT PROTOTYPE 4-5 (EBI)', dataset='uniprot' - ) - - #self.submit_form(form='settings', button='stage_filter', - # database='UNIPROTPROTOTYPE4-5(EBI)__default', dataset='uniprot' - #) - - #self.submit_form(form='settings', button=6, - # uniprot_collection_start=1, uniprot_collection_end=1, - # uniprot_component_start=1000, uniprot_component_end=2000 - #) - - #self.submit_form(form='settings', button=5, - # outtype='Features', outformat='tsv' - #) - - #self.check_data('biomart_uniprot.dat') + # def test_30_Biomart_Uniprot(self): + # """3A_GetData: Connection to Biomart""" + # #All this test does, is check to see if biomart is accessible through Galaxy. A dataset is never retrieved or checked. + # + # # some button indices are hardcoded (twill limitation) + # self.run_tool('biomart') + # + # self.submit_form(form='mainform', button='get_count_button', + # dataBase='default____UNIPROT PROTOTYPE 4-5 (EBI)', dataset='uniprot' + # ) + # + # #self.submit_form(form='settings', button='stage_filter', + # # database='UNIPROTPROTOTYPE4-5(EBI)__default', dataset='uniprot' + # #) + # + # #self.submit_form(form='settings', button=6, + # # uniprot_collection_start=1, uniprot_collection_end=1, + # # uniprot_component_start=1000, uniprot_component_end=2000 + # #) + # + # #self.submit_form(form='settings', button=5, + # # outtype='Features', outformat='tsv' + # #) + # + # #self.check_data('biomart_uniprot.dat') diff --git a/test/functional/test_toolbox.py b/test/functional/test_toolbox.py index 39cfde16f4a..f60e2310667 100644 --- a/test/functional/test_toolbox.py +++ b/test/functional/test_toolbox.py @@ -9,6 +9,12 @@ class ToolTestCase( TwillTestCase ): Abstract test case that runs tests based on a `galaxy.tools.test.ToolTest` """ def do_it( self ): + # If the test generation had an error, raise + if self.testdef.error: + if self.testdef.exception: + raise self.testdef.exception + else: + raise Exception( "Test parse failure" ) # Start with an empty history self.clear_history() # Upload any needed files @@ -31,13 +37,6 @@ class ToolTestCase( TwillTestCase ): self.check_data( file ) def shortDescription( self ): return self.name - -class BadToolTestCase( TwillTestCase ): - def do_it( self ): - if self.testdef.exception: - raise self.testdef.exception - else: - raise Exception( "Test parse failure" ) def get_testcase( testdef, name ): """ @@ -49,17 +48,6 @@ def get_testcase( testdef, name ): self.do_it() d = dict( testdef=testdef, test_tool=test_tool, name=name ) return new.classobj( n, s, d ) - -def get_badtestcase( testdef, name ): - """ - Dynamically generate a `BadToolTestCase` for `testdef` - """ - n = "GeneratedToolTestCase_" + testdef.tool.id.replace( ' ', '_' ) - s = ( BadToolTestCase, ) - def test_tool( self ): - self.do_it() - d = dict( testdef=testdef, test_tool=test_tool, name=name ) - return new.classobj( n, s, d ) def setup(): """ @@ -76,8 +64,5 @@ def setup(): if tool.tests: for k, testdef in enumerate( tool.tests ): name = "%s > %s > %s" % ( section.name, tool.name, testdef.name ) - if isinstance( testdef, BadToolTest ): - testcase = get_badtestcase( testdef, name ) - else: - testcase = get_testcase( testdef, name ) + testcase = get_testcase( testdef, name ) G[ 'testcase_%d_%d_%d' % ( i, j, k ) ] = testcase \ No newline at end of file