Пример #1
0
    def __test_arbitrary_path_rewriting( self ):
        self.job.parameters = [ JobParameter( name="index_path", value="\"/old/path/human\"" ) ]
        xml = XML('''<param name="index_path" type="select">
            <option value="/old/path/human">Human</option>
            <option value="/old/path/mouse">Mouse</option>
        </param>''')
        parameter = SelectToolParameter( self.tool, xml )

        def get_field_by_name_for_value( name, value, trans, other_values ):
            assert value == "/old/path/human"
            assert name == "path"
            return ["/old/path/human"]

        def get_options( trans, other_values ):
            return [ [ "", "/old/path/human", "" ] ]

        parameter.options = Bunch(get_field_by_name_for_value=get_field_by_name_for_value, get_options=get_options)
        self.tool.set_params( {
            "index_path": parameter
        } )
        self.tool._command_line = "prog1 $index_path.fields.path"

        def test_path_rewriter(v):
            if v:
                v = v.replace("/old", "/new")
            return v
        self._set_compute_environment(path_rewriter=test_path_rewriter)
        command_line, extra_filenames, _ = self.evaluator.build( )
        self.assertEquals(command_line, "prog1 /new/path/human")
Пример #2
0
    def __test_arbitrary_path_rewriting(self):
        self.job.parameters = [
            JobParameter(name="index_path", value="\"/old/path/human\"")
        ]
        xml = XML('''<param name="index_path" type="select">
            <option value="/old/path/human">Human</option>
            <option value="/old/path/mouse">Mouse</option>
        </param>''')
        parameter = SelectToolParameter(self.tool, xml)

        def get_field_by_name_for_value(name, value, trans, other_values):
            assert value == "/old/path/human"
            assert name == "path"
            return ["/old/path/human"]

        parameter.options = Bunch(
            get_field_by_name_for_value=get_field_by_name_for_value)
        self.tool.set_params({"index_path": parameter})
        self.tool._command_line = "prog1 $index_path.fields.path"

        def test_path_rewriter(v):
            if v:
                v = v.replace("/old", "/new")
            return v

        self._set_compute_environment(path_rewriter=test_path_rewriter)
        command_line, extra_filenames = self.evaluator.build()
        self.assertEquals(command_line, "prog1 /new/path/human")
Пример #3
0
    def __test_arbitrary_path_rewriting(self):
        self.job.parameters = [
            JobParameter(name="index_path", value="\"/old/path/human\"")
        ]
        xml = XML('''<param name="index_path" type="select">
            <option value="/old/path/human">Human</option>
            <option value="/old/path/mouse">Mouse</option>
        </param>''')
        parameter = SelectToolParameter(self.tool, xml)

        def get_field_by_name_for_value(name, value, trans, other_values):
            assert value == "/old/path/human"
            assert name == "path"
            return ["/old/path/human"]

        def get_options(trans, other_values):
            return [["", "/old/path/human", ""]]

        parameter.options = Bunch(
            get_field_by_name_for_value=get_field_by_name_for_value,
            get_options=get_options)
        self.tool.set_params({"index_path": parameter})
        self.tool._command_line = "prog1 $index_path.fields.path"
        self._set_compute_environment(
            unstructured_path_rewrites={"/old": "/new"})
        command_line = self.evaluator.build()[0]
        self.assertEqual(command_line, "prog1 /new/path/human")