Commit cf9b205a authored by Vincent Michel's avatar Vincent Michel

Update tests

parent 3909c01d
Pipeline #1295 passed with stages
in 1 minute and 21 seconds
......@@ -14,9 +14,9 @@ from .parser import parse_xia_ini_file
from .mapping import parse_mapping_buffer
__all__ = ['init', 'init_handel', 'exit',
'new_detector', 'get_num_detectors', 'get_detectors',
'get_num_detectors', 'get_detectors',
'get_detector_from_channel',
'start_run', 'stop_run',
'start_run', 'stop_run', 'get_channel_realtime',
'get_spectrum_length', 'get_spectrum', 'get_spectrums',
'is_channel_running', 'is_running',
'get_module_statistics', 'get_statistics',
......@@ -32,11 +32,13 @@ __all__ = ['init', 'init_handel', 'exit',
'set_log_output', 'set_log_level', 'close_log',
'get_num_modules', 'get_modules', 'get_module_from_channel',
'get_module_type', 'get_module_interface',
'get_module_number_of_channels', 'get_module_channel_at',
'get_module_channels', 'get_grouped_channels', 'get_channels',
'get_trigger_channels',
'get_master_channels', 'get_trigger_channels',
'set_acquisition_value', 'get_acquisition_value',
'remove_acquisition_value', 'apply_acquisition_values',
'get_handel_version']
'get_handel_version',
'get_config_files', 'get_config']
MAX_STRING_LENGTH = 80
......
......@@ -3,6 +3,7 @@ import numpy
import mock
from handel.stats import Stats
from handel.error import HandelError
@pytest.fixture
......@@ -164,6 +165,22 @@ def test_stop_run(interface):
interface.check_error.assert_called_once_with(0)
def test_get_channel_realtime(interface):
m = interface.handel.xiaGetRunData
def side_effect(channel, dtype, arg):
arg[0] = 1.23
return 0
m.side_effect = side_effect
assert interface.get_channel_realtime(1) == 1.23
m.assert_called_once()
arg = m.call_args[0][2]
m.assert_called_once_with(1, b'realtime', arg)
# Make sure errors have been checked
interface.check_error.assert_called_once_with(0)
def test_get_spectrum_length(interface):
m = interface.handel.xiaGetRunData
......@@ -297,12 +314,15 @@ def test_get_module_statistics(interface):
with mock.patch('handel.interface.get_spectrum') as m4:
m2.return_value = [-1, -1, -1, 8]
m3.return_value = u'falconxn'
m4.side_effect = HandelError(12, 'hello')
# First test
assert interface.get_module_statistics('module3') == expected
m2.assert_called_once_with('module3')
arg = m.call_args[0][2]
m.assert_called_once_with(8, b'module_statistics_2', arg)
m4.assert_called_once_with(8)
# Second test
raw[5] = 4.56 # ICR inconsistency
raw[6] = 1.23 # OCR inconsistency
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment