def test_jexl_works(self): filter = self.create_basic_filter() # Would throw if not defined expr = filter.to_jexl() assert isinstance(expr, str) jexl = get_normandy_jexl() errors = jexl.validate(expr) assert list(errors) == []
def validate_extra_filter_expression(self, value): if value: jexl = get_normandy_jexl() errors = list(jexl.validate(value)) if errors: raise serializers.ValidationError(errors) return value
def to_jexl(self): built_expression = "(" + self.initial_data["expression"] + ")" jexl = get_normandy_jexl() errors = list(jexl.validate(built_expression)) if errors: raise serializers.ValidationError(errors) return built_expression