Esempio n. 1
0
def test_input_value_wrapper(tool):
    parameter = IntegerToolParameter(
        tool,
        XML('<param name="blah" type="integer" size="4" value="10" min="0" />')
    )
    wrapper = InputValueWrapper(parameter, "5")
    assert str(wrapper) == "5"
Esempio n. 2
0
def test_input_value_wrapper_comparison_optional(tool):
    parameter = IntegerToolParameter(
        tool,
        XML('<param name="blah" type="integer" min="0" optional="true"/>'))
    wrapper = InputValueWrapper(parameter, None)
    assert not wrapper
    with pytest.raises(ValueError):
        int(wrapper)
    assert str(wrapper) == ""
    assert wrapper == ""  # for backward-compatibility
    parameter = IntegerToolParameter(
        tool,
        XML('<param name="blah" type="integer" min="0" optional="true"/>'))
    wrapper = InputValueWrapper(parameter, 0)
    assert wrapper == 0
    assert int(wrapper) == 0
    assert str(wrapper)
    assert wrapper != ""  # for backward-compatibility, the correct way to check if an optional integer param is not empty is to use str(wrapper)
Esempio n. 3
0
def valuewrapper(tool, value, paramtype, optional=False):
    if paramtype == "integer":
        optional = 'optional="true"' if optional else 'value="10"'
        parameter = IntegerToolParameter(tool, XML('<param name="blah" type="integer" %s min="0" />' % optional))
    elif paramtype == "text":
        optional = 'optional="true"' if optional else 'value="foo"'
        parameter = TextToolParameter(tool, XML('<param name="blah" type="text" %s/>' % optional))
    elif paramtype == "float":
        optional = 'optional="true"' if optional else 'value="10.0"'
        parameter = FloatToolParameter(tool, XML('<param name="blah" type="float" %s/>' % optional))
    elif paramtype == "boolean":
        optional = 'optional="true"' if optional else 'value=""'
        parameter = BooleanToolParameter(tool, XML('<param name="blah" type="boolean" truevalue="truevalue" falsevalue="falsevalue" %s/>' % optional))
    return InputValueWrapper(parameter, value)
Esempio n. 4
0
def valuewrapper(tool, value, paramtype):
    if paramtype == "integer":
        parameter = IntegerToolParameter(
            tool,
            XML('<param name="blah" type="integer" value="10" min="0" />'))
    elif paramtype == "text":
        parameter = TextToolParameter(
            tool, XML('<param name="blah" type="text" value="foo"/>'))
    elif paramtype == "float":
        parameter = FloatToolParameter(
            tool, XML('<param name="blah" type="float" value="10.0"/>'))
    elif paramtype == "boolean":
        parameter = BooleanToolParameter(
            tool,
            XML('<param name="blah" type="boolean" truevalue="truevalue" falsevalue="falsevalue"/>'
                ))
    return InputValueWrapper(parameter, value)
Esempio n. 5
0
 def test_thresh_param(self):
     elem = XML('<param name="thresh" type="integer" value="5" />')
     return IntegerToolParameter(self, elem)