-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_scripts.py
More file actions
executable file
·71 lines (55 loc) · 1.9 KB
/
test_scripts.py
File metadata and controls
executable file
·71 lines (55 loc) · 1.9 KB
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
#!/usr/bin/env python3
import os
import sys
import tempfile
import unittest
from pcpostprocess.scripts.run_herg_qc import run as run_herg_qc
from pcpostprocess.scripts.summarise_herg_export import run as run_summarise
store_output = False
class TestScripts(unittest.TestCase):
"""
Tests the scripts bundled with pcpostprocess.
"""
@classmethod
def setUpClass(self):
if store_output: # pragma: no cover
self.temp_dir = None
self.plot_dir = 'test_output'
os.makedirs(self.plot_dir, exist_ok=True)
else:
self.temp_dir = tempfile.TemporaryDirectory()
self.plot_dir = self.temp_dir.name
@classmethod
def tearDownClass(self):
if self.temp_dir:
self.temp_dir.cleanup()
def test_run_herg_qc_and_summarise_herg_export(self):
# Test run_herg_qc_, then summarise_herg_export
data = os.path.join('test_data', '13112023_MW2_FF')
d1 = os.path.join(self.plot_dir, 'run_herg_qc')
d2 = os.path.join(self.plot_dir, 'summarise_herg_export')
# Test run herg qc
erev = -90.71
qc_map = {'staircaseramp (2)_2kHz': 'staircaseramp'}
write_map = {'staircaseramp2': 'staircaseramp2'}
run_herg_qc(
data,
d1,
'13112023_MW2',
qc_map,
write_map,
('A03', 'A20', 'D16'),
write_traces=True,
reversal_potential=erev,
)
with open(os.path.join(d1, 'passed_wells.txt'), 'r') as f:
self.assertEqual(f.read().strip(), 'A03')
# Test summarise herg export
run_summarise(d1, d2, '13112023_MW2', reversal_potential=erev)
if __name__ == "__main__": # pragma: no cover
if '-store' in sys.argv:
sys.argv.remove('-store')
store_output = True
else:
print('Add -store to store output')
unittest.main()