def test_step_with_scattered_input_no_scatter_method(self): wf = WorkflowGenerator() wf.load('tests/data/tools') msgs = wf.add_input(wfmessages='string[]') wf.echo(message=msgs, scatter='message') wf.validate()
def test_step_with_compatible_input(self): wf = WorkflowGenerator() wf.load('tests/data/tools') wfmessage = wf.add_input(wfmessage='string') echoed = wf.echo(message=wfmessage) wf.validate()
def test_enum_as_workflow_input(self): wf = WorkflowGenerator() wf.add_input(input1='enum', symbols=['one', 'two', 'three']) wf.validate() obj = wf.to_obj()['inputs']['input1'] assert obj['type']['type'] == 'enum' assert obj['type']['symbols'] == ['one', 'two', 'three']
def test_label_for_workflow_input(self): wf = WorkflowGenerator() wf.add_input(input1='string', label='test label') wf.validate() obj = wf.to_obj()['inputs']['input1'] assert obj['type'] == 'string' assert obj['label'] == 'test label'
def test_optional_type(self): wf = WorkflowGenerator() wf.load('tests/data/tools') # This could work, if you pass a string for input, even if # the echo step requires an input. So we expect it to work. wfmessage = wf.add_input(message='string?') echod = wf.echo(message=wfmessage) wf.validate()
def test_step_with_scattered_step_output(self): wf = WorkflowGenerator() wf.load('tests/data/tools') msgs = wf.add_input(msgs='string[]') echoed = wf.echo(message=msgs, scatter='message', scatter_method='dotproduct') wced = wf.wc(file2count=echoed, scatter='file2count', scatter_method='dotproduct') wf.validate()
def test_scatter_method_incorrect(self): wf = WorkflowGenerator() wf.load('tests/data/tools') msgs = wf.add_input(wfmessages='string[]') wf.validate() with pytest.raises(ValueError): wf.echo(message=msgs, scatter='message', scatter_method='blah')
def test_validate_with_inline_tools(self): wf = WorkflowGenerator() wf.load('tests/data/tools') wfmessage = wf.add_input(wfmessage='string') echoed = wf.echo(message=wfmessage) echoed2 = wf.echo(message=wfmessage) wf.add_outputs(echoed2=echoed2) wf.validate(inline=True)
def test_step_with_incompatible_step_output(self): wf = WorkflowGenerator() wf.load('tests/data/tools') infile = wf.add_input(infile='File') wced = wf.wc(file2count=infile) wf.validate() with pytest.raises(ValueError): echoed = wf.echo(message=wced)
def test_optional_to_optional_type(self): wf = WorkflowGenerator() wf.load('tests/data/tools') wf_infiles = wf.add_input(in_files='File[]') wf_outdir = wf.add_input(out_dir='string?') wf_counselors = wf.add_input(counselors='string[]') out_files, meta_out = wf.multiple_out_args( in_files=wf_infiles, out_dir=wf_outdir, counselors=wf_counselors) wf.validate()
def test_required_to_optional(self): wf = WorkflowGenerator() wf.load('tests/data/tools') # out_dir is optional, attaching to non-optional input # should work. wf_infiles = wf.add_input(in_files='File[]') wf_outdir = wf.add_input(out_dir='string') wf_counselors = wf.add_input(counselors='string[]') out_files, meta_out = wf.multiple_out_args( in_files=wf_infiles, out_dir=wf_outdir, counselors=wf_counselors) wf.validate()
def test_scatter_variable_correct(self): scatter_methods = [ 'dotproduct', 'nested_crossproduct', 'flat_crossproduct' ] for method in scatter_methods: wf = WorkflowGenerator() wf.load('tests/data/tools') msgs = wf.add_input(wfmessages='string[]') echoed = wf.echo( message=msgs, scatter='message', scatter_method=method) wf.validate() assert echoed.step_name == 'echo' assert echoed.output_name == 'echoed'
def test_generate_step_name(self): wf = WorkflowGenerator() wf.load('tests/data/tools') wfmessage = wf.add_input(wfmessage='string') name = wf._generate_step_name('echo') echoed = wf.echo(message=wfmessage) assert name == 'echo' assert name == echoed.step_name name = wf._generate_step_name('echo') echoed2 = wf.echo(message=wfmessage) assert name != 'echo' assert name == echoed2.step_name wf.validate()