Beispiel #1
0
 def test_long_parse(self):
     # patterns with over 116 parts smash the FilterParser stack (the old parser)
     letters = (c for c in string.ascii_letters * 3)
     fstring = next(letters)
     count = 0
     for c in letters:
         fstring += " AND " + c
         count += 1
     self.assertTrue(count > 130)
     self.assertFalse(matches(fstring, "zzzz"))
     self.assertTrue(matches(fstring, " ".join(string.ascii_letters)))
     # new parser is more robust
     self.assertTrue(make_parse_tree(" OR ".join(map(str, range(2000)))).matches("999"))
     self.assertTrue(make_parse_tree("%s Hi %s" % ("(" * 100, ")" * 100)).matches("hi"))
Beispiel #2
0
 def test_long_parse(self):
     # patterns with over 116 parts smash the FilterParser stack (the old parser)
     letters = (c for c in string.ascii_letters * 3)
     fstring = next(letters)
     count = 0
     for c in letters:
         fstring += ' AND ' + c
         count += 1
     self.assertTrue(count > 130)
     self.assertFalse(matches(fstring, 'zzzz'))
     self.assertTrue(matches(fstring, ' '.join(string.ascii_letters)))
     # new parser is more robust
     self.assertTrue(make_parse_tree(' OR '.join(map(str, range(2000)))).matches('999'))
     self.assertTrue(make_parse_tree('%s Hi %s' % ('(' * 100, ')' * 100)).matches('hi'))
Beispiel #3
0
    def test_parse(self):
        bigquery = """
(Axsun OR "Volcano Corporation" OR Bioptigen OR ("Heidelberg Engineering" OR Imalux) OR Innolume OR NOT "Isis Optronics" OR "Lantis Laser" OR "Lightlab Imaging" OR "Michelson Diagnostics" OR Optiphase OR Optopol OR Optovue OR "Ophthalmic Technologies Inc")"""
        parens = "(a b(c d e)(f('g')))"
        parens2 = "(a b(c d e) OR (f('g')))"

        for p in ["(this)", "(this OR that)", "this\nNOT that", '"bob smith"', bigquery, parens, parens2]:
            tree = make_parse_tree(p)
Beispiel #4
0
    def test_parse(self):
        bigquery = '''
(Axsun OR "Volcano Corporation" OR Bioptigen OR ("Heidelberg Engineering" OR Imalux) OR Innolume OR NOT "Isis Optronics" OR "Lantis Laser" OR "Lightlab Imaging" OR "Michelson Diagnostics" OR Optiphase OR Optopol OR Optovue OR "Ophthalmic Technologies Inc")'''
        parens = "(a b(c d e)(f('g')))"
        parens2 = "(a b(c d e) OR (f('g')))"

        for p in ['(this)', '(this OR that)', 'this\nNOT that', '"bob smith"', bigquery, parens, parens2]:
            tree = make_parse_tree(p)
Beispiel #5
0
 def test_bad_parse(self):
     self.assertRaises(ParseException, make_parse_tree, "(a")
     self.assertRaises(ParseException, make_parse_tree, '"a')
     self.assertRaises(ParseException, make_parse_tree, "a)")
     make_parse_tree("*hive")  # backwards compat, '*' gets silently dropped
     make_parse_tree('"(a"')
     make_parse_tree('"a)"')
Beispiel #6
0
 def test_bad_parse(self):
     self.assertRaises(ParseException, make_parse_tree, '(a')
     self.assertRaises(ParseException, make_parse_tree, '"a')
     self.assertRaises(ParseException, make_parse_tree, 'a)')
     make_parse_tree('*hive') # backwards compat, '*' gets silently dropped
     make_parse_tree('"(a"')
     make_parse_tree('"a)"')