[Checkins] SVN: Products.ZCatalog/trunk/src/Products/PluginIndexes/DateRangeIndex/tests/test_DateRangeIndex.py Test passing in a resultset into _apply_index, and provide failing tests for an edge case: if a resultset is provided, items matching the value itself will be excluded

Hanno Schlichting hannosch at hannosch.eu
Fri Apr 1 06:32:11 EDT 2011


Log message for revision 121190:
  Test passing in a resultset into _apply_index, and provide failing tests for an edge case: if a resultset is provided, items matching the value itself will be excluded
  

Changed:
  U   Products.ZCatalog/trunk/src/Products/PluginIndexes/DateRangeIndex/tests/test_DateRangeIndex.py

-=-
Modified: Products.ZCatalog/trunk/src/Products/PluginIndexes/DateRangeIndex/tests/test_DateRangeIndex.py
===================================================================
--- Products.ZCatalog/trunk/src/Products/PluginIndexes/DateRangeIndex/tests/test_DateRangeIndex.py	2011-04-01 10:05:22 UTC (rev 121189)
+++ Products.ZCatalog/trunk/src/Products/PluginIndexes/DateRangeIndex/tests/test_DateRangeIndex.py	2011-04-01 10:32:10 UTC (rev 121190)
@@ -190,7 +190,41 @@
         results, used = index._apply_index({'work': after})
         self.assertEqual(len(results), 0)
 
+    def test_resultset(self):
+        from BTrees.IIBTree import IISet
 
+        index = self._makeOne('work', 'start', 'stop')
+        for i in range(len(dummies)):
+            index.index_object(i, dummies[i])
+
+        results, used = index._apply_index({'work': 20})
+        self.assertEqual(set(results), set([0, 1, 2, 3]))
+
+        # a resultset with everything doesn't actually limit
+        results, used = index._apply_index({'work': 20},
+            resultset=IISet(range(len(dummies))))
+        self.assertEqual(set(results), set([0, 1, 2, 3]))
+
+        # a small resultset limits
+        results, used = index._apply_index({'work': 20},
+            resultset=IISet([1, 2]))
+        self.assertEqual(set(results), set([1, 2]))
+
+        # the specified value is included
+        results, used = index._apply_index({'work': 11})
+        self.assertEqual(set(results), set([0, 1, 2, 3, 5, 6]))
+
+        # the specified value is included with a large resultset
+        results, used = index._apply_index({'work': 11},
+            resultset=IISet(range(len(dummies))))
+        self.assertEqual(set(results), set([0, 1, 2, 3, 5, 6]))
+
+        # the specified value is included with a small resultset
+        results, used = index._apply_index({'work': 11},
+            resultset=IISet([0, 5, 7]))
+        self.assertEqual(set(results), set([0, 5]))
+
+
 def test_suite():
     suite = unittest.TestSuite()
     suite.addTest(unittest.makeSuite(DRI_Tests))



More information about the checkins mailing list