-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathtest_run.py
117 lines (107 loc) · 4.11 KB
/
test_run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
"""The module contains a class to test the ``cwl_run`` command."""
import os
from .test_utils import (
CliTestCase,
CWL_DRAFT3_DIR,
mark,
PROJECT_TEMPLATES_DIR,
skip_if_environ,
target_galaxy_branch,
TEST_DATA_DIR,
)
def _cwl_file(name):
return os.path.normpath(os.path.join(CWL_DRAFT3_DIR, name))
# TODO: Improve these tests so they actually check something instead
# of just arbitrarily exercising the code.
class RunTestCase(CliTestCase):
@skip_if_environ("PLANEMO_SKIP_CWLTOOL_TESTS")
def test_run_cat_cwltool(self):
with self._isolate() as f:
tool_path = _cwl_file("cat1-tool.cwl")
job_path = _cwl_file("cat-job.json")
test_cmd = [
"run",
"--engine",
"cwltool",
"--no_container",
tool_path,
job_path,
]
self._check_exit_code(test_cmd)
assert os.path.exists(os.path.join(f, "tool_test_output.html"))
assert os.path.exists(os.path.join(f, "tool_test_output.json"))
@skip_if_environ("PLANEMO_SKIP_CWLTOOL_TESTS")
def test_run_cat_cwltool_more_options(self):
with self._isolate() as f:
tool_path = _cwl_file("cat1-tool.cwl")
job_path = _cwl_file("cat-job.json")
test_cmd = [
"--verbose",
"run",
"--engine",
"cwltool",
"--no_container",
tool_path,
job_path,
]
self._check_exit_code(test_cmd)
assert os.path.exists(os.path.join(f, "tool_test_output.html"))
assert os.path.exists(os.path.join(f, "tool_test_output.json"))
@skip_if_environ("PLANEMO_SKIP_GALAXY_TESTS")
@mark.tests_galaxy_branch
def test_run_gxtool_randomlines(self):
with self._isolate() as f:
tool_path = os.path.join(PROJECT_TEMPLATES_DIR, "demo", "randomlines.xml")
job_path = os.path.join(TEST_DATA_DIR, "randomlines_job_1.json")
test_cmd = [
"--verbose",
"run",
"--no_dependency_resolution",
"--galaxy_branch",
target_galaxy_branch(),
"--test_data",
TEST_DATA_DIR,
tool_path,
job_path,
]
self._check_exit_code(test_cmd)
assert os.path.exists(os.path.join(f, "tool_test_output.html"))
assert os.path.exists(os.path.join(f, "tool_test_output.json"))
@skip_if_environ("PLANEMO_SKIP_GALAXY_TESTS")
@skip_if_environ("PLANEMO_SKIP_CWLTOOL_TESTS")
def test_run_cat(self):
with self._isolate() as f:
tool_path = _cwl_file("cat1-tool.cwl")
job_path = _cwl_file("cat-job.json")
test_cmd = [
"run",
"--no_dependency_resolution",
tool_path,
job_path,
]
self._check_exit_code(test_cmd)
assert os.path.exists(os.path.join(f, "tool_test_output.html"))
assert os.path.exists(os.path.join(f, "tool_test_output.json"))
@skip_if_environ("PLANEMO_SKIP_GALAXY_TESTS")
@skip_if_environ("PLANEMO_SKIP_CWLTOOL_TESTS")
@skip_if_environ("PLANEMO_SKIP_GALAXY_CWL_TESTS")
def test_run_output_directory(self):
with self._isolate() as f:
tool_path = _cwl_file("wc-tool.cwl")
job_path = _cwl_file("wc-job.json")
test_cmd = [
"--verbose",
"run",
"--no_dependency_resolution",
"--output_directory",
f,
tool_path,
job_path,
]
self._check_exit_code(test_cmd)
assert os.path.exists(os.path.join(f, "tool_test_output.html"))
assert os.path.exists(os.path.join(f, "tool_test_output.json"))
output_path = os.path.join(f, "output")
assert os.path.exists(output_path)
with open(output_path) as fh:
assert fh.read().startswith(" 16 198 1111")