mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Enhance functional test framework so that a boolean form field ( checkbox ) can have a false value ( be unchecked ). Add a 2nd test to gops_concat that uses this behavior.
This commit is contained in:
@@ -857,8 +857,28 @@ class TwillTestCase( unittest.TestCase ):
|
||||
elif control.is_of_kind( "list" ):
|
||||
try:
|
||||
if control.is_of_kind( "multilist" ):
|
||||
for elem in control_value:
|
||||
control.get( name=elem ).selected = True
|
||||
if control.type == "checkbox":
|
||||
def is_checked( value ):
|
||||
# Copied from form_builder.CheckboxField
|
||||
if value == True:
|
||||
return True
|
||||
if isinstance( value, basestring ) and value.lower() in ( "yes", "true", "on" ):
|
||||
return True
|
||||
# This may look strange upon initial inspection, but see the comments in the get_html() method
|
||||
# above for clarification. Basically, if value is not True, then it will always be a list with
|
||||
# 2 input fields ( a checkbox and a hidden field ) if the checkbox is checked. If it is not
|
||||
# checked, then value will be only the hidden field.
|
||||
return isinstance( value, list ) and len( value ) == 2
|
||||
try:
|
||||
checkbox = control.get()
|
||||
checkbox.selected = is_checked( control_value )
|
||||
except ClientForm.AmbiguityError:
|
||||
# if there's more than one checkbox, use the behaviour for
|
||||
# ClientForm.ListControl - see twill code..
|
||||
pass
|
||||
else:
|
||||
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 ) )
|
||||
|
||||
@@ -20,8 +20,14 @@
|
||||
<param name="input1" value="1.bed" />
|
||||
<param name="input2" value="2.bed" />
|
||||
<param name="sameformat" value="true" />
|
||||
<output name="output" file="gops-concat.dat" />
|
||||
</test>
|
||||
<output name="output" file="gops_concat_out1.bed" />
|
||||
</test>
|
||||
<test>
|
||||
<param name="input1" value="1.bed" />
|
||||
<param name="input2" value="1.interval" />
|
||||
<param name="sameformat" value="false" />
|
||||
<output name="output" file="gops_concat_out2.bed" />
|
||||
</test>
|
||||
</tests>
|
||||
<help>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user