[Zope-Checkins] CVS: Zope/lib/python/Products/ZCTextIndex/tests - testLexicon.py:1.5.16.1
Casey Duncan
casey@zope.com
Thu, 29 May 2003 23:53:13 -0400
Update of /cvs-repository/Zope/lib/python/Products/ZCTextIndex/tests
In directory cvs.zope.org:/tmp/cvs-serv13282/tests
Modified Files:
Tag: casey-zctextindex-fewer-conflicts-branch
testLexicon.py
Log Message:
Some experimental changes to reduce write conflicts with ZCTextIndex
=== Zope/lib/python/Products/ZCTextIndex/tests/testLexicon.py 1.5 => 1.5.16.1 ===
--- Zope/lib/python/Products/ZCTextIndex/tests/testLexicon.py:1.5 Thu Dec 19 10:39:29 2002
+++ Zope/lib/python/Products/ZCTextIndex/tests/testLexicon.py Thu May 29 23:53:12 2003
@@ -12,9 +12,11 @@
#
##############################################################################
-import sys
+import os, sys
from unittest import TestCase, TestSuite, main, makeSuite
+import ZODB
+
from Products.ZCTextIndex.Lexicon import Lexicon
from Products.ZCTextIndex.Lexicon import Splitter, CaseNormalizer
@@ -134,9 +136,49 @@
words = HTMLWordSplitter().process(words)
self.assertEqual(words, expected)
locale.setlocale(locale.LC_ALL, loc) # restore saved locale
+
+class TestLexiconConflict(TestCase):
+
+ storage = None
+
+ def tearDown(self):
+ if self.storage is not None:
+ self.storage.close()
+
+ def openDB(self):
+ from ZODB.FileStorage import FileStorage
+ from ZODB.DB import DB
+ n = 'fs_tmp__%s' % os.getpid()
+ self.storage = FileStorage(n)
+ self.db = DB(self.storage)
+
+ def testAddWordConflict(self):
+ self.l = Lexicon()
+ self.openDB()
+ r1 = self.db.open().root()
+ r1['l'] = self.l
+ get_transaction().commit()
+
+ r2 = self.db.open().root()
+ copy = r2['l']
+ # Make sure the data is loaded
+ list(copy._wids.items())
+ list(copy._words.items())
+
+ self.assertEqual(self.l._p_serial, copy._p_serial)
+
+ self.l.sourceToWordIds('spam')
+ get_transaction().commit()
+
+ copy.sourceToWordIds('eggs')
+ get_transaction().commit()
+
def test_suite():
- return makeSuite(Test)
+ suite = TestSuite()
+ suite.addTest(makeSuite(Test))
+ suite.addTest(makeSuite(TestLexiconConflict))
+ return suite
if __name__=='__main__':
main(defaultTest='test_suite')