Пример #1
0
 def testTwoTerms(self):
     expected = CQL_QUERY(
         SCOPED_CLAUSE(
             SCOPED_CLAUSE(SEARCH_CLAUSE(SEARCH_TERM(TERM('term1'))), ),
             BOOLEAN('and'), SEARCH_CLAUSE(SEARCH_TERM(TERM('term2')))))
     r = parseString('term1 and term2')
     self.assertEqualsCQL(expected, r)
Пример #2
0
 def testBooleansAreCaseInsensitive(self):
     self.assertEqualsCQL(
         CQL_QUERY(
             SCOPED_CLAUSE(
                 SCOPED_CLAUSE(SEARCH_CLAUSE(SEARCH_TERM(TERM('term')))),
                 BOOLEAN('and'),
                 SEARCH_CLAUSE(SEARCH_TERM(TERM('term2'))))),
         parseString('term AnD term2'))
Пример #3
0
 def testPrecedenceOrAnd(self):
     answer = CQL_QUERY(
         SCOPED_CLAUSE(
             SEARCH_CLAUSE(SEARCH_TERM(TERM('term1'))), BOOLEAN('or'),
             SCOPED_CLAUSE(
                 SCOPED_CLAUSE(SEARCH_CLAUSE(SEARCH_TERM(TERM('term2')))),
                 BOOLEAN('and'),
                 SEARCH_CLAUSE(SEARCH_TERM(TERM('term3'))))))
     self.assertEqualsCQL(answer, parseString('term1 or term2 and term3'))
Пример #4
0
 def _addFilter(self, filterQuery):
     self._filters.append(filterQuery)
     insertOriginalAst = SCOPED_CLAUSE(SEARCH_CLAUSE(self.ast)) if len(self._filters) == 1 else self.ast.children[0]
     self.ast = CQL_QUERY(
         SCOPED_CLAUSE(
             insertOriginalAst,
             BOOLEAN('and'),
             filterQuery
         )
     )
Пример #5
0
 def testPrecedenceAndAndAnd(self):
     expected = CQL_QUERY(
         SCOPED_CLAUSE(
             SCOPED_CLAUSE(
                 SCOPED_CLAUSE(
                     SCOPED_CLAUSE(SEARCH_CLAUSE(SEARCH_TERM(TERM('a'))), ),
                     BOOLEAN('and'), SEARCH_CLAUSE(SEARCH_TERM(TERM('b')))),
                 BOOLEAN('and'), SEARCH_CLAUSE(SEARCH_TERM(TERM('c')))),
             BOOLEAN('and'), SEARCH_CLAUSE(SEARCH_TERM(TERM('d')))))
     r = parseString("a and b and c and d")
     self.assertEqualsCQL(expected, r)
Пример #6
0
 def testOneTerm(self):
     self.assertEqualsCQL(
         CQL_QUERY(SCOPED_CLAUSE(SEARCH_CLAUSE(SEARCH_TERM(TERM('term'))))),
         parseString('term'))
     self.assertEqualsCQL(
         CQL_QUERY(
             SCOPED_CLAUSE(SEARCH_CLAUSE(SEARCH_TERM(
                 TERM('white space'))))), parseString('"white space"'))
     self.assertEqualsCQL(
         CQL_QUERY(
             SCOPED_CLAUSE(
                 SEARCH_CLAUSE(SEARCH_TERM(TERM('string "quotes"'))))),
         parseString(r'"string \"quotes\""'))
Пример #7
0
 def testPrecedenceAndOr(self):
     answer = CQL_QUERY(
         SCOPED_CLAUSE(
             SEARCH_CLAUSE(
                 CQL_QUERY(
                     SCOPED_CLAUSE(
                         SCOPED_CLAUSE(
                             SEARCH_CLAUSE(SEARCH_TERM(TERM('term')))),
                         BOOLEAN('and'),
                         SEARCH_CLAUSE(SEARCH_TERM(TERM('term2')))))),
             BOOLEAN('or'),
             SCOPED_CLAUSE(SEARCH_CLAUSE(SEARCH_TERM(TERM('term3'))))))
     result = parseString('term and term2 or term3')
     self.assertEqualsCQL(answer, result)