1 # ====================================================================
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13 # ====================================================================
15 from unittest import TestCase, main
19 class TestBooleanQuery(TestCase):
21 Unit tests ported from Java Lucene
24 def testEquality(self):
27 bq1.add(TermQuery(Term("field", "value1")), BooleanClause.Occur.SHOULD)
28 bq1.add(TermQuery(Term("field", "value2")), BooleanClause.Occur.SHOULD)
30 nested1 = BooleanQuery()
31 nested1.add(TermQuery(Term("field", "nestedvalue1")), BooleanClause.Occur.SHOULD)
32 nested1.add(TermQuery(Term("field", "nestedvalue2")), BooleanClause.Occur.SHOULD)
33 bq1.add(nested1, BooleanClause.Occur.SHOULD)
36 bq2.add(TermQuery(Term("field", "value1")), BooleanClause.Occur.SHOULD)
37 bq2.add(TermQuery(Term("field", "value2")), BooleanClause.Occur.SHOULD)
39 nested2 = BooleanQuery()
40 nested2.add(TermQuery(Term("field", "nestedvalue1")), BooleanClause.Occur.SHOULD)
41 nested2.add(TermQuery(Term("field", "nestedvalue2")), BooleanClause.Occur.SHOULD)
42 bq2.add(nested2, BooleanClause.Occur.SHOULD)
44 self.assert_(bq1.equals(bq2))
47 if __name__ == "__main__":
50 if '-loop' in sys.argv:
51 sys.argv.remove('-loop')