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