def test_tags(): now = datetime.now(timezone.utc) classes = [ ("Test", Rule({"regex": "value$"})), ("Test", Rule({"regex": "^just"})), ] events = [ Event(timestamp=now, duration=0, data={"key": "just a test value"}), Event(timestamp=now, duration=0, data={}), ] events = tag(events, classes) assert len(events[0].data["$tags"]) == 2 assert len(events[1].data["$tags"]) == 0
def q2_tag(events: list, classes: list): classes = [(_cls, Rule(rule_dict)) for _cls, rule_dict in classes] return tag(events, classes)