3 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/7eeb2a0f5a97/ Changeset: 7eeb2a0f5a97 User: jmchilton Date: 2014-12-10 16:49:50+00:00 Summary: force_history_refresh does nothing so I am just setting it False in tool. (TODO: Update planemo linter to mark this as a problem.) Affected #: 1 file diff -r 01a3ff6a376c4b95ca540bc120b5aab47920fd39 -r 7eeb2a0f5a977d88c506bf1365c8bb46b5897354 lib/galaxy/tools/__init__.py --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -1410,10 +1410,8 @@ self.version = "1.0.0" # Support multi-byte tools self.is_multi_byte = string_as_bool( root.get( "is_multi_byte", False ) ) - # Force history to fully refresh after job execution for this tool. - # Useful i.e. when an indeterminate number of outputs are created by - # a tool. - self.force_history_refresh = string_as_bool( root.get( 'force_history_refresh', 'False' ) ) + # Legacy feature, ignored by UI. + self.force_history_refresh = False self.display_interface = string_as_bool( root.get( 'display_interface', str( self.display_interface ) ) ) self.require_login = string_as_bool( root.get( 'require_login', str( self.require_login ) ) ) # Load input translator, used by datasource tools to change names/values of incoming parameters https://bitbucket.org/galaxy/galaxy-central/commits/05533cd3509f/ Changeset: 05533cd3509f User: jmchilton Date: 2014-12-10 16:49:50+00:00 Summary: Small PEP-8 fix for Tool.parse_inputs. Affected #: 1 file diff -r 7eeb2a0f5a977d88c506bf1365c8bb46b5897354 -r 05533cd3509f1e23f514fc5190467580824f0b37 lib/galaxy/tools/__init__.py --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -1580,11 +1580,11 @@ # template. if self.nginx_upload and self.app.config.nginx_upload_path: if '?' in urllib.unquote_plus( self.action ): - raise Exception( 'URL parameters in a non-default tool action can not be used ' \ - 'in conjunction with nginx upload. Please convert them to ' \ + raise Exception( 'URL parameters in a non-default tool action can not be used ' + 'in conjunction with nginx upload. Please convert them to ' 'hidden POST parameters' ) self.action = (self.app.config.nginx_upload_path + '?nginx_redir=', - urllib.unquote_plus(self.action)) + urllib.unquote_plus(self.action)) self.target = input_elem.get( "target", self.target ) self.method = input_elem.get( "method", self.method ) # Parse the actual parameters https://bitbucket.org/galaxy/galaxy-central/commits/d66ad58a40e3/ Changeset: d66ad58a40e3 User: jmchilton Date: 2014-12-10 16:49:50+00:00 Summary: Unit testing explicitly related to parsing of XML for parameters. Cleans up some existing tests and does some de-duplication as well. Affected #: 4 files diff -r 05533cd3509f1e23f514fc5190467580824f0b37 -r d66ad58a40e31defb6de0eb8b8b543b7e0f26ae5 test/unit/tools/test_column_parameters.py --- a/test/unit/tools/test_column_parameters.py +++ b/test/unit/tools/test_column_parameters.py @@ -2,16 +2,12 @@ test_select_parameters.py. """ -from unittest import TestCase -from galaxy.tools.parameters import basic from galaxy.util import bunch from galaxy import model -from elementtree.ElementTree import XML +from .test_parameter_parsing import BaseParameterTestCase -import tools_support - -class DataColumnParameterTestCase( TestCase, tools_support.UsesApp ): +class DataColumnParameterTestCase( BaseParameterTestCase ): def test_not_optional_by_default(self): assert not self.__param_optional() @@ -62,11 +58,7 @@ self.assertEqual( '2', self.param.get_initial_value( self.trans, { "input_tsv": self.build_ready_hda() } ) ) def setUp( self ): - self.setup_app( mock_model=False ) - self.mock_tool = bunch.Bunch( - app=self.app, - tool_type="default", - ) + super(DataColumnParameterTestCase, self).setUp() self.test_history = model.History() self.app.model.context.add( self.test_history ) self.app.model.context.flush() @@ -105,8 +97,8 @@ if self.set_data_ref: data_ref_text = 'data_ref="input_tsv"' template_xml = '''<param name="my_name" type="%s" %s %s %s %s></param>''' - self.param_xml = XML( template_xml % ( self.type, data_ref_text, multi_text, optional_text, self.other_attributes ) ) - self._param = basic.ColumnListParameter( self.mock_tool, self.param_xml ) + param_str = template_xml % ( self.type, data_ref_text, multi_text, optional_text, self.other_attributes ) + self._param = self._parameter_for( xml=param_str ) self._param.ref_input = bunch.Bunch(formats=[model.datatypes_registry.get_datatype_by_extension("tabular")]) return self._param diff -r 05533cd3509f1e23f514fc5190467580824f0b37 -r d66ad58a40e31defb6de0eb8b8b543b7e0f26ae5 test/unit/tools/test_data_parameters.py --- a/test/unit/tools/test_data_parameters.py +++ b/test/unit/tools/test_data_parameters.py @@ -1,15 +1,10 @@ -from unittest import TestCase - from galaxy import model from galaxy.util import bunch -from galaxy.tools.parameters import basic -from elementtree.ElementTree import XML +from .test_parameter_parsing import BaseParameterTestCase -import tools_support - -class DataToolParameterTestCase( TestCase, tools_support.UsesApp ): +class DataToolParameterTestCase( BaseParameterTestCase ): def test_to_python_none_values( self ): assert None is self.param.to_python( None, self.app ) @@ -149,11 +144,7 @@ return hda def setUp( self ): - self.setup_app( mock_model=False ) - self.mock_tool = bunch.Bunch( - app=self.app, - tool_type="default", - ) + super(DataToolParameterTestCase, self).setUp() self.test_history = model.History() self.app.model.context.add( self.test_history ) self.app.model.context.flush() @@ -187,8 +178,8 @@ if self.optional: optional_text = 'optional="True"' template_xml = '''<param name="data2" type="data" ext="txt" %s %s></param>''' - self.param_xml = XML( template_xml % ( multi_text, optional_text ) ) - self._param = basic.DataToolParameter( self.mock_tool, self.param_xml ) + param_str = template_xml % ( multi_text, optional_text ) + self._param = self._parameter_for( tool=self.mock_tool, xml=param_str ) return self._param diff -r 05533cd3509f1e23f514fc5190467580824f0b37 -r d66ad58a40e31defb6de0eb8b8b543b7e0f26ae5 test/unit/tools/test_parameter_parsing.py --- /dev/null +++ b/test/unit/tools/test_parameter_parsing.py @@ -0,0 +1,283 @@ +from unittest import TestCase + +from galaxy.tools.parameters import basic +from galaxy.util import bunch +from elementtree.ElementTree import XML + +import tools_support + + +class BaseParameterTestCase( TestCase, tools_support.UsesApp ): + + def setUp(self): + self.setup_app( mock_model=False ) + self.mock_tool = bunch.Bunch( + app=self.app, + tool_type="default", + ) + + def _parameter_for(self, **kwds): + content = kwds["xml"] + param_xml = XML( content ) + return basic.ToolParameter.build( self.mock_tool, param_xml ) + + +class ParameterParsingTestCase( BaseParameterTestCase ): + """ Test the parsing of XML for most parameter types - in many + ways these are not very good tests since they break the abstraction + established by the tools. The docs tests in basic.py are better but + largely rely on HTML stuff we are moving to the client side so they + those tests may need to be updated anyway. + + It occurs to me that rewriting this stuff to test to_dict would + be much better - since that is a public API of the the tools. + """ + + def test_parse_help_and_label(self): + param = self._parameter_for(xml=""" + <param type="text" name="texti" size="8" value="mydefault" label="x" help="y" /> + """) + assert param.label == "x" + assert param.help == "y" + + param = self._parameter_for(xml=""" + <param type="text" name="texti" size="8" value="mydefault"> + <label>x2</label> + <help>y2</help> + </param> + """) + assert param.label == "x2" + assert param.help == "y2" + + def test_parse_sanitizers(self): + param = self._parameter_for(xml=""" + <param type="text" name="texti" size="8" value="mydefault"> + <sanitizer invalid_char=""> + <valid initial="string.digits"><add value=","/></valid> + </sanitizer> + </param> + """) + sanitizer = param.sanitizer + assert sanitizer is not None + assert sanitizer.sanitize_param("a") == "" + assert sanitizer.sanitize_param(",") == "," + + def test_parse_optional(self): + param = self._parameter_for(xml=""" + <param type="text" name="texti" size="8" value="mydefault" /> + """) + assert param.optional is False + + param = self._parameter_for(xml=""" + <param type="text" name="texti" size="8" value="mydefault" optional="true" /> + """) + assert param.optional is True + + def test_parse_validators(self): + param = self._parameter_for(xml=""" + <param type="text" name="texti" size="8" value="mydefault"> + <validator type="unspecified_build" message="no genome?" /> + </param> + """) + assert param.validators[0].message == "no genome?" + + def test_text_params(self): + param = self._parameter_for(xml=""" + <param type="text" name="texti" size="8" value="mydefault" /> + """) + assert param.size == "8" + assert param.value == "mydefault" + assert param.type == "text" + assert not param.area + + def test_text_area_params(self): + param = self._parameter_for(xml=""" + <param type="text" name="textarea" area="true" /> + """) + assert param.size is None + assert param.value is None + assert param.type == "text" + assert param.area + + def test_integer_params(self): + param = self._parameter_for(xml=""" + <param type="integer" name="intp" min="8" max="9" value="9" /> + """) + assert param.name == "intp" + assert param.value == "9" + assert param.type == "integer" + param.validate( 8 ) + self.assertRaises(Exception, lambda: param.validate( 10 )) + + def test_float_params(self): + param = self._parameter_for(xml=""" + <param type="float" name="floatp" min="7.8" max="9.5" value="9" /> + """) + assert param.name == "floatp" + assert param.value == "9" + assert param.type == "float" + param.validate( 8.1 ) + self.assertRaises(Exception, lambda: param.validate( 10.0 )) + + def test_boolean_params(self): + param = self._parameter_for(xml=""" + <param type="boolean" name="boolp" /> + """) + assert param.name == "boolp" + assert param.truevalue == "true" + assert param.falsevalue == "false" + assert param.type == "boolean" + + param = self._parameter_for(xml=""" + <param type="boolean" name="boolp" truevalue="t" falsevalue="f" /> + """) + assert param.truevalue == "t" + assert param.falsevalue == "f" + + def test_file_params(self): + param = self._parameter_for(xml=""" + <param type="file" name="filep" ajax-upload="true" /> + """) + assert param.name == "filep" + assert param.type == "file" + assert param.ajax + + def test_ftpfile_params(self): + param = self._parameter_for(xml=""" + <param type="ftpfile" name="ftpfilep" /> + """) + assert param.name == "ftpfilep" + assert param.type == "ftpfile" + + def test_hidden(self): + param = self._parameter_for(xml=""" + <param name="hiddenp" type="hidden" value="a hidden value" /> + """) + assert param.name == "hiddenp" + assert param.type == "hidden" + assert param.value == "a hidden value" + + def test_base_url(self): + param = self._parameter_for(xml=""" + <param name="urlp" type="baseurl" value="http://twitter.com/" /> + """) + assert param.name == "urlp" + assert param.type == "baseurl" + assert param.value == "http://twitter.com/" + + param = self._parameter_for(xml=""" + <param name="urlp" type="baseurl" /> + """) + assert param.value == "" + + def test_select_static(self): + param = self._parameter_for(xml=""" + <param name="selectp" type="select" multiple="true"> + <option value="a">A</option> + <option value="b" selected="true">B</option> + </param> + """) + assert param.multiple is True + assert param.name == "selectp" + assert param.type == "select" + + assert param.options is None + assert param.dynamic_options is None + assert not param.is_dynamic + + options = param.static_options + assert options[0][0] == "A" + assert options[0][1] == "a" + assert not options[0][2] + + assert options[1][0] == "B" + assert options[1][1] == "b" + assert options[1][2] + + def test_select_dynamic(self): + param = self._parameter_for(xml=""" + <param name="selectp" type="select" dynamic_options="cow"> + </param> + """) + assert param.multiple is False + assert param.options is None + assert param.dynamic_options == "cow" + ## This should be None or something - not undefined. + # assert not param.static_options + assert param.is_dynamic + + def test_select_options_from(self): + param = self._parameter_for(xml=""" + <param name="selectp" type="select"> + <options from_data_table="cow"> + </options> + </param> + """) + assert param.dynamic_options is None + assert param.is_dynamic + + # More detailed tests of dynamic options should be placed + # in test_select_parameters. + assert param.options.missing_tool_data_table_name == "cow" + + def test_genome_build(self): + param = self._parameter_for(xml=""" + <param name="genomep" type="genomebuild"> + </param> + """) + assert param.type == "genomebuild" + assert param.name == "genomep" + assert param.static_options + + # Column and Data have sufficient test coverage in + # other modules. + def test_drilldown(self): + param = self._parameter_for(xml=""" + <param name="some_name" type="drill_down" display="checkbox" hierarchy="recurse" multiple="true"> + <options> + <option name="Heading 1" value="heading1"> + <option name="Option 1" value="option1"/> + <option name="Option 2" value="option2"/> + <option name="Heading 1" value="heading1"> + <option name="Option 3" value="option3"/> + <option name="Option 4" value="option4"/> + </option> + </option> + <option name="Option 5" value="option5"/> + </options> + </param> + """) + assert param.type == "drill_down" + assert param.name == "some_name" + assert param.options + + heading1 = param.options[0] + assert heading1["selected"] is False + assert heading1["name"] == "Heading 1" + assert heading1["value"] == "heading1" + option1 = heading1["options"][0] + assert option1["selected"] is False + assert option1["name"] == "Option 1" + assert option1["value"] == "option1" + + option5 = param.options[1] + assert option5["selected"] is False + assert option5["name"] == "Option 5" + assert option5["value"] == "option5" + assert len(option5["options"]) == 0 + + def test_tool_collection(self): + param = self._parameter_for(xml=""" + <param name="datac" type="data_collection" collection_type="list" format="txt"> + </param> + """) + assert param.type == "data_collection" + assert param.collection_type == "list" + + def test_library(self): + param = self._parameter_for(xml=""" + <param name="libraryp" type="library_data"> + </param> + """) + assert param.type == "library_data" + assert param.name == "libraryp" diff -r 05533cd3509f1e23f514fc5190467580824f0b37 -r d66ad58a40e31defb6de0eb8b8b543b7e0f26ae5 test/unit/tools/test_select_parameters.py --- a/test/unit/tools/test_select_parameters.py +++ b/test/unit/tools/test_select_parameters.py @@ -1,13 +1,11 @@ -from unittest import TestCase from galaxy.util import bunch from galaxy import model from galaxy.tools.parameters import basic -from elementtree.ElementTree import XML -import tools_support +from .test_parameter_parsing import BaseParameterTestCase -class SelectToolParameterTestCase( TestCase, tools_support.UsesApp ): +class SelectToolParameterTestCase( BaseParameterTestCase ): def test_dep_dummy_datasets_need_late_validation( self ): self.options_xml = '''<options><filter type="data_meta" ref="input_bam" key="dbkey"/></options>''' @@ -51,11 +49,7 @@ # TODO: Good deal of overlap here with DataToolParameterTestCase, # refactor. def setUp( self ): - self.setup_app( mock_model=False ) - self.mock_tool = bunch.Bunch( - app=self.app, - tool_type="default", - ) + super(SelectToolParameterTestCase, self).setUp() self.test_history = model.History() self.app.model.context.add( self.test_history ) self.app.model.context.flush() @@ -88,8 +82,8 @@ if self.set_data_ref: data_ref_text = 'data_ref="input_bam"' template_xml = '''<param name="my_name" type="%s" %s %s %s>%s</param>''' - self.param_xml = XML( template_xml % ( self.type, data_ref_text, multi_text, optional_text, options_text ) ) - self._param = basic.SelectToolParameter( self.mock_tool, self.param_xml ) + param_str = template_xml % ( self.type, data_ref_text, multi_text, optional_text, options_text ) + self._param = self._parameter_for( xml=param_str ) return self._param Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.