comparison env/lib/python3.7/site-packages/cwltool/tests/test_override.py @ 0:26e78fe6e8c4 draft

"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
author shellac
date Sat, 02 May 2020 07:14:21 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:26e78fe6e8c4
1 import json
2
3 from six import StringIO
4
5 import pytest
6
7 from cwltool.main import main
8 from cwltool import load_tool
9 from .util import get_data, needs_docker
10
11 override_parameters = [
12 ([get_data('tests/override/echo.cwl'),
13 get_data('tests/override/echo-job.yml')],
14 {"out": "zing hello1\n"}
15 ),
16 (["--overrides",
17 get_data('tests/override/ov.yml'),
18 get_data('tests/override/echo.cwl'),
19 get_data('tests/override/echo-job.yml')],
20 {"out": "zing hello2\n"}
21 ),
22 ([get_data('tests/override/echo.cwl'),
23 get_data('tests/override/echo-job-ov.yml')],
24 {"out": "zing hello3\n"}
25 ),
26 ([get_data('tests/override/echo-job-ov2.yml')],
27 {"out": "zing hello4\n"}
28 ),
29 (["--overrides",
30 get_data('tests/override/ov.yml'),
31 get_data('tests/override/echo-wf.cwl'),
32 get_data('tests/override/echo-job.yml')],
33 {"out": "zing hello2\n"}
34 ),
35 (["--overrides",
36 get_data('tests/override/ov2.yml'),
37 get_data('tests/override/echo-wf.cwl'),
38 get_data('tests/override/echo-job.yml')],
39 {"out": "zing hello5\n"}
40 ),
41 (["--overrides",
42 get_data('tests/override/ov3.yml'),
43 get_data('tests/override/echo-wf.cwl'),
44 get_data('tests/override/echo-job.yml')],
45 {"out": "zing hello6\n"}
46 ),
47 ([get_data('tests/override/env-tool_v1.1.cwl'),
48 get_data('tests/override/env-tool_cwl-requirement_override.yaml')],
49 {"value": "hello test env"}
50 ),
51 (["--enable-dev",
52 get_data('tests/override/env-tool_cwl-requirement_override_default.yaml')],
53 {"value": "hello test env"}
54 ),
55 ]
56
57 @needs_docker
58 @pytest.mark.parametrize('parameters,result', override_parameters)
59 def test_overrides(parameters, result):
60 sio = StringIO()
61
62 assert main(parameters, stdout=sio) == 0
63 assert json.loads(sio.getvalue()) == result
64
65
66 failing_override_parameters = [
67 ([get_data('tests/override/env-tool.cwl'),
68 get_data('tests/override/env-tool_cwl-requirement_override.yaml')],
69 "`cwl:requirements` in the input object is not part of CWL v1.0. You can "
70 "adjust to use `cwltool:overrides` instead; or you can set the cwlVersion to "
71 "v1.1"
72 ),
73 ([get_data('tests/override/env-tool_v1.1.0-dev1.cwl'),
74 get_data('tests/override/env-tool_cwl-requirement_override.yaml')],
75 "Version 'v1.1.0-dev1' is a development or deprecated version.\n"
76 " Update your document to a stable version (v1.0, v1.1) or use --enable-dev to "
77 "enable support for development and deprecated versions."
78 ),
79 ([get_data('tests/override/env-tool_cwl-requirement_override_default_wrongver.yaml')],
80 "`cwl:requirements` in the input object is not part of CWL v1.0. You can "
81 "adjust to use `cwltool:overrides` instead; or you can set the cwlVersion to "
82 "v1.1 or greater."
83 ),
84 ([get_data('tests/override/env-tool_cwl-requirement_override_default.yaml')],
85 "Version 'v1.1.0-dev1' is a development or deprecated version.\n"
86 " Update your document to a stable version (v1.0, v1.1) or use --enable-dev to "
87 "enable support for development and deprecated versions."
88 ),
89 ]
90
91 @needs_docker
92 @pytest.mark.parametrize('parameters,expected_error', failing_override_parameters)
93 def test_overrides_fails(parameters, expected_error):
94 sio = StringIO()
95
96 assert main(parameters, stderr=sio) == 1
97 stderr = sio.getvalue()
98 assert expected_error in stderr, stderr