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

Andreas Jung andreas@digicool.com
Sun, 3 Feb 2002 14:08:49 -0500


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

Modified Files:
      Tag: ajung-textindexng-branch
	testNormalizer.py 
Log Message:
added Normalizer


=== Zope/lib/python/Products/PluginIndexes/TextIndexNG/tests/testNormalizer.py 1.1.2.1 => 1.1.2.2 ===
 #
 # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-# 
+#
 # This software is subject to the provisions of the Zope Public License,
 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE
-# 
+#
 ##############################################################################
 
 import sys, os, unittest
 
-from Products.PluginIndexes.TextIndexNG.Normalizer import Normalizer 
+from Products.PluginIndexes.TextIndexNG import normalizer
 from BTrees.IIBTree import IISet, difference
 
 class Tests(unittest.TestCase):
 
+    norm = [
+        ('ä','ae'),
+        ('ö','oe'),
+        ]
+
+    data = {
+         'einen':'einen',
+         'alle':'alle',
+         'flugplätze':'flugplaetze',
+         'zerstört':'zerstoert',
+         None: None
+    }
+
     def setUp(self):
-        self.N = Normalizer('default_de.txt')
+        self.N = normalizer.Normalizer( self.norm )
 
 
     def testSimple(self):
-        """ simple normalizer test """
+        """ testing single strings as argument """
+
+        for word  in self.data.keys():
+
+            self.assertEqual(
+                self.N.normalize(word),
+                self.data[word],
+                (word,self.data[word],self.N.normalize(word))
+                )
+
 
-        _data = (
-            ('einen','einen'), 
-            ('alle','alle'),
-            ('Flugplätze','Flugplaetze'), 
-            ('zerstört','zerstoert'),  
-        )
-
-        for w1,w2 in _data:
-            self.assertEqual( self.N(w1), w2, (w1,w2,self.N(w1)))
-        
+    def testList(self):
+        """ testing list as argument """
+
+        self.assertEqual(
+                self.N.normalize(self.data.keys()),
+                self.data.values()
+                )
 
-       
 
 def test_suite():
-   return unittest.makeSuite(Tests)
+    return unittest.makeSuite(Tests)
 
 def main():
-   unittest.TextTestRunner().run(test_suite())
+    unittest.TextTestRunner().run(test_suite())
 
 def debug():
-   test_suite().debug()
+    test_suite().debug()
 
 def pdebug():
     import pdb
     pdb.run('debug()')
-   
-if __name__=='__main__':
-   if len(sys.argv) > 1:
-      globals()[sys.argv[1]]()
-   else:
-      main()
 
+if __name__=='__main__':
+    if len(sys.argv) > 1:
+        globals()[sys.argv[1]]()
+    else:
+        main()