Skip to content

Commit 2051071

Browse files
committed
added shell and workflow tests
1 parent 919be4e commit 2051071

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

pydra/utils/tests/test_general.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
from pydra.compose import python # , workflow, shell
1+
from pydra.compose import python, workflow, shell
2+
from fileformats.generic import File
23
from pydra.utils.general import task_def_as_dict, task_def_from_dict, task_fields
4+
from pydra.utils.tests.utils import SpecificFuncTask, Concatenate
35

46

57
def test_python_task_def_as_dict():
@@ -26,3 +28,31 @@ def Add(a: int, b: int | None = None, c: int | None = None) -> int:
2628
dct = task_def_as_dict(Add)
2729
Reloaded = task_def_from_dict(dct)
2830
assert task_fields(Add) == task_fields(Reloaded)
31+
32+
33+
def test_shell_task_def_as_dict():
34+
35+
MyCmd = shell.define(
36+
"my-cmd <in_file> <out|out_file> --an-arg <an_arg:int=2> --a-flag<a_flag>"
37+
)
38+
39+
dct = task_def_as_dict(MyCmd)
40+
Reloaded = task_def_from_dict(dct)
41+
assert task_fields(MyCmd) == task_fields(Reloaded)
42+
43+
44+
def test_workflow_task_def_as_dict():
45+
46+
@workflow.define
47+
def AWorkflow(in_file: File, a_param: int) -> tuple[File, File]:
48+
spec_func = workflow.add(SpecificFuncTask(in_file))
49+
concatenate = workflow.add(
50+
Concatenate(
51+
in_file1=in_file, in_file2=spec_func.out_file, duplicates=a_param
52+
)
53+
)
54+
return concatenate.out_file
55+
56+
dct = task_def_as_dict(AWorkflow)
57+
Reloaded = task_def_from_dict(dct)
58+
assert task_fields(AWorkflow) == task_fields(Reloaded)

0 commit comments

Comments
 (0)