mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-25 10:24:38 +08:00
PEP-8 fixes related to tool test parsing.
This commit is contained in:
@@ -1574,7 +1574,7 @@ class Tool( object, Dictifiable ):
|
||||
# history, but we'll keep it unique per set of tests
|
||||
composite_data_names_counter = 0
|
||||
for i, test_elem in enumerate( tests_elem.findall( 'test' ) ):
|
||||
name = test_elem.get( 'name', 'Test-%d' % (i+1) )
|
||||
name = test_elem.get( 'name', 'Test-%d' % (i + 1) )
|
||||
maxseconds = int( test_elem.get( 'maxseconds', '120' ) )
|
||||
test = ToolTestBuilder( self, name, maxseconds )
|
||||
try:
|
||||
@@ -1625,6 +1625,7 @@ class Tool( object, Dictifiable ):
|
||||
raise Exception( "Test output does not have a 'name'" )
|
||||
assert_elem = output_elem.find("assert_contents")
|
||||
assert_list = None
|
||||
|
||||
# Trying to keep testing patch as localized as
|
||||
# possible, this function should be relocated
|
||||
# somewhere more conventional.
|
||||
@@ -1636,7 +1637,7 @@ class Tool( object, Dictifiable ):
|
||||
converted_children = []
|
||||
for child_elem in child_elems:
|
||||
converted_children.append( convert_elem(child_elem) )
|
||||
return {"tag" : tag, "attributes" : attributes, "children" : converted_children}
|
||||
return {"tag": tag, "attributes": attributes, "children": converted_children}
|
||||
if assert_elem is not None:
|
||||
assert_list = []
|
||||
for assert_child in list(assert_elem):
|
||||
@@ -1677,6 +1678,7 @@ class Tool( object, Dictifiable ):
|
||||
test.error = True
|
||||
test.exception = e
|
||||
self.tests.append( test )
|
||||
|
||||
def parse_input_page( self, input_elem, enctypes ):
|
||||
"""
|
||||
Parse a page of inputs. This basically just calls 'parse_input_elem',
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
import new, sys
|
||||
import os.path
|
||||
import galaxy.util
|
||||
import parameters
|
||||
from parameters import basic
|
||||
from parameters import grouping
|
||||
from elementtree.ElementTree import XML
|
||||
import logging
|
||||
|
||||
log = logging.getLogger( __name__ )
|
||||
|
||||
|
||||
class ToolTestBuilder( object ):
|
||||
"""
|
||||
Encapsulates information about a tool test, and allows creation of a
|
||||
dynamic TestCase class (the unittest framework is very class oriented,
|
||||
doing dynamic tests in this way allows better integration)
|
||||
"""
|
||||
|
||||
def __init__( self, tool, name, maxseconds ):
|
||||
self.tool = tool
|
||||
self.name = name
|
||||
@@ -24,6 +22,7 @@ class ToolTestBuilder( object ):
|
||||
self.outputs = []
|
||||
self.error = False
|
||||
self.exception = None
|
||||
|
||||
def add_param( self, name, value, extra ):
|
||||
try:
|
||||
if name not in self.tool.inputs:
|
||||
@@ -43,8 +42,10 @@ class ToolTestBuilder( object ):
|
||||
except Exception, e:
|
||||
log.debug( "Error for tool %s: could not add test parameter %s. %s" % ( self.tool.id, name, e ) )
|
||||
self.inputs.append( ( name, value, extra ) )
|
||||
|
||||
def add_output( self, name, file, extra ):
|
||||
self.outputs.append( ( name, file, extra ) )
|
||||
|
||||
def __expand_grouping_for_data_input( self, name, value, extra, grouping_name, grouping_value ):
|
||||
# Currently handles grouping.Conditional and grouping.Repeat
|
||||
if isinstance( grouping_value, grouping.Conditional ):
|
||||
@@ -93,20 +94,21 @@ class ToolTestBuilder( object ):
|
||||
if found_parameter:
|
||||
return True, new_value
|
||||
return False, value
|
||||
|
||||
def __add_uploaded_dataset( self, name, value, extra, input_parameter ):
|
||||
if value is None:
|
||||
assert input_parameter.optional, '%s is not optional. You must provide a valid filename.' % name
|
||||
return value
|
||||
if ( value, extra ) not in self.required_files:
|
||||
self.required_files.append( ( value, extra ) ) #these files will be uploaded
|
||||
self.required_files.append( ( value, extra ) ) # these files will be uploaded
|
||||
name_change = [ att for att in extra.get( 'edit_attributes', [] ) if att.get( 'type' ) == 'name' ]
|
||||
if name_change:
|
||||
name_change = name_change[-1].get( 'value' ) #only the last name change really matters
|
||||
value = name_change #change value for select to renamed uploaded file for e.g. composite dataset
|
||||
name_change = name_change[-1].get( 'value' ) # only the last name change really matters
|
||||
value = name_change # change value for select to renamed uploaded file for e.g. composite dataset
|
||||
else:
|
||||
for end in [ '.zip', '.gz' ]:
|
||||
if value.endswith( end ):
|
||||
value = value[ :-len( end ) ]
|
||||
break
|
||||
value = os.path.basename( value ) #if uploading a file in a path other than root of test-data
|
||||
value = os.path.basename( value ) # if uploading a file in a path other than root of test-data
|
||||
return value
|
||||
|
||||
Reference in New Issue
Block a user