Skip to content
Snippets Groups Projects
Commit 5ad877e2 authored by Eduardo Rodrigues's avatar Eduardo Rodrigues Committed by Patrick Koppenburg
Browse files

Full coverage in FunTuple Python modules

parent 5e25c304
No related branches found
No related tags found
1 merge request!915Full coverage in FunTuple Python modules
......@@ -54,6 +54,11 @@ def test_constructor_TypeError_dict_keys():
_ = FunctorCollection({(1, ): "CHILD(PT, 1)", "PT": F.PT})
def test_constructor_TypeError_bad_functor_type():
with pytest.raises(TypeError):
_ = FunctorCollection({"BadType": lambda x: x**2})
def test_repr_thor():
c = FunctorCollection({"PT": F.PT})
assert repr(c) == "<FunctorCollection: n_thor_fctors=1, n_loki_fctors=0>"
......
......@@ -13,10 +13,11 @@ import sys
import pytest
from PyConf.application import make_data_with_FetchDataFromFile
from PyConf.application import default_raw_event, make_odin
import Functors as F
from FunTuple import FunctorCollection
from FunTuple.functorcollections import Kinematics
from FunTuple.functorcollections import Kinematics, EventInfo
@pytest.fixture()
......@@ -36,7 +37,10 @@ variables = dict(A=Kinematics())
# to test both FunTuple_Particles and FunTuple_MCParticles
# available in the FunTuple module
list_function_tuple_name = (("FunTuple_Particles", "FunTupleP"),
("FunTuple_MCParticles", "FunTupleMCP"))
("FunTuple_MCParticles", "FunTupleMCP"),
("FunTuple_Composites",
"FunTupleComposites"), ("FunTuple_ChargedBasics",
"FunTupleChgBasics"))
this_module = sys.modules["FunTuple"]
......@@ -112,6 +116,30 @@ def test_simple_with_ALL_field(data_handle, func_name, name_argument):
inputs=data_handle)
@pytest.mark.parametrize("func_name,name_argument", list_function_tuple_name)
def test_with_event_variables(data_handle, func_name, name_argument):
"""
Check that event variables passed as an optional argument are dealt with correctly.
"""
with default_raw_event.bind(raw_event_format=0.5):
odin_loc = make_odin(stream="Spruce")
event_variables = EventInfo(odin_loc, extra_info=True)
tuple = getattr(this_module, func_name)(
name=name_argument,
tuple_name=name_argument,
fields=fields,
variables=variables,
event_variables=event_variables,
inputs=data_handle)
assert list(tuple.properties["void_thor_functors"].keys()) == [
"EVENTNUMBER", "RUNNUMBER", "BUNCHCROSSING_ID", "BUNCHCROSSING_TYPE",
"ODINTCK", "GPSTIME"
]
@pytest.mark.parametrize("func_name,name_argument", list_function_tuple_name)
def test_with_loki_preamble(data_handle, func_name, name_argument):
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment