def test_optional_array_prefixes(self): t = ToolInput( "filesD", Array(String(), optional=True), prefix="-D", prefix_applies_to_all_elements=True, ) cwltoolinput = cwl.translate_tool_input(t, None) self.assertDictEqual( { "id": "filesD", "label": "filesD", "inputBinding": {}, "type": [ { "inputBinding": { "prefix": "-D" }, "items": "string", "type": "array", }, "null", ], }, dict(cwltoolinput.save()), )
def test_separated_input_bindingin(self): t = ToolInput( "filesC", Array(String()), prefix="-C=", separate_value_from_prefix=False, position=4, separator=",", ) cwltoolinput = cwl.translate_tool_input(t, None) self.assertDictEqual( { "id": "filesC", "label": "filesC", "type": { "items": "string", "type": "array" }, "inputBinding": { "prefix": "-C=", "itemSeparator": ",", "separate": False, "position": 4, }, }, cwltoolinput.save(), )
def test_nested_input_binding(self): t = ToolInput( "filesB", Array(String()), prefix="-B=", separate_value_from_prefix=False, position=2, prefix_applies_to_all_elements=True, ) cwltoolinput = cwl.translate_tool_input(t, None) self.assertDictEqual( { "id": "filesB", "label": "filesB", "type": { "items": "string", "type": "array", "inputBinding": { "prefix": "-B=", "separate": False }, }, "inputBinding": { "position": 2 }, }, cwltoolinput.save(), )
def test_regular_input_bindingin(self): t = ToolInput("filesA", Array(String()), prefix="-A", position=1) cwltoolinput = cwl.translate_tool_input(t, None, None).save() self.assertDictEqual( { "id": "filesA", "label": "filesA", "type": {"items": "string", "type": "array"}, "inputBinding": {"prefix": "-A", "position": 1}, }, cwltoolinput, )
def test_1(self): tool = FilenameGeneratedTool() inputsdict = {t.id(): t for t in tool.inputs()} mapped = [cwl.translate_tool_input(i, inputsdict, tool) for i in tool.inputs()] expressions = [ mapped[i].save()["inputBinding"]["valueFrom"] for i in range(4, len(mapped)) ] self.assertEqual("$(inputs.inp)", expressions[0]) self.assertEqual( '$(inputs.inpOptional ? inputs.inpOptional : "generated")', expressions[1] ) self.assertEqual( '$(inputs.fileInp.basename.replace(/.txt$/, "")).transformed.fnp', expressions[2], ) self.assertEqual( '$(inputs.fileInpOptional ? inputs.fileInpOptional.basename.replace(/.txt$/, "") : "generated").optional.txt', expressions[3], )