99
1010import pytest
1111
12+ from jsonpath_ng .ext .filter import Filter , Expression
13+ from jsonpath_ng .ext .parser import (
14+ ExtendedJsonPathLexer ,
15+ ExtentedJsonPathParser ,
16+ )
1217from jsonpath_ng .jsonpath import *
13- from jsonpath_ng .lexer import JsonPathLexer
14- from jsonpath_ng .parser import JsonPathParser
1518
1619
1720# TODO: This will be much more effective with a few regression tests and `arbitrary` parse . pretty testing
@@ -22,11 +25,11 @@ def setup_module():
2225
2326
2427def check_parse_case (string , parsed ):
25- parser = JsonPathParser (
28+ parser = ExtentedJsonPathParser (
2629 debug = True ,
2730 # Note that just manually passing token streams avoids this
2831 # dep, but that sucks
29- lexer_class = lambda : JsonPathLexer (debug = False ),
32+ lexer_class = lambda : ExtendedJsonPathLexer (debug = False ),
3033 )
3134 assert parser .parse (string ) == parsed
3235
@@ -91,10 +94,14 @@ def test_nested(string, parsed):
9194 Child (Descendants (Root (), Fields ('book' )), Slice (end = 2 ))),
9295
9396 # Filter all books with ISBN number
94- # ("$..book[?(@.isbn)]", None), # Not implemented
97+ ("$..book[?(@.isbn)]" ,
98+ Child (Descendants (Root (), Fields ('book' )),
99+ Filter ([Expression (Child (This (), Fields ('isbn' )), None , None )]))),
95100
96101 # Filter all books cheaper than 10
97- # ("$..book[?(@.price<10)]", None), # Not implemented
102+ ("$..book[?(@.price<10)]" ,
103+ Child (Descendants (Root (), Fields ('book' )),
104+ Filter ([Expression (Child (This (), Fields ('price' )), '<' , 10 )]))),
98105
99106 # All members of JSON structure
100107 ("$..*" , Descendants (Root (), Fields ('*' ))),
0 commit comments