[Zope-CVS] CVS: Products/ZCTextIndex/tests - testQueryEngine.py:1.1.2.5 testQueryParser.py:1.1.2.6
Guido van Rossum
guido@python.org
Mon, 6 May 2002 12:36:28 -0400
Update of /cvs-repository/Products/ZCTextIndex/tests
In directory cvs.zope.org:/tmp/cvs-serv20133/tests
Modified Files:
Tag: TextIndexDS9-branch
testQueryEngine.py testQueryParser.py
Log Message:
Move the parser output (the exception it raises and the parse tree
nodes) to a separate module, so other pluggable parsers can more
easily share these. (Maybe these belong in IQueryParser???)
Changed the parser so that it parses "foo bar" the same as "foo OR
bar". (Though maybe this should be "foo AND bar"?)
=== Products/ZCTextIndex/tests/testQueryEngine.py 1.1.2.4 => 1.1.2.5 ===
from BTrees.IIBTree import IIBucket
-from Products.ZCTextIndex.QueryParser import QueryParser, ParseError
+from Products.ZCTextIndex.QueryParser import QueryParser
+from Products.ZCTextIndex.ParseTree import ParseError
from Products.ZCTextIndex.QueryEngine import QueryEngine, QueryError
class FauxIndex:
@@ -60,7 +61,7 @@
self.compareQuery("ham AND foo AND bar", {1: 3})
def testInvalidQuery(self):
- from Products.ZCTextIndex.QueryParser import NotNode, AtomNode
+ from Products.ZCTextIndex.ParseTree import NotNode, AtomNode
tree = NotNode(AtomNode("foo"))
self.assertRaises(QueryError,
self.engine.executeQuery, self.index, tree)
=== Products/ZCTextIndex/tests/testQueryParser.py 1.1.2.5 => 1.1.2.6 ===
from unittest import TestCase, TestSuite, main, makeSuite
-from Products.ZCTextIndex.QueryParser import \
- QueryParser, ParseError, ParseTreeNode, OrNode, AndNode, NotNode, AtomNode
+from Products.ZCTextIndex.QueryParser import QueryParser
+
+from Products.ZCTextIndex.ParseTree import \
+ ParseError, ParseTreeNode, OrNode, AndNode, NotNode, AtomNode
class TestQueryParser(TestCase):
@@ -63,9 +65,9 @@
self.expect("a AND not b",
AndNode([AtomNode("a"), NotNode(AtomNode("b"))]))
- self.expect("foo bar", AtomNode("foo bar"))
+ self.expect("foo bar", OrNode([AtomNode("foo"), AtomNode("bar")]))
- self.expect("((foo bar))", AtomNode("foo bar"))
+ self.expect("((foo bar))", OrNode([AtomNode("foo"), AtomNode("bar")]))
def testParseFailures(self):
self.failure("")