Skip to content

Commit 22ef750

Browse files
committed
Add unit test to check task_inputs_mandatory_with_xOR
1 parent 5bbb4a9 commit 22ef750

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

pydra/engine/tests/test_specs.py

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,15 @@
1414
DockerSpec,
1515
SingularitySpec,
1616
LazyField,
17+
ShellOutSpec,
18+
)
19+
from ..task import (
20+
TaskBase,
21+
ShellCommandTask
1722
)
1823
from ..helpers import make_klass
1924
import pytest
20-
25+
import attr
2126

2227
def test_basespec():
2328
spec = BaseSpec()
@@ -366,3 +371,43 @@ def test_input_file_hash_5(tmpdir):
366371
f.write("hi")
367372
hash3 = inputs(in_file=[{"file": file_diffcontent, "int": 3}]).hash
368373
assert hash1 != hash3
374+
375+
376+
377+
def test_task_inputs_mandatory_with_xOR():
378+
"""input spec with mandatory inputs"""
379+
input_fields=[
380+
(
381+
"input_1",
382+
bool,
383+
{
384+
"help_string": "help",
385+
"argstr": "--i1",
386+
"xor": ("input_1", "input_2"),
387+
}
388+
),
389+
(
390+
"input_2",
391+
bool,
392+
{
393+
"help_string": "help",
394+
"mandatory": True,
395+
"argstr": "--i2",
396+
"xor": ("input_1", "input_2"),
397+
}
398+
)
399+
]
400+
task_input_spec = SpecInfo(name="Input", fields=input_fields, bases=(ShellSpec,))
401+
task_output_fields = []
402+
task_output_spec = SpecInfo(name="Output", fields=task_output_fields, bases=(ShellOutSpec,))
403+
404+
class MyTask(ShellCommandTask):
405+
input_spec = task_input_spec
406+
output_spec = task_output_spec
407+
executable = "task"
408+
409+
task = MyTask()
410+
task.inputs.input_1 = True
411+
task.inputs.input_2 = True
412+
task.inputs.check_fields_input_spec()
413+
#task.cmdline

0 commit comments

Comments
 (0)