[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TextIndexNG/tests - testTextIndexNGinCatalog.py:1.1.2.2

Andreas Jung andreas@digicool.com
Sat, 23 Feb 2002 20:07:46 -0500


Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TextIndexNG/tests
In directory cvs.zope.org:/tmp/cvs-serv27815/tests

Modified Files:
      Tag: ajung-textindexng-branch
	testTextIndexNGinCatalog.py 
Log Message:
- added tests for NEAR search and phrase search
- now using a subclassed Catalog to provided customized
versions for catalogObject() and unrestrictedTraverse(). That's
needed in the TextIndexNG to extract data from stored objects


=== Zope/lib/python/Products/PluginIndexes/TextIndexNG/tests/testTextIndexNGinCatalog.py 1.1.2.1 => 1.1.2.2 ===
 
 
-class Tests(testTextIndexNG):
+class TestCatalog(Catalog):
+        
+    _objects = {}
+
+    def catalogObject(self, obj, uid):
+        Catalog.catalogObject(self, obj, uid)
+        self._objects[uid] = obj
+        
+    def unrestrictedTraverse(self, path):
+        print self._objects
+        return self._objects[path]
+        
+
+class CatalogTestBase(testTextIndexNG):
 
     def _init(self, arguments):
 
@@ -43,11 +56,13 @@
                             timed_statistics=timed_statistics
                         )
 
-        self.catalog = Catalog('catalog')
+        self.catalog = TestCatalog('catalog')
         self.catalog.addIndex('text', index)
         self.catalog.addColumn('text')
         self.catalog.addColumn('id')
 
+        index.catalog = self.catalog
+
         self.catalog.aq_parent = TO('blabla',-999)
 
         for id,text in self._testdata:
@@ -71,9 +86,29 @@
         return lst
 
 
+class Tests(CatalogTestBase):
+
+    def checkNearSearchNoStemmer(self):
+
+        self._init(arguments(
+                splitterCasefolding = 1,             
+                nearDistance = 3,
+                useStemmer = None
+                ))
+
+        self.search('text near simple',   [1] )
+        self.search('text quote simple',  [1] )
+        self.search('Gegner near lazy',   [4] )
+        self.search('Gegner quote lazy',  [4] )
+
+        self.search('FOX near jumps ',    [2] )
+        self.search('FOX quote jumps ',   [2] )
+        self.search('FOX near over',      [2] )
+        self.search('FOX quote over',     []  )
+
 
 def test_suite():
-   return unittest.makeSuite(Tests)
+   return unittest.makeSuite(Tests,'check')
 
 def main():
    unittest.TextTestRunner().run(test_suite())