def test_query_metadata_composable(caplog): caplog.set_level(logging.INFO) r_base = my_event().QMetaData({"one": "1"}) # Each of these is a different base and should not interfear. r1 = r_base.QMetaData({"two": "2"}) r2 = r_base.QMetaData({"two": "2+"}) from func_adl.ast.meta_data import lookup_query_metadata assert lookup_query_metadata(r1, "two") == "2" assert lookup_query_metadata(r2, "two") == "2+" assert len(caplog.text) == 0
def test_query_metadata_not_found(): r = ( my_event() .QMetaData({"one": "two", "two": "three"}) .SelectMany("lambda e: e.jets()") .Select("lambda j: j.pT()") ) assert lookup_query_metadata(r, "three") is None
def test_query_metadata_updated(): '''This is testing code in QMetaData, but we need lookup_query_metadata which we are testing in this file''' r = ( my_event() .QMetaData({"one": "two"}) .QMetaData({"one": "three"}) ) assert lookup_query_metadata(r, "one") == "three"
def test_query_metadata_burried(): r = ( my_event() .QMetaData({"three": "forks"}) .SelectMany("lambda e: e.jets()") .QMetaData({"one": "two", "two": "three"}) .Select("lambda j: j.pT()") ) assert lookup_query_metadata(r, "three") == "forks"