[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TextIndexNG/tests - testProximityLexicon.py:1.1.2.3
Andreas Jung
andreas@digicool.com
Thu, 10 Jan 2002 21:45:33 -0500
Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TextIndexNG/tests
In directory cvs.zope.org:/tmp/cvs-serv7526/tests
Modified Files:
Tag: ajung-textindexng-branch
testProximityLexicon.py
Log Message:
fixed a bug where a word got called twice with the proximity function.
Good to have unittests !
=== Zope/lib/python/Products/PluginIndexes/TextIndexNG/tests/testProximityLexicon.py 1.1.2.2 => 1.1.2.3 ===
from Products.PluginIndexes.TextIndexNG.ProximityLexicon import ProximityLexicon
+from BTrees.IIBTree import IISet
import Proximity
class Tests(unittest.TestCase):
@@ -41,7 +42,6 @@
""" """
self._lexicon = ProximityLexicon(algorithm)
- PF = getattr(Proximity,algorithm)
words = s.split()
@@ -51,8 +51,21 @@
for word in words:
self.WIDS[word] = self._lexicon.getWordId(word)
+ self.assertEqual(len(self.WIDS) , len(self._lexicon._lexicon))
+
+
for word,wid in self.WIDS.items():
- self.assertEqual( wid, self._lexicon.getWordId(word))
+
+ i1 = IISet()
+ i1.insert(wid)
+ i1 = list(i1)
+ i1.sort()
+ i2 = self._lexicon.get(word)
+ i2 = list(i2)
+ i2.sort()
+
+ self.assertEqual( i1,i2 )
+
def algorithmTest(self,d):
@@ -60,8 +73,16 @@
for key,words in d.items():
for word in words:
- wid = self._lexicon.getWordId(word)
- self.assertEqual( wid, self.WIDS[key] ,(word,key))
+
+ i1 = self._lexicon.get(key)
+ i1 = list(i1)
+ i1.sort()
+
+ i2 = self._lexicon.get(word)
+ i2 = list(i2)
+ i2.sort()
+
+ self.assertEqual( i1,i2 )
def testSoundexAscii(self):