def test_arithmetic_pow(): result = parse(['>', ['^', ['get', 'size'], 2], 100]) assert result == ast.GreaterThan( ast.Function( 'pow', [ast.Attribute('size'), 2], ), 100)
def test_arithmetic_abs(): result = parse(['>', ['abs', ['get', 'delta']], 1]) assert result == ast.GreaterThan( ast.Function( 'abs', [ ast.Attribute('delta'), ], ), 1)
def test_arithmetic_max(): result = parse(['>', ['max', ['get', 'wins'], ['get', 'ties']], 10]) assert result == ast.GreaterThan( ast.Function( 'max', [ ast.Attribute('wins'), ast.Attribute('ties'), ], ), 10)
def test_logical_all(): result = parse([ 'all', ['>', ['get', 'height'], 50], ['==', ['get', 'type'], 'commercial'], ['get', 'occupied'] ]) assert result == ast.And( ast.And(ast.GreaterThan( ast.Attribute('height'), 50, ), ast.Equal(ast.Attribute('type'), 'commercial')), ast.Attribute('occupied'))
def test_and(): result = parse(''' <fes:Filter xmlns:fes="http://www.opengis.net/fes/2.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema-datatypes"> <fes:And> <fes:PropertyIsLessThan> <fes:ValueReference>attr</fes:ValueReference> <fes:Literal type="xsd:int">30</fes:Literal> </fes:PropertyIsLessThan> <fes:PropertyIsGreaterThan> <fes:ValueReference>attr</fes:ValueReference> <fes:Literal type="xsd:int">10</fes:Literal> </fes:PropertyIsGreaterThan> </fes:And> </fes:Filter> ''') assert result == ast.And(ast.LessThan( ast.Attribute('attr'), 30, ), ast.GreaterThan( ast.Attribute('attr'), 10, ))
def test_attribute_gt_literal(): result = parse('{ "gt": [{ "property": "attr" }, 5]}') assert result == ast.GreaterThan( ast.Attribute('attr'), 5.0, )
def test_attribute_gt_literal(): result = parse('attr > 5') assert result == ast.GreaterThan( ast.Attribute('attr'), 5.0, )
def test_attribute_gt_literal(): result = parse('[">", ["get", "attr"], 5]') assert result == ast.GreaterThan( ast.Attribute('attr'), 5.0, )