[Zope-Checkins] CVS: Zope/lib/python/Products/ZCTextIndex/tests - testLexicon.py:1.5.16.2

Casey Duncan casey@zope.com
Thu, 5 Jun 2003 11:01:12 -0400


Update of /cvs-repository/Zope/lib/python/Products/ZCTextIndex/tests
In directory cvs.zope.org:/tmp/cvs-serv12170/tests

Modified Files:
      Tag: casey-zctextindex-fewer-conflicts-branch
	testLexicon.py 
Log Message:
Further minimize the chance of write conflicts in the lexicon by making sure the length counter gets reloaded from the database when a new batch of words is added. Another option would be to generate randomized wids, but this would undo a core optimization of the indexes.
Improved the tests to exercise this improvement and make sure the data gets saved as expected.


=== Zope/lib/python/Products/ZCTextIndex/tests/testLexicon.py 1.5.16.1 => 1.5.16.2 ===
--- Zope/lib/python/Products/ZCTextIndex/tests/testLexicon.py:1.5.16.1	Thu May 29 23:53:12 2003
+++ Zope/lib/python/Products/ZCTextIndex/tests/testLexicon.py	Thu Jun  5 11:01:11 2003
@@ -153,7 +153,7 @@
         self.db = DB(self.storage)
         
     def testAddWordConflict(self):
-        self.l = Lexicon()
+        self.l = Lexicon(Splitter())
         self.openDB()
         r1 = self.db.open().root()
         r1['l'] = self.l
@@ -164,15 +164,17 @@
         # Make sure the data is loaded
         list(copy._wids.items())
         list(copy._words.items())
+        copy.length()
         
         self.assertEqual(self.l._p_serial, copy._p_serial)
         
-        self.l.sourceToWordIds('spam')
+        self.l.sourceToWordIds('mary had a little lamb')
         get_transaction().commit()
         
-        copy.sourceToWordIds('eggs')
+        copy.sourceToWordIds('whose fleece was white as snow')
         get_transaction().commit()
-        
+        self.assertEqual(copy.length(), 11)
+        self.assertEqual(copy.length(), len(copy._words))
 
 def test_suite():
     suite = TestSuite()