[Zope-Checkins] CVS: Products/ZCTextIndex/tests - testIndex.py:1.11
Casey Duncan
casey@zope.com
Wed, 12 Jun 2002 17:45:53 -0400
Update of /cvs-repository/Products/ZCTextIndex/tests
In directory cvs.zope.org:/tmp/cvs-serv24512/tests
Modified Files:
testIndex.py
Log Message:
Reimplemented Index.length to use a BTree.Length. Previous dynamic computation was way too slow for big indexes.
Updated tests to include length value checks
=== Products/ZCTextIndex/tests/testIndex.py 1.10 => 1.11 ===
self.assertEqual(len(self.index._docwords), 1)
self.assertEqual(len(self.index.get_words(DOCID)), 5)
+ self.assertEqual(len(self.index._wordinfo),
+ self.index.length())
for map in self.index._wordinfo.values():
self.assertEqual(len(map), 1)
self.assert_(map.has_key(DOCID))
@@ -48,6 +50,8 @@
self.assertEqual(len(self.index._docweight), 0)
self.assertEqual(len(self.index._wordinfo), 0)
self.assertEqual(len(self.index._docwords), 0)
+ self.assertEqual(len(self.index._wordinfo),
+ self.index.length())
def test_index_two_documents(self):
self.test_index_document()
@@ -59,6 +63,8 @@
self.assertEqual(len(self.index._wordinfo), 8)
self.assertEqual(len(self.index._docwords), 2)
self.assertEqual(len(self.index.get_words(DOCID)), 4)
+ self.assertEqual(len(self.index._wordinfo),
+ self.index.length())
wids = self.lexicon.termToWordIds("document")
self.assertEqual(len(wids), 1)
document_wid = wids[0]
@@ -80,6 +86,8 @@
self.assertEqual(len(self.index._wordinfo), 4)
self.assertEqual(len(self.index._docwords), 1)
self.assertEqual(len(self.index.get_words(DOCID)), 4)
+ self.assertEqual(len(self.index._wordinfo),
+ self.index.length())
for map in self.index._wordinfo.values():
self.assertEqual(len(map), 1)
self.assert_(map.has_key(DOCID))
@@ -91,6 +99,8 @@
self.assertEqual(len(self.index._wordinfo), 5)
self.assertEqual(len(self.index._docwords), 1)
self.assertEqual(len(self.index.get_words(DOCID)), 7)
+ self.assertEqual(len(self.index._wordinfo),
+ self.index.length())
wids = self.lexicon.termToWordIds("repeat")
self.assertEqual(len(wids), 1)
repititive_wid = wids[0]