11"""Tests --validation."""
2-
2+ import re
33
44from .util import get_data , get_main_output
55
@@ -14,3 +14,41 @@ def test_validate_graph_with_no_default() -> None:
1414 assert "packed_no_main.cwl#cat is valid CWL" in stdout
1515 assert "packed_no_main.cwl#collision is valid CWL" in stdout
1616 assert "tests/wf/packed_no_main.cwl is valid CWL" in stdout
17+
18+
19+ def test_validate_with_valid_input_object () -> None :
20+ """Ensure that --validate with a valid input object."""
21+ exit_code , stdout , stderr = get_main_output (
22+ [
23+ "--validate" ,
24+ get_data ("tests/wf/1st-workflow.cwl" ),
25+ "--inp" ,
26+ get_data ("tests/wf/1st-workflow.cwl" ),
27+ "--ex" ,
28+ "FOO" ,
29+ ]
30+ )
31+ assert exit_code == 0
32+ assert "tests/wf/1st-workflow.cwl is valid CWL. No errors detected in the inputs." in stdout
33+
34+
35+ def test_validate_with_invalid_input_object () -> None :
36+ """Ensure that --validate with an invalid input object."""
37+ exit_code , stdout , stderr = get_main_output (
38+ [
39+ "--validate" ,
40+ get_data ("tests/wf/1st-workflow.cwl" ),
41+ get_data ("tests/wf/1st-workflow_bad_inputs.yml" ),
42+ ]
43+ )
44+ assert exit_code == 1
45+ stderr = re .sub (r"\s\s+" , " " , stderr )
46+ assert "Invalid job input record" in stderr
47+ assert (
48+ "tests/wf/1st-workflow_bad_inputs.yml:2:1: * the 'ex' field is not "
49+ "valid because the value is not string" in stderr
50+ )
51+ assert (
52+ "tests/wf/1st-workflow_bad_inputs.yml:1:1: * the 'inp' field is not "
53+ "valid because is not a dict. Expected a File object." in stderr
54+ )
0 commit comments