Update of /cvs-repository/Products/PluginIndexes/DateIndex/tests In directory cvs.zope.org:/tmp/cvs-serv19773
Modified Files: Tag: Zope-2_7-branch test_DateIndex.py Log Message: - deleted trailing whitespace - new test for removal (indexing an object with a value of None should remove it from the index) === Products/PluginIndexes/DateIndex/tests/test_DateIndex.py 1.5.2.4 => 1.5.2.5 === --- Products/PluginIndexes/DateIndex/tests/test_DateIndex.py:1.5.2.4 Thu Feb 5 12:49:02 2004 +++ Products/PluginIndexes/DateIndex/tests/test_DateIndex.py Wed Aug 24 11:38:36 2005 @@ -109,13 +109,13 @@ (7, Dummy('f', 1072742900)), # 1073545928 (8, Dummy('g', date(2034,2,5))), # 1073599200 (9, Dummy('h', datetime(2034,2,5,15,17,5))), # (1073600117UTC) - (10, Dummy('i', datetime(2034,2,5,10,17,5, + (10, Dummy('i', datetime(2034,2,5,10,17,5, tzinfo=Eastern))), # 1073600117 ) self._index = DateIndex('date') self._noop_req = {'bar': 123} self._request = {'date': DateTime(0)} - self._min_req = {'date': {'query': DateTime('2032-05-08 15:16:17'), + self._min_req = {'date': {'query': DateTime('2032-05-08 15:16:17'), 'range': 'min'}} self._max_req = {'date': {'query': DateTime('2032-05-08 15:16:17'), 'range': 'max'}} @@ -204,20 +204,33 @@ self._checkApply(self._range_req, values[2:] ) self._checkApply(self._float_req, [values[6]] ) self._checkApply(self._int_req, [values[7]] ) - + def test_naive_convert_to_utc(self): values = self._values index = self._index index.index_naive_time_as_local = False self._populateIndex() - for k, v in values[9:]: + for k, v in values[9:]: # assert that the timezone is effectively UTC for item 9, # and still correct for item 10 yr, mo, dy, hr, mn = v.date().utctimetuple()[:5] val = (((yr * 12 + mo) * 31 + dy) * 24 + hr) * 60 + mn self.failUnlessEqual(self._index.getEntryForObject(k), val) - - + + def test_removal(self): + """ DateIndex would hand back spurious entries when used as a + sort_index, because it previously was not removing entries + from the _unindex when indexing an object with a value of + None. The catalog consults a sort_index's + documentToKeyMap() to build the brains. + """ + values = self._values + index = self._index + self._populateIndex() + self._checkApply(self._int_req, [values[7]]) + index.index_object(7, None) + self.failIf(7 in index.documentToKeyMap().keys()) + def test_suite(): suite = unittest.TestSuite() _______________________________________________ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins