def make_parameter_meta(self, named: Iterable[NamedArgument]) -> ParameterMeta: params = {} for named_arg in named: params[named_arg.name] = escape_wdl_str(named_arg.arg.description) return ParameterMeta(**params)
def test_parameter_meta_obj(self): w = Workflow( "param_meta_obj", parameter_meta=ParameterMeta( obj_value=ParameterMeta.ParamMetaAttribute( help="This is help text", scalar=96)), ) expected = """\ workflow param_meta_obj { parameter_meta { obj_value: {help: "This is help text", scalar: 96} } }""" derived_workflow_only = "".join( w.get_string().splitlines(keepends=True)[4:]) self.assertEqual(expected, derived_workflow_only)
def test_parameter_meta_scalar(self): w = Task("param_meta_scalar", parameter_meta=ParameterMeta(test=42)) expected = """\ task param_meta_scalar { parameter_meta { test: 42 } }""" derived_workflow_only = "".join( w.get_string().splitlines(keepends=True)[2:]) self.assertEqual(expected, derived_workflow_only)
def test_parameter_meta_string(self): w = Workflow("param_meta_string", parameter_meta=ParameterMeta(other="string value")) expected = """\ workflow param_meta_string { parameter_meta { other: "string value" } }""" derived_workflow_only = "".join( w.get_string().splitlines(keepends=True)[4:]) self.assertEqual(expected, derived_workflow_only)
def test_parameter_meta_bool(self): w = Workflow("param_meta_scalar", parameter_meta=ParameterMeta(pos=True, neg=False)) expected = """\ workflow param_meta_scalar { parameter_meta { pos: true neg: false } }""" derived_task_only = "".join( w.get_string().splitlines(keepends=True)[4:]) self.assertEqual(expected, derived_task_only)
def test_parameter_meta_dict(self): w = Task( "param_meta_obj", parameter_meta=ParameterMeta(obj_value={ "help": "This is help text", "scalar": 96 }), ) expected = """\ task param_meta_obj { parameter_meta { obj_value: {help: "This is help text", scalar: 96} } }""" derived_workflow_only = "".join( w.get_string().splitlines(keepends=True)[2:]) self.assertEqual(expected, derived_workflow_only)
def test_quote_sanitise(self): meta = ParameterMeta(foo='"bar"').get_string() self.assertEqual('foo: "\\"bar\\""', meta)
def test_backslackquote_sanitise(self): meta = ParameterMeta(foo='bar\\"').get_string() self.assertEqual('foo: "bar\\\\\\""', meta)
def test_nl_sanitise(self): meta = ParameterMeta(foo="bar\nbaz").get_string() self.assertEqual('foo: "bar\\nbaz"', meta)