20
20
from cwl_utils .errors import WorkflowException
21
21
from cwl_utils .expression_refactor import run as expression_refactor
22
22
23
- HERE = Path ( __file__ ). resolve (). parent
23
+ from . util import get_data
24
24
25
25
26
26
def test_v1_0_workflow_top_level_format_expr () -> None :
27
27
"""Test for the correct error when converting a format expression in a workflow level input."""
28
28
with raises (WorkflowException , match = r".*format specification.*" ):
29
29
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" )),
33
31
False ,
34
32
False ,
35
33
False ,
@@ -41,7 +39,7 @@ def test_v1_0_workflow_top_level_sf_expr() -> None:
41
39
"""Test for the correct error when converting a secondaryFiles expression in a workflow level input."""
42
40
with raises (WorkflowException , match = r".*secondaryFiles.*" ):
43
41
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" )),
45
43
False ,
46
44
False ,
47
45
False ,
@@ -53,9 +51,7 @@ def test_v1_0_workflow_top_level_sf_expr_array() -> None:
53
51
"""Test for the correct error when converting a secondaryFiles expression (array form) in a workflow level input."""
54
52
with raises (WorkflowException , match = r".*secondaryFiles.*" ):
55
53
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" )),
59
55
False ,
60
56
False ,
61
57
False ,
@@ -65,11 +61,10 @@ def test_v1_0_workflow_top_level_sf_expr_array() -> None:
65
61
66
62
def test_v1_1_workflow_top_level_format_expr () -> None :
67
63
"""Test for the correct error when converting a format expression in a workflow level input."""
68
- # import ipdb; ipdb.set_trace()
69
64
with raises (WorkflowException , match = r".*format specification.*" ):
70
65
result , modified = traverse1 (
71
66
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" )
73
68
),
74
69
False ,
75
70
False ,
@@ -82,9 +77,7 @@ def test_v1_1_workflow_top_level_sf_expr() -> None:
82
77
"""Test for the correct error when converting a secondaryFiles expression in a workflow level input."""
83
78
with raises (WorkflowException , match = r".*secondaryFiles.*" ):
84
79
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" )),
88
81
False ,
89
82
False ,
90
83
False ,
@@ -97,7 +90,7 @@ def test_v1_1_workflow_top_level_sf_expr_array() -> None:
97
90
with raises (WorkflowException , match = r".*secondaryFiles.*" ):
98
91
result , modified = traverse1 (
99
92
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" )
101
94
),
102
95
False ,
103
96
False ,
@@ -111,7 +104,7 @@ def test_v1_2_workflow_top_level_format_expr() -> None:
111
104
with raises (WorkflowException , match = r".*format specification.*" ):
112
105
result , modified = traverse2 (
113
106
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" )
115
108
),
116
109
False ,
117
110
False ,
@@ -124,9 +117,7 @@ def test_v1_2_workflow_top_level_sf_expr() -> None:
124
117
"""Test for the correct error when converting a secondaryFiles expression in a workflow level input."""
125
118
with raises (WorkflowException , match = r".*secondaryFiles.*" ):
126
119
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" )),
130
121
False ,
131
122
False ,
132
123
False ,
@@ -139,7 +130,7 @@ def test_v1_2_workflow_top_level_sf_expr_array() -> None:
139
130
with raises (WorkflowException , match = r".*secondaryFiles.*" ):
140
131
result , modified = traverse2 (
141
132
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" )
143
134
),
144
135
False ,
145
136
False ,
@@ -151,7 +142,7 @@ def test_v1_2_workflow_top_level_sf_expr_array() -> None:
151
142
def test_v1_0_step_valuefrom_expr_multisource () -> None :
152
143
"""Convert a valueFrom expression that has multiple sources."""
153
144
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" )),
155
146
False ,
156
147
False ,
157
148
False ,
@@ -162,7 +153,7 @@ def test_v1_0_step_valuefrom_expr_multisource() -> None:
162
153
def test_v1_1_step_valuefrom_expr_multisource () -> None :
163
154
"""Convert a valueFrom expression that has multiple sources."""
164
155
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" )),
166
157
False ,
167
158
False ,
168
159
False ,
@@ -173,7 +164,7 @@ def test_v1_1_step_valuefrom_expr_multisource() -> None:
173
164
def test_v1_2_step_valuefrom_expr_multisource () -> None :
174
165
"""Convert a valueFrom expression that has multiple sources."""
175
166
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" )),
177
168
False ,
178
169
False ,
179
170
False ,
@@ -184,7 +175,7 @@ def test_v1_2_step_valuefrom_expr_multisource() -> None:
184
175
def test_v1_0_step_valuefrom_expr_sibling_inputs () -> None :
185
176
"""Convert a valueFrom expression from a step input that has uninvolved sibling inputs."""
186
177
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" )),
188
179
False ,
189
180
False ,
190
181
False ,
@@ -195,7 +186,7 @@ def test_v1_0_step_valuefrom_expr_sibling_inputs() -> None:
195
186
def test_v1_1_step_valuefrom_expr_sibling_inputs () -> None :
196
187
"""Convert a valueFrom expression from a step input that has uninvolved sibling inputs."""
197
188
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" )),
199
190
False ,
200
191
False ,
201
192
False ,
@@ -206,7 +197,7 @@ def test_v1_1_step_valuefrom_expr_sibling_inputs() -> None:
206
197
def test_v1_2_step_valuefrom_expr_sibling_inputs () -> None :
207
198
"""Convert a valueFrom expression from a step input that has uninvolved sibling inputs."""
208
199
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" )),
210
201
False ,
211
202
False ,
212
203
False ,
@@ -217,7 +208,7 @@ def test_v1_2_step_valuefrom_expr_sibling_inputs() -> None:
217
208
def test_v1_2_workflow_output_pickvalue_expr () -> None :
218
209
"""Convert a workflow output pickValue expression."""
219
210
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" )),
221
212
False ,
222
213
False ,
223
214
False ,
@@ -227,22 +218,22 @@ def test_v1_2_workflow_output_pickvalue_expr() -> None:
227
218
228
219
def test_expression_refactor (tmp_path : Path ) -> None :
229
220
"""Functional test."""
230
- input_path = str ( HERE / "../ testdata/cond-wf-003.1.cwl" )
221
+ input_path = get_data ( " testdata/cond-wf-003.1.cwl" )
231
222
result = expression_refactor ([str (tmp_path ), input_path ])
232
223
assert result == 0
233
224
234
225
235
226
def test_expression_refactor_noop_solo (tmp_path : Path ) -> None :
236
227
"""Functional test."""
237
- input_path = str ( HERE / "../ testdata/dockstore-tool-md5sum.cwl" )
228
+ input_path = get_data ( " testdata/dockstore-tool-md5sum.cwl" )
238
229
result = expression_refactor ([str (tmp_path ), input_path ])
239
230
assert result == 7
240
231
241
232
242
233
def test_expression_refactor_noop (tmp_path : Path ) -> None :
243
234
"""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" )
246
237
result = expression_refactor ([str (tmp_path ), input_path1 , input_path2 ])
247
238
assert result == 0
248
239
0 commit comments