From 37d86ac19072254eac9ee5c6702a5aedeaebc628 Mon Sep 17 00:00:00 2001 From: Ariana Barzinpour Date: Thu, 28 Mar 2024 03:40:34 +0000 Subject: [PATCH] fix tests --- pygeofilter/parsers/cql2_json/parser.py | 11 ++++------- tests/parsers/cql2_json/test_parser.py | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/pygeofilter/parsers/cql2_json/parser.py b/pygeofilter/parsers/cql2_json/parser.py index 74b41da..e1eb503 100644 --- a/pygeofilter/parsers/cql2_json/parser.py +++ b/pygeofilter/parsers/cql2_json/parser.py @@ -125,7 +125,10 @@ def walk_cql_json(node: JsonType): # noqa: C901 return ast.Not(cast(ast.Node, walk_cql_json(args))) elif op == "isNull": - return ast.IsNull(cast(ast.Node, walk_cql_json(args)), False) + # like with "not", allow both arrays and objects + if isinstance(args, list): + args = args[0] + return ast.IsNull(cast(ast.Node, walk_cql_json(args)), not_=False) elif op == "between": return ast.Between( @@ -153,12 +156,6 @@ def walk_cql_json(node: JsonType): # noqa: C901 not_=False, ) - elif op == "isNull": - return ast.IsNull( - walk_cql_json(args), - not_=False, - ) - elif op in BINARY_OP_PREDICATES_MAP: args = [cast(ast.Node, walk_cql_json(arg)) for arg in args] return BINARY_OP_PREDICATES_MAP[op](*args) diff --git a/tests/parsers/cql2_json/test_parser.py b/tests/parsers/cql2_json/test_parser.py index b78d440..c28ef6e 100644 --- a/tests/parsers/cql2_json/test_parser.py +++ b/tests/parsers/cql2_json/test_parser.py @@ -145,7 +145,7 @@ def test_attribute_in_list(): def test_attribute_is_null(): - result = parse({"op": "isNull", "args": {"property": "attr"}}) + result = parse({"op": "isNull", "args": [{"property": "attr"}]}) assert result == ast.IsNull(ast.Attribute("attr"), False)