21
21
ProcessingError
22
22
)
23
23
24
+ from . import _SpecialSuiteWindowTestBase , _SpecialSuiteProcessorTestBase
25
+
24
26
app = mkQApp ()
25
27
26
- logger .setLevel ('CRITICAL ' )
28
+ logger .setLevel ('INFO ' )
27
29
28
30
29
- class TestGotthard ( unittest . TestCase ):
31
+ class TestGotthardWindow ( _SpecialSuiteWindowTestBase ):
30
32
@classmethod
31
33
def setUpClass (cls ):
32
34
cls ._win = GotthardWindow ('MID' )
@@ -36,6 +38,19 @@ def tearDownClass(cls):
36
38
# explicitly close the MainGUI to avoid error in GuiLogger
37
39
cls ._win .close ()
38
40
41
+ @staticmethod
42
+ def data4visualization (n_pulses = 4 ):
43
+ """Override."""
44
+ return {
45
+ "x" : None ,
46
+ "spectrum" : np .arange (10 * n_pulses ).reshape (n_pulses , 10 ),
47
+ "spectrum_ma" : np .arange (10 * n_pulses ).reshape (n_pulses , 10 ),
48
+ "spectrum_mean" : np .arange (10 ),
49
+ "spectrum_ma_mean" : np .arange (10 ),
50
+ "poi_index" : 0 ,
51
+ "hist" : (np .arange (5 ), np .arange (5 ), 1 , 1 , 1 ),
52
+ }
53
+
39
54
def testWindow (self ):
40
55
win = self ._win
41
56
@@ -49,7 +64,7 @@ def testWindow(self):
49
64
self .assertEqual (1 , counter [GotthardPulsePlot ])
50
65
self .assertEqual (1 , counter [GotthardHist ])
51
66
52
- win . updateWidgetsST ()
67
+ self . _check_update_plots ()
53
68
54
69
def testCtrl (self ):
55
70
from extra_foam .special_suite .gotthard_w import _DEFAULT_N_BINS , _DEFAULT_BIN_RANGE
@@ -135,7 +150,7 @@ def testCtrl(self):
135
150
self .assertTrue (proc ._hist_over_ma )
136
151
137
152
138
- class TestGotthardProcessor (_RawDataMixin ):
153
+ class TestGotthardProcessor (_RawDataMixin , _SpecialSuiteProcessorTestBase ):
139
154
@pytest .fixture (autouse = True )
140
155
def setUp (self ):
141
156
self ._proc = GotthardProcessor (object (), object ())
@@ -269,6 +284,7 @@ def testProcessing(self, subtract_dark):
269
284
270
285
# 1st train
271
286
processed = proc .process (self ._get_data (12345 ))
287
+ self ._check_processed_data_structure (processed )
272
288
assert 1 == processed ["poi_index" ]
273
289
np .testing .assert_array_almost_equal (adc_gt , processed ["spectrum" ])
274
290
np .testing .assert_array_almost_equal (adc_gt , processed ["spectrum_ma" ])
@@ -329,3 +345,8 @@ def testRemoveDark(self):
329
345
proc .onRemoveDark ()
330
346
assert proc ._dark_ma is None
331
347
assert proc ._dark_mean_ma is None
348
+
349
+ def _check_processed_data_structure (self , ret ):
350
+ """Override."""
351
+ data_gt = TestGotthardWindow .data4visualization ().keys ()
352
+ assert set (ret .keys ()) == set (data_gt )
0 commit comments