-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest_cgatreport-test.py
112 lines (87 loc) · 2.7 KB
/
test_cgatreport-test.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
import unittest
import subprocess
import collections
import os
import re
import tempfile
import shutil
import sys
N_CORES = 4
EXAMPLE_OUTPUT1 = """.. ---- TEMPLATE START --------
.. report:: Trackers.LabeledDataExample
:render: table
add caption here
.. ---- TEMPLATE END ----------
.. ---- OUTPUT-----------------
b''
b''
b''
b''
b'.. csv-table:: '
b' :header: track,slice,column1,column2,column3'
b''
b' track1,slice1,1.0,2.0,'
b' track1,slice2,2.0,4.0,6.0'
b' track2,slice1,2.0,4.0,'
b' track2,slice2,4.0,8.0,12.0'
b' track3,slice1,3.0,6.0,'
b' track3,slice2,6.0,12.0,18.0'
b' '
b''
b''
b''
"""
class TestCGATReportTest(unittest.TestCase):
ignored_errors = [
"testing",
"UnknownTracker",
"GalleryBokeh",
"TestExceptions",
"unknown-renderer",
"unknown-transform"]
def setUp(self):
self.docs_dir = os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
"doc")
if not os.path.exists(self.docs_dir):
raise ValueError("doc directory {} does not exist".format(self.docs_dir))
def test_tracker_without_prefix_works(self):
stdout = subprocess.check_output(
"cgatreport-test "
"--path={docs_dir}/trackers "
"--renderer=table "
"--tracker=LabeledDataExample ".format(
docs_dir=self.docs_dir),
shell=True)
self.assertEqual(EXAMPLE_OUTPUT1, stdout)
def test_tracker_with_prefix_works(self):
stdout = subprocess.check_output(
"cgatreport-test "
"--path={docs_dir}/trackers "
"--renderer=table "
"--tracker=Trackers.LabeledDataExample ".format(
docs_dir=self.docs_dir),
shell=True)
self.assertEqual(EXAMPLE_OUTPUT1, stdout)
def test_tracker_with_missing_module_fails(self):
self.assertRaises(
subprocess.CalledProcessError,
subprocess.check_output,
"cgatreport-test "
"--path={docs_dir}/trackers "
"--renderer=table "
"--tracker=Truckers.LabeledDataExample ".format(
docs_dir=self.docs_dir),
shell=True)
def test_tracker_with_missing_tracker_fails(self):
self.assertRaises(
subprocess.CalledProcessError,
subprocess.check_output,
"cgatreport-test "
"--path={docs_dir}/trackers "
"--renderer=table "
"--tracker=UnknownLabeledDataExample ".format(
docs_dir=self.docs_dir),
shell=True)
if __name__ == "__main__":
unittest.main()