Commit 3054237b authored by Vincent Michel's avatar Vincent Michel
Browse files

Add missing tests

parent 622c25a8
Pipeline #947 passed with stages
in 1 minute and 17 seconds
......@@ -104,16 +104,9 @@ A few scripts are provided:
TODO
----
- Parsing of the weird XIA INI file format.
- Missing tests:
* get_module_number_of_channels(alias)
* get_module_channel_at(alias, index)
* get_module_channels(alias)
* get_channels()
- Improve `handel-server` using argparse.
Contact
-------
......
......@@ -303,8 +303,11 @@ def get_grouped_channels():
def get_channels():
"""Return all the enabled channels."""
return sorted(channel for channels in get_grouped_channels()
for channel in channels if channel != -1)
return tuple(sorted(
channel
for channels in get_grouped_channels()
for channel in channels
if channel != -1))
# Not exposed
......
......@@ -394,7 +394,7 @@ def test_get_module_from_channel(interface):
arg = m.call_args[0][1]
m.assert_called_once_with(1, arg)
# Make sure errors have been checked
interface.check_error.assert_called_with(0)
interface.check_error.assert_called_once_with(0)
def test_get_module_type(interface):
......@@ -409,7 +409,7 @@ def test_get_module_type(interface):
arg = m.call_args[0][2]
m.assert_called_once_with(b'module1', b'module_type', arg)
# Make sure errors have been checked
interface.check_error.assert_called_with(0)
interface.check_error.assert_called_once_with(0)
def test_get_module_interface(interface):
......@@ -424,9 +424,108 @@ def test_get_module_interface(interface):
arg = m.call_args[0][2]
m.assert_called_once_with(b'module1', b'interface', arg)
# Make sure errors have been checked
interface.check_error.assert_called_once_with(0)
def test_get_module_number_of_channels(interface):
m = interface.handel.xiaGetModuleItem
def side_effect(a, b, c):
c[0] = 4
return 0
m.side_effect = side_effect
assert interface.get_module_number_of_channels('module1') == 4
arg = m.call_args[0][2]
m.assert_called_once_with(b'module1', b'number_of_channels', arg)
# Make sure errors have been checked
interface.check_error.assert_called_once_with(0)
def test_get_module_channel_at(interface):
m = interface.handel.xiaGetModuleItem
def side_effect(a, b, c):
c[0] = 3
return 0
m.side_effect = side_effect
assert interface.get_module_channel_at('module1', 2) == 3
arg = m.call_args[0][2]
m.assert_called_once_with(b'module1', b'channel2_alias', arg)
# Make sure errors have been checked
interface.check_error.assert_called_once_with(0)
def test_get_module_channels(interface):
m = interface.handel.xiaGetModuleItem
results = [3, 2, 1, 0, 4]
def side_effect(a, b, c):
c[0] = results.pop()
return 0
m.side_effect = side_effect
assert interface.get_module_channels('module1') == (0, 1, 2, 3)
# Make sure errors have been checked
interface.check_error.assert_called_with(0)
def test_get_grouped_channels(interface):
m1 = interface.handel.xiaGetNumModules
m2 = interface.handel.xiaGetModules
m3 = interface.handel.xiaGetModuleItem
results = [3, 2, 1, 0, 4, 7, 6, 5, 4, 4]
def side_effect_1(arg):
arg[0] = 2
return 0
def side_effect_2(lst):
lst[0][0:5] = b'name1'
lst[1][0:5] = b'name2'
return 0
def side_effect_3(a, b, c):
c[0] = results.pop()
return 0
m1.side_effect = side_effect_1
m2.side_effect = side_effect_2
m3.side_effect = side_effect_3
assert interface.get_grouped_channels() == ((4, 5, 6, 7), (0, 1, 2, 3))
# Make sure errors have been checked
interface.check_error.assert_called_with(0)
def test_get_channels(interface):
m1 = interface.handel.xiaGetNumModules
m2 = interface.handel.xiaGetModules
m3 = interface.handel.xiaGetModuleItem
results = [3, 2, 1, 0, 4, 7, 6, 5, 4, 4]
def side_effect_1(arg):
arg[0] = 2
return 0
def side_effect_2(lst):
lst[0][0:5] = b'name1'
lst[1][0:5] = b'name2'
return 0
def side_effect_3(a, b, c):
c[0] = results.pop()
return 0
m1.side_effect = side_effect_1
m2.side_effect = side_effect_2
m3.side_effect = side_effect_3
assert interface.get_channels() == (0, 1, 2, 3, 4, 5, 6, 7)
# Make sure errors have been checked
interface.check_error.assert_called_with(0)
# Parameters
def test_set_acquisition_value(interface):
......
Supports Markdown
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