[Zope-CVS] CVS: Products/ZCTextIndex/tests - testZCTextIndex.py:1.21
Tim Peters
tim.one@comcast.net
Fri, 17 May 2002 16:50:29 -0400
Update of /cvs-repository/Products/ZCTextIndex/tests
In directory cvs.zope.org:/tmp/cvs-serv13140/tests
Modified Files:
testZCTextIndex.py
Log Message:
Added a number of tests to trigger search-can-return-None bugs. The three
tests that currently fail are currently commented out.
Key question: If someone does a search on a stopword, and nothing else is
in the query, what do we want to do? Return all docs in a random order?
Return no docs? Raise an exception?
Second question: What if someone does a query on
rare_word AND NOT stop_word
?
=== Products/ZCTextIndex/tests/testZCTextIndex.py 1.20 => 1.21 ===
self.assertEqual(len(self.index.get_words(1)), 1)
+ r, num = self.zc_index.query('question')
+ self.assertEqual(num, 1)
+ self.assertEqual(r[0][0], 1)
+
+ r, num = self.zc_index.query('question AND to AND be')
+ self.assertEqual(num, 1)
+ self.assertEqual(r[0][0], 1)
+
+ r, num = self.zc_index.query('to AND NOT question')
+ self.assertEqual(num, 0)
+
+# r, num = self.zc_index.query('question AND NOT to AND NOT be')
+# self.assertEqual(num, 1)
+# self.assertEqual(r[0][0], 1)
+
+# r, num = self.zc_index.query('question OR to OR be')
+# self.assertEqual(num, 1)
+# self.assertEqual(r[0][0], 1)
+
+ r, num = self.zc_index.query('question to be')
+ self.assertEqual(num, 1)
+ self.assertEqual(r[0][0], 1)
+
+ r, num = self.zc_index.query('to be')
+ self.assertEqual(num, 0)
+
+ r, num = self.zc_index.query('to AND be')
+ self.assertEqual(num, 0)
+
+# r, num = self.zc_index.query('to OR be')
+# self.assertEqual(num, 0)
+
+ r, num = self.zc_index.query('to AND NOT be')
+ self.assertEqual(num, 0)
+
def testDocUpdate(self):
docid = 1 # doesn't change -- we index the same doc repeatedly
N = len(text)