[Zope-CVS] CVS: Products/ZCTextIndex/tests - testQueryParser.py:1.1.2.10

Guido van Rossum guido@python.org
Mon, 13 May 2002 18:17:12 -0400


Update of /cvs-repository/Products/ZCTextIndex/tests
In directory cvs.zope.org:/tmp/cvs-serv7094/tests

Modified Files:
      Tag: TextIndexDS9-branch
	testQueryParser.py 
Log Message:
Added globbing or pattern searches.  Currently only a single trailing
star is supported (e.g. ``foo*'').  There are some assumptions on case
insensitivity hidden in the glob code.  There are no unit tests for
the globbing search execution currently.  (There are none for phrase
searching either.  This is all my fault.  But it does work.)


=== Products/ZCTextIndex/tests/testQueryParser.py 1.1.2.9 => 1.1.2.10 ===
 from Products.ZCTextIndex.QueryParser import QueryParser
 
-from Products.ZCTextIndex.ParseTree import \
-     ParseError, ParseTreeNode, OrNode, AndNode, NotNode, AtomNode, PhraseNode
+from Products.ZCTextIndex.ParseTree import ParseError, ParseTreeNode
+from Products.ZCTextIndex.ParseTree import OrNode, AndNode, NotNode
+from Products.ZCTextIndex.ParseTree import AtomNode, PhraseNode, GlobNode
 
 class TestQueryParser(TestCase):
 
@@ -27,6 +28,9 @@
         if isinstance(got, PhraseNode):
             self.assertEqual(got.nodeType(), "PHRASE")
             self.assertEqual(got.getValue(), expected.getValue())
+        elif isinstance(got, GlobNode):
+            self.assertEqual(got.nodeType(), "GLOB")
+            self.assertEqual(got.getValue(), expected.getValue())
         elif isinstance(got, AtomNode):
             self.assertEqual(got.nodeType(), "ATOM")
             self.assertEqual(got.getValue(), expected.getValue())
@@ -94,6 +98,10 @@
         self.expect('foo"bar"blech',
                     AndNode([AtomNode("foo"), AtomNode("bar"),
                              AtomNode("blech")]))
+
+        self.expect("foo*", GlobNode("foo*"))
+        self.expect("foo* bar", AndNode([GlobNode("foo*"),
+                                         AtomNode("bar")]))
 
     def testParseFailures(self):
         self.failure("")