Ejemplo n.º 1
0
 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) == []
Ejemplo n.º 2
0
    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
Ejemplo n.º 3
0
    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