[Zope-CVS] CVS: Products/ZCTextIndex/tests - testLexicon.py:1.1.2.3

Barry Warsaw barry@wooz.org
Wed, 1 May 2002 11:31:34 -0400


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

Modified Files:
      Tag: TextIndexDS9-branch
	testLexicon.py 
Log Message:
Add a test for a 2-element pipeline


=== Products/ZCTextIndex/tests/testLexicon.py 1.1.2.2 => 1.1.2.3 ===
         return res
 
+class WackyReversePipelineElement:
+    def __init__(self, revword):
+        self.__revword = revword
+
+    def __call__(self, seq):
+        res = []
+        for term in seq:
+            if term == self.__revword:
+                x = list(term)
+                x.reverse()
+                res.append(''.join(x))
+            else:
+                res.append(term)
+        return res
+
 
 class SplitterAdaptor:
     def __init__(self, splitterclass, synstop=None, casefolding=0):
@@ -86,6 +101,14 @@
         wids = lexicon.sourceToWordIds('CATS and dogs')
         wids = lexicon.termToWordIds('cats and dogs')
         self.assertEqual(wids, [2, 3])
+
+    def testLongerPipeline(self):
+        lexicon = Lexicon(ZopeSplitter,
+                          (StupidPipelineElement('cats', 'fish'),
+                           WackyReversePipelineElement('fish')))
+        wids = lexicon.sourceToWordIds('cats and dogs')
+        wids = lexicon.termToWordIds('hsif')
+        self.assertEqual(wids, [1])
 
 
 def test_suite():