-
Notifications
You must be signed in to change notification settings - Fork 83
/
test_test_checker.py
78 lines (62 loc) · 2.1 KB
/
test_test_checker.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
"""Unit tests for runnable test case checking and related functionality."""
import os
from planemo.runnable import (
cases,
for_path,
)
from .test_utils import TEST_DATA_DIR
def test_non_file_case_checker():
"""Verify simply usage of :func:`planemo.runnable.TestCase.check`."""
int_tool_path = os.path.join(TEST_DATA_DIR, "int_tool.cwl")
test_cases = cases(for_path(int_tool_path))
assert len(test_cases) == 1
test_case = test_cases[0]
outputs_dict = {
"output": 4,
}
sd = test_case.structured_test_data(MockRunResponse(outputs_dict))
assert sd["data"]["status"] == "success"
bad_outputs_dict = {
"output": 5,
}
sd = test_case.structured_test_data(MockRunResponse(bad_outputs_dict))
assert sd["data"]["status"] == "failure"
def test_file_case_checker():
hello_txt_path = os.path.join(TEST_DATA_DIR, "hello.txt")
int_tool_path = os.path.join(TEST_DATA_DIR, "cat_tool.cwl")
test_cases = cases(for_path(int_tool_path))
assert len(test_cases) == 1
test_case = test_cases[0]
outputs_dict = {
"output_file": {
"path": hello_txt_path,
}
}
sd = test_case.structured_test_data(MockRunResponse(outputs_dict))
assert sd["data"]["status"] == "success"
not_hello_txt_path = os.path.join(TEST_DATA_DIR, "int_tool_job.json")
bad_outputs_dict = {
"output_file": {
"path": not_hello_txt_path,
}
}
sd = test_case.structured_test_data(MockRunResponse(bad_outputs_dict))
assert sd["data"]["status"] == "failure"
class MockRunResponse(object):
def __init__(self, outputs_dict):
self.outputs_dict = outputs_dict
self.was_successful = True
self.job_info = {
"command_line": "cat /tmp/1.txt > /tmp/2.out",
"stdout": "Cat output",
"stderr": "Cat problems..."
}
self.log = "My Log"
class MockErrorRunResponse(object):
was_successful = False
error_message = "Problem running job."
log = "Error log"
__all__ = [
"test_non_file_case_checker",
"test_file_case_checker",
]