2020from cwl_utils .errors import WorkflowException
2121from cwl_utils .expression_refactor import run as expression_refactor
2222
23- HERE = Path ( __file__ ). resolve (). parent
23+ from . util import get_data
2424
2525
2626def test_v1_0_workflow_top_level_format_expr () -> None :
2727 """Test for the correct error when converting a format expression in a workflow level input."""
2828 with raises (WorkflowException , match = r".*format specification.*" ):
2929 result , modified = traverse0 (
30- parser .load_document (
31- str (HERE / "../testdata/workflow_input_format_expr.cwl" )
32- ),
30+ parser .load_document (get_data ("testdata/workflow_input_format_expr.cwl" )),
3331 False ,
3432 False ,
3533 False ,
@@ -41,7 +39,7 @@ def test_v1_0_workflow_top_level_sf_expr() -> None:
4139 """Test for the correct error when converting a secondaryFiles expression in a workflow level input."""
4240 with raises (WorkflowException , match = r".*secondaryFiles.*" ):
4341 result , modified = traverse0 (
44- parser .load_document (str ( HERE / "../ testdata/workflow_input_sf_expr.cwl" )),
42+ parser .load_document (get_data ( " testdata/workflow_input_sf_expr.cwl" )),
4543 False ,
4644 False ,
4745 False ,
@@ -53,9 +51,7 @@ def test_v1_0_workflow_top_level_sf_expr_array() -> None:
5351 """Test for the correct error when converting a secondaryFiles expression (array form) in a workflow level input."""
5452 with raises (WorkflowException , match = r".*secondaryFiles.*" ):
5553 result , modified = traverse0 (
56- parser .load_document (
57- str (HERE / "../testdata/workflow_input_sf_expr_array.cwl" )
58- ),
54+ parser .load_document (get_data ("testdata/workflow_input_sf_expr_array.cwl" )),
5955 False ,
6056 False ,
6157 False ,
@@ -65,11 +61,10 @@ def test_v1_0_workflow_top_level_sf_expr_array() -> None:
6561
6662def test_v1_1_workflow_top_level_format_expr () -> None :
6763 """Test for the correct error when converting a format expression in a workflow level input."""
68- # import ipdb; ipdb.set_trace()
6964 with raises (WorkflowException , match = r".*format specification.*" ):
7065 result , modified = traverse1 (
7166 parser1 .load_document (
72- str ( HERE / "../ testdata/workflow_input_format_expr_v1_1.cwl" )
67+ get_data ( " testdata/workflow_input_format_expr_v1_1.cwl" )
7368 ),
7469 False ,
7570 False ,
@@ -82,9 +77,7 @@ def test_v1_1_workflow_top_level_sf_expr() -> None:
8277 """Test for the correct error when converting a secondaryFiles expression in a workflow level input."""
8378 with raises (WorkflowException , match = r".*secondaryFiles.*" ):
8479 result , modified = traverse1 (
85- parser1 .load_document (
86- str (HERE / "../testdata/workflow_input_sf_expr_v1_1.cwl" )
87- ),
80+ parser1 .load_document (get_data ("testdata/workflow_input_sf_expr_v1_1.cwl" )),
8881 False ,
8982 False ,
9083 False ,
@@ -97,7 +90,7 @@ def test_v1_1_workflow_top_level_sf_expr_array() -> None:
9790 with raises (WorkflowException , match = r".*secondaryFiles.*" ):
9891 result , modified = traverse1 (
9992 parser1 .load_document (
100- str ( HERE / "../ testdata/workflow_input_sf_expr_array_v1_1.cwl" )
93+ get_data ( " testdata/workflow_input_sf_expr_array_v1_1.cwl" )
10194 ),
10295 False ,
10396 False ,
@@ -111,7 +104,7 @@ def test_v1_2_workflow_top_level_format_expr() -> None:
111104 with raises (WorkflowException , match = r".*format specification.*" ):
112105 result , modified = traverse2 (
113106 parser2 .load_document (
114- str ( HERE / "../ testdata/workflow_input_format_expr_v1_2.cwl" )
107+ get_data ( " testdata/workflow_input_format_expr_v1_2.cwl" )
115108 ),
116109 False ,
117110 False ,
@@ -124,9 +117,7 @@ def test_v1_2_workflow_top_level_sf_expr() -> None:
124117 """Test for the correct error when converting a secondaryFiles expression in a workflow level input."""
125118 with raises (WorkflowException , match = r".*secondaryFiles.*" ):
126119 result , modified = traverse2 (
127- parser2 .load_document (
128- str (HERE / "../testdata/workflow_input_sf_expr_v1_2.cwl" )
129- ),
120+ parser2 .load_document (get_data ("testdata/workflow_input_sf_expr_v1_2.cwl" )),
130121 False ,
131122 False ,
132123 False ,
@@ -139,7 +130,7 @@ def test_v1_2_workflow_top_level_sf_expr_array() -> None:
139130 with raises (WorkflowException , match = r".*secondaryFiles.*" ):
140131 result , modified = traverse2 (
141132 parser2 .load_document (
142- str ( HERE / "../ testdata/workflow_input_sf_expr_array_v1_2.cwl" )
133+ get_data ( " testdata/workflow_input_sf_expr_array_v1_2.cwl" )
143134 ),
144135 False ,
145136 False ,
@@ -151,7 +142,7 @@ def test_v1_2_workflow_top_level_sf_expr_array() -> None:
151142def test_v1_0_step_valuefrom_expr_multisource () -> None :
152143 """Convert a valueFrom expression that has multiple sources."""
153144 result , modified = traverse0 (
154- parser .load_document (str ( HERE / "../ testdata/step-valuefrom2-wf_v1_0.cwl" )),
145+ parser .load_document (get_data ( " testdata/step-valuefrom2-wf_v1_0.cwl" )),
155146 False ,
156147 False ,
157148 False ,
@@ -162,7 +153,7 @@ def test_v1_0_step_valuefrom_expr_multisource() -> None:
162153def test_v1_1_step_valuefrom_expr_multisource () -> None :
163154 """Convert a valueFrom expression that has multiple sources."""
164155 result , modified = traverse1 (
165- parser1 .load_document (str ( HERE / "../ testdata/step-valuefrom2-wf_v1_1.cwl" )),
156+ parser1 .load_document (get_data ( " testdata/step-valuefrom2-wf_v1_1.cwl" )),
166157 False ,
167158 False ,
168159 False ,
@@ -173,7 +164,7 @@ def test_v1_1_step_valuefrom_expr_multisource() -> None:
173164def test_v1_2_step_valuefrom_expr_multisource () -> None :
174165 """Convert a valueFrom expression that has multiple sources."""
175166 result , modified = traverse2 (
176- parser2 .load_document (str ( HERE / "../ testdata/step-valuefrom2-wf_v1_2.cwl" )),
167+ parser2 .load_document (get_data ( " testdata/step-valuefrom2-wf_v1_2.cwl" )),
177168 False ,
178169 False ,
179170 False ,
@@ -184,7 +175,7 @@ def test_v1_2_step_valuefrom_expr_multisource() -> None:
184175def test_v1_0_step_valuefrom_expr_sibling_inputs () -> None :
185176 """Convert a valueFrom expression from a step input that has uninvolved sibling inputs."""
186177 result , modified = traverse0 (
187- parser .load_document (str ( HERE / "../ testdata/step-valuefrom3-wf_v1_0.cwl" )),
178+ parser .load_document (get_data ( " testdata/step-valuefrom3-wf_v1_0.cwl" )),
188179 False ,
189180 False ,
190181 False ,
@@ -195,7 +186,7 @@ def test_v1_0_step_valuefrom_expr_sibling_inputs() -> None:
195186def test_v1_1_step_valuefrom_expr_sibling_inputs () -> None :
196187 """Convert a valueFrom expression from a step input that has uninvolved sibling inputs."""
197188 result , modified = traverse1 (
198- parser1 .load_document (str ( HERE / "../ testdata/step-valuefrom3-wf_v1_1.cwl" )),
189+ parser1 .load_document (get_data ( " testdata/step-valuefrom3-wf_v1_1.cwl" )),
199190 False ,
200191 False ,
201192 False ,
@@ -206,7 +197,7 @@ def test_v1_1_step_valuefrom_expr_sibling_inputs() -> None:
206197def test_v1_2_step_valuefrom_expr_sibling_inputs () -> None :
207198 """Convert a valueFrom expression from a step input that has uninvolved sibling inputs."""
208199 result , modified = traverse2 (
209- parser2 .load_document (str ( HERE / "../ testdata/step-valuefrom3-wf_v1_2.cwl" )),
200+ parser2 .load_document (get_data ( " testdata/step-valuefrom3-wf_v1_2.cwl" )),
210201 False ,
211202 False ,
212203 False ,
@@ -217,7 +208,7 @@ def test_v1_2_step_valuefrom_expr_sibling_inputs() -> None:
217208def test_v1_2_workflow_output_pickvalue_expr () -> None :
218209 """Convert a workflow output pickValue expression."""
219210 result , modified = traverse2 (
220- parser2 .load_document (str ( HERE / "../ testdata/cond-wf-003.1.cwl" )),
211+ parser2 .load_document (get_data ( " testdata/cond-wf-003.1.cwl" )),
221212 False ,
222213 False ,
223214 False ,
@@ -227,22 +218,22 @@ def test_v1_2_workflow_output_pickvalue_expr() -> None:
227218
228219def test_expression_refactor (tmp_path : Path ) -> None :
229220 """Functional test."""
230- input_path = str ( HERE / "../ testdata/cond-wf-003.1.cwl" )
221+ input_path = get_data ( " testdata/cond-wf-003.1.cwl" )
231222 result = expression_refactor ([str (tmp_path ), input_path ])
232223 assert result == 0
233224
234225
235226def test_expression_refactor_noop_solo (tmp_path : Path ) -> None :
236227 """Functional test."""
237- input_path = str ( HERE / "../ testdata/dockstore-tool-md5sum.cwl" )
228+ input_path = get_data ( " testdata/dockstore-tool-md5sum.cwl" )
238229 result = expression_refactor ([str (tmp_path ), input_path ])
239230 assert result == 7
240231
241232
242233def test_expression_refactor_noop (tmp_path : Path ) -> None :
243234 """Functional test."""
244- input_path1 = str ( HERE / "../ testdata/dockstore-tool-md5sum.cwl" )
245- input_path2 = str ( HERE / "../ testdata/echo-tool-packed.cwl" )
235+ input_path1 = get_data ( " testdata/dockstore-tool-md5sum.cwl" )
236+ input_path2 = get_data ( " testdata/echo-tool-packed.cwl" )
246237 result = expression_refactor ([str (tmp_path ), input_path1 , input_path2 ])
247238 assert result == 0
248239
0 commit comments