[Zope-Checkins] CVS: Zope2 - test_UnIndex.py:1.3.4.3

Jim Fulton jim@digiciool.com
Mon, 12 Mar 2001 11:47:40 -0500 (EST)


Update of /cvs-repository/Zope2/lib/python/SearchIndex/tests
In directory korak:/tmp/cvs-serv27331

Modified Files:
      Tag: Catalog-BTrees-Integration
	test_UnIndex.py 
Log Message:
Added a simple range test.
Added some other standard debug machinery.



--- Updated File test_UnIndex.py in package test --
--- test_UnIndex.py	2001/03/05 00:19:20	1.3.4.2
+++ test_UnIndex.py	2001/03/12 16:47:39	1.3.4.3
@@ -226,10 +226,44 @@
         values = self._values
         self._checkApply(self._none_req, values[-1:])
         assert None in self._index.uniqueValues('foo')
+
+    def testRange(self):
+        """Test a range search"""
+        index = UnIndex( 'foo' )
+        for i in range(100):
+            index.index_object(i, Dummy(i%10))
+
+        r=index._apply_index({
+            'foo_usage': 'range:min:max',
+            'foo': [-99, 3]})
+
+        assert tuple(r[1])==('foo',), r[1]
+        r=list(r[0].keys())
+
+        expect=[
+            0, 1, 2, 3, 10, 11, 12, 13, 20, 21, 22, 23, 30, 31, 32, 33,
+            40, 41, 42, 43, 50, 51, 52, 53, 60, 61, 62, 63, 70, 71, 72, 73,
+            80, 81, 82, 83, 90, 91, 92, 93
+            ]
+        
+        assert r==expect, r 
+            
         
 def test_suite():
     return unittest.makeSuite( TestCase )
 
+def debug():
+    return test_suite().debug()
 
-if __name__ == '__main__':
+def pdebug():
+    import pdb
+    pdb.run('debug()')
+
+def main():
     unittest.TextTestRunner().run( test_suite() )
+
+if __name__ == '__main__':
+   if len(sys.argv) > 1:
+      globals()[sys.argv[1]]()
+   else:
+      main()



--- Updated File test_UnIndex.py in package Zope2 --
--- test_UnIndex.py	2001/03/05 00:19:20	1.3.4.2
+++ test_UnIndex.py	2001/03/12 16:47:39	1.3.4.3
@@ -226,10 +226,44 @@
         values = self._values
         self._checkApply(self._none_req, values[-1:])
         assert None in self._index.uniqueValues('foo')
+
+    def testRange(self):
+        """Test a range search"""
+        index = UnIndex( 'foo' )
+        for i in range(100):
+            index.index_object(i, Dummy(i%10))
+
+        r=index._apply_index({
+            'foo_usage': 'range:min:max',
+            'foo': [-99, 3]})
+
+        assert tuple(r[1])==('foo',), r[1]
+        r=list(r[0].keys())
+
+        expect=[
+            0, 1, 2, 3, 10, 11, 12, 13, 20, 21, 22, 23, 30, 31, 32, 33,
+            40, 41, 42, 43, 50, 51, 52, 53, 60, 61, 62, 63, 70, 71, 72, 73,
+            80, 81, 82, 83, 90, 91, 92, 93
+            ]
+        
+        assert r==expect, r 
+            
         
 def test_suite():
     return unittest.makeSuite( TestCase )
 
+def debug():
+    return test_suite().debug()
 
-if __name__ == '__main__':
+def pdebug():
+    import pdb
+    pdb.run('debug()')
+
+def main():
     unittest.TextTestRunner().run( test_suite() )
+
+if __name__ == '__main__':
+   if len(sys.argv) > 1:
+      globals()[sys.argv[1]]()
+   else:
+      main()