[Zope-CVS] CVS: Products/ZCTextIndex/tests - test_index.py:1.1.2.4

Fred L. Drake, Jr. fdrake@acm.org
Tue, 30 Apr 2002 17:44:53 -0400


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

Modified Files:
      Tag: TextIndexDS9-branch
	test_index.py 
Log Message:
Update SimpleLexicon to use the final ILexicon interface.
Add a trivial test case for the search() method.


=== Products/ZCTextIndex/tests/test_index.py 1.1.2.3 => 1.1.2.4 ===
         self._words = {}
 
-    def textToWordIDs(self, text):
+    def sourceToWordIds(self, text):
         words = text.split()
         wids = []
         for word in words:
@@ -32,6 +32,9 @@
             wids.append(wid)
         return wids
 
+    def termToWordIds(self, text):
+        return self.sourceToWordIds(text)
+
 
 class Indexable:
     def __init__(self, text):
@@ -120,6 +123,13 @@
                 self.assertEqual(docfreq, 1)
             self.assertEqual(len(map), 1)
             self.assert_(map.has_key(DOCID))
+
+    def test_simple_query(self):
+        doc = MethodIndexable('not the same document')
+        self.index.index_object(1, doc)
+        results = self.index.search("document")
+        self.assertEqual(len(results), 1)
+        self.assert_(results.has_key(1))
 
 
 def test_suite():