@@ -73,7 +73,7 @@ def test_cwl_inputs_to_jsonschema(tool_path: Path, inputs_path: Path) -> None:
7373 raise SchemaError (f"{ inputs_path .name } failed schema validation" ) from err
7474
7575
76- def test_cwl_inputs_to_jsonschema_fails () -> None :
76+ def test_cwl_inputs_to_jsonschema_single_fail () -> None :
7777 """Compare tool schema of param 1 against input schema of param 2."""
7878 tool_path : Path = TEST_PARAMS [0 ][0 ]
7979 inputs_path : Path = TEST_PARAMS [3 ][1 ]
@@ -92,3 +92,54 @@ def test_cwl_inputs_to_jsonschema_fails() -> None:
9292 # We expect this to fail
9393 with pytest .raises (ValidationError ):
9494 validate (input_obj , json_schema )
95+
96+
97+ BAD_TEST_PARAMS = [
98+ # Any without defaults cannot be unspecified
99+ (
100+ get_path ("testdata/null-expression2-tool.cwl" ),
101+ get_path ("testdata/empty.json" ),
102+ "'i1' is a required property" ,
103+ ),
104+ # null to Any type without a default value.
105+ (
106+ get_path ("testdata/null-expression2-tool.cwl" ),
107+ get_path ("testdata/null-expression1-job.json" ),
108+ "None is not valid under any of the given schemas" ,
109+ ),
110+ # Any without defaults, unspecified
111+ (
112+ get_path ("testdata/echo-tool.cwl" ),
113+ get_path ("testdata/null-expression-echo-job.json" ),
114+ "None is not valid under any of the given schemas" ,
115+ ),
116+ # JSON null provided for required input
117+ (
118+ get_path ("testdata/echo-tool.cwl" ),
119+ get_path ("testdata/null-expression1-job.json" ),
120+ "'in' is a required property" ,
121+ ),
122+ ]
123+
124+
125+ @pytest .mark .parametrize ("tool_path,inputs_path,exception_message" , BAD_TEST_PARAMS )
126+ def test_cwl_inputs_to_jsonschema_fails (
127+ tool_path : Path ,
128+ inputs_path : Path ,
129+ exception_message : str ,
130+ ) -> None :
131+ cwl_obj = load_document_by_uri (tool_path .as_uri ())
132+
133+ logger .info (f"Generating schema for { tool_path .name } " )
134+ json_schema = cwl_to_jsonschema (cwl_obj )
135+
136+ logger .info (
137+ f"Testing { inputs_path .name } against schema generated for input { tool_path .name } "
138+ )
139+
140+ yaml = YAML ()
141+
142+ input_obj = yaml .load (inputs_path )
143+
144+ with pytest .raises (ValidationError , match = exception_message ):
145+ validate (input_obj , json_schema )
0 commit comments