[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/FieldIndex/tests - testFieldIndex.py:1.5
Toby Dickenson
tdickenson@geminidataloggers.com
Wed, 13 Mar 2002 09:24:07 -0500
Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/FieldIndex/tests
In directory cvs.zope.org:/tmp/cvs-serv31368/lib/python/Products/PluginIndexes/FieldIndex/tests
Modified Files:
testFieldIndex.py
Log Message:
merged toby-catalog-delete-property-branch: Collector 291: deleting and indexed property
=== Zope/lib/python/Products/PluginIndexes/FieldIndex/tests/testFieldIndex.py 1.4 => 1.5 ===
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()