[Zope-Checkins] CVS: Zope/lib/python/Products/ZCTextIndex/tests - testIndex.py:1.11.74.2 testZCTextIndex.py:1.36.70.1
Casey Duncan
casey@zope.com
Thu, 5 Jun 2003 00:41:59 -0400
Update of /cvs-repository/Zope/lib/python/Products/ZCTextIndex/tests
In directory cvs.zope.org:/tmp/cvs-serv14976/tests
Modified Files:
Tag: casey-zctextindex-fewer-conflicts-branch
testIndex.py testZCTextIndex.py
Log Message:
Add opportunistic upgrade code for _totaldoclen attribute. Also made sure queries still function before it is upgraded. Added upgrade tests to testLexicon. Fixed broken test in testZCTextIndex.
=== Zope/lib/python/Products/ZCTextIndex/tests/testIndex.py 1.11.74.1 => 1.11.74.2 ===
--- Zope/lib/python/Products/ZCTextIndex/tests/testIndex.py:1.11.74.1 Wed Jun 4 00:26:39 2003
+++ Zope/lib/python/Products/ZCTextIndex/tests/testIndex.py Thu Jun 5 00:41:58 2003
@@ -211,10 +211,38 @@
copy.index_doc(1, 'Then again, who asked you?')
get_transaction().commit()
+class TestTotalDocLenUpgrade(TestCase):
+
+ def test_query_before_upgrade(self):
+ self.index1 = OkapiIndex(Lexicon(Splitter()))
+ self.index1.index_doc(0, 'The quiet of night')
+ # Revert index1 back to a long to simulate an older index instance
+ self.index1._totaldoclen = long(self.index1._totaldoclen())
+ self.assertEqual(len(self.index1.search('night')), 1)
+
+ def test_upgrade_totaldoclen(self):
+ self.index1 = OkapiIndex(Lexicon())
+ self.index2 = OkapiIndex(Lexicon())
+ self.index1.index_doc(0, 'The quiet of night')
+ self.index2.index_doc(0, 'The quiet of night')
+ # Revert index1 back to a long to simulate an older index instance
+ self.index1._totaldoclen = long(self.index1._totaldoclen())
+ self.index1.index_doc(1, 'gazes upon my shadow')
+ self.index2.index_doc(1, 'gazes upon my shadow')
+ self.assertEqual(
+ self.index1._totaldoclen(), self.index2._totaldoclen())
+ self.index1._totaldoclen = long(self.index1._totaldoclen())
+ self.index1.unindex_doc(0)
+ self.index2.unindex_doc(0)
+ self.assertEqual(
+ self.index1._totaldoclen(), self.index2._totaldoclen())
+
+
def test_suite():
return TestSuite((makeSuite(CosineIndexTest),
makeSuite(OkapiIndexTest),
makeSuite(TestIndexConflict),
+ makeSuite(TestTotalDocLenUpgrade),
))
if __name__=='__main__':
=== Zope/lib/python/Products/ZCTextIndex/tests/testZCTextIndex.py 1.36 => 1.36.70.1 ===
--- Zope/lib/python/Products/ZCTextIndex/tests/testZCTextIndex.py:1.36 Wed Aug 14 18:25:14 2002
+++ Zope/lib/python/Products/ZCTextIndex/tests/testZCTextIndex.py Thu Jun 5 00:41:58 2003
@@ -331,7 +331,7 @@
self._checkAbsoluteScores()
def _checkAbsoluteScores(self):
- self.assertEqual(self.index._totaldoclen, 6)
+ self.assertEqual(self.index._totaldoclen(), 6)
# So the mean doc length is 2. We use that later.
r, num = self.zc_index.query("one")