@@ -135,7 +135,6 @@ def test_logical_nesting_or(query):
135135 '((p1=v1,or(p2=v2,p3=v3),and(p4=v4,p5=v5)))' ,
136136 '(p1=v1,or(p2=v2,p3=v3),and(p4=v4,p5=v5))' ,
137137 'and(p1=v1,or(p2=v2,p3=v3),and(p4=v4,p5=v5))' ,
138- 'p1=v1&(p2=v2|p3=v3)&(p4=v4,p5=v5)' ,
139138 'p1=v1,(p2=v2|p3=v3),(p4=v4,p5=v5)' ,
140139])
141140def test_logical_nesting_and (query ):
@@ -147,20 +146,16 @@ def test_logical_nesting_and(query):
147146 assert result == {
148147 and_grammar_key : [
149148 ('eq' , 'p1' , 'v1' ),
149+ {
150+ or_grammar_key : [
151+ ('eq' , 'p2' , 'v2' ),
152+ ('eq' , 'p3' , 'v3' ),
153+ ],
154+ },
150155 {
151156 and_grammar_key : [
152- {
153- or_grammar_key : [
154- ('eq' , 'p2' , 'v2' ),
155- ('eq' , 'p3' , 'v3' ),
156- ],
157- },
158- {
159- and_grammar_key : [
160- ('eq' , 'p4' , 'v4' ),
161- ('eq' , 'p5' , 'v5' ),
162- ],
163- },
157+ ('eq' , 'p4' , 'v4' ),
158+ ('eq' , 'p5' , 'v5' ),
164159 ],
165160 },
166161 ],
@@ -173,23 +168,26 @@ def test_and_chain():
173168 and_grammar_key = LogicalOperators .get_grammar_key (LogicalOperators .AND )
174169 assert result == {
175170 and_grammar_key : [
176- (ComparisonOperators .NE , 'p1' , 'v1' ),
177171 {
178172 and_grammar_key : [
173+ (ComparisonOperators .NE , 'p1' , 'v1' ),
179174 (ComparisonOperators .GE , 'p2' , 'and' ),
180- (ComparisonOperators .EQ , 'or' , 'v3' ),
181175 ],
182176 },
177+ (ComparisonOperators .EQ , 'or' , 'v3' ),
183178 ],
184179 }
185-
186- assert result == logical_transform ('(ne(p1,v1)&(p2=ge=and,or=v3))' )
180+ assert result == logical_transform ('((ne(p1,v1)&p2=ge=and),or=v3)' )
187181
188182
189- def test_or_chain ():
190- q = '(ne(p1,v1)|(p2=ge=and;or=v3))'
183+ @pytest .mark .parametrize ('query' , (
184+ '(ne(p1,v1)|(p2=ge=and;or=v3)|p4=v4)' ,
185+ 'or(ne(p1,v1),(ge(p2,and);or=v3),p4=v4)' ,
186+ ))
187+ def test_or_chain (query ):
191188 or_grammar_key = LogicalOperators .get_grammar_key (LogicalOperators .OR )
192- assert logical_transform (q ) == {
189+ result = logical_transform (query )
190+ assert result == {
193191 or_grammar_key : [
194192 (ComparisonOperators .NE , 'p1' , 'v1' ),
195193 {
@@ -198,5 +196,6 @@ def test_or_chain():
198196 (ComparisonOperators .EQ , 'or' , 'v3' ),
199197 ],
200198 },
199+ (ComparisonOperators .EQ , 'p4' , 'v4' ),
201200 ],
202201 }
0 commit comments