[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/FieldIndex/tests - testFieldIndex.py:1.4.34.1

Casey Duncan casey@zope.com
Wed, 27 Mar 2002 15:51:42 -0500


Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/FieldIndex/tests
In directory cvs.zope.org:/tmp/cvs-serv22094/lib/python/Products/PluginIndexes/FieldIndex/tests

Modified Files:
      Tag: casey-death_to_index_html-branch
	testFieldIndex.py 
Log Message:
Updating branch to head for testing


=== Zope/lib/python/Products/PluginIndexes/FieldIndex/tests/testFieldIndex.py 1.4 => 1.4.34.1 ===
     def foo( self ):
         return self._foo
-    
+
     def __str__( self ):
         return '<Dummy: %s>' % self._foo
     
@@ -148,6 +148,29 @@
         self._checkApply(self._none_req, values[-1:])
         assert None in self._index.uniqueValues('foo')
 
+    def testReindex( self ):
+        self._populateIndex()
+        result, used = self._index._apply_index( {'foo':'abc'} )
+        assert list(result)==[2]
+        assert self._index.keyForDocument(2)=='abc'
+        d = Dummy('world')
+        self._index.index_object(2,d)
+        result, used = self._index._apply_index( {'foo':'world'} )
+        assert list(result)==[2]
+        assert self._index.keyForDocument(2)=='world'
+        del d._foo
+        self._index.index_object(2,d)
+        result, used = self._index._apply_index( {'foo':'world'} )
+        assert list(result)==[]
+        try:
+            should_not_be = self._index.keyForDocument(2)
+        except KeyError:
+            # As expected, we deleted that attribute.
+            pass
+        else:
+            # before Collector #291 this would be 'world'
+            raise ValueError(repr(should_not_be))
+                    
     def testRange(self):
         """Test a range search"""
         index = FieldIndex( 'foo' )
@@ -183,3 +206,9 @@
 
 def test_suite():
     return unittest.makeSuite( TestCase )
+
+def main():
+    unittest.TextTestRunner().run(test_suite())
+
+if __name__ == '__main__':
+    main()