[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/PathIndex/tests - testPathIndex.py:1.10.36.1

Andreas Jung andreas at andreas-jung.com
Fri Aug 15 11:35:33 EDT 2003


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

Modified Files:
      Tag: ajung-indexes-btrees-length-branch
	testPathIndex.py 
Log Message:
- white space cleanup
- code cleanup
- removed splitPath()
- added tests for reindexing


=== Zope/lib/python/Products/PluginIndexes/PathIndex/tests/testPathIndex.py 1.10 => 1.10.36.1 ===
--- Zope/lib/python/Products/PluginIndexes/PathIndex/tests/testPathIndex.py:1.10	Thu Nov 28 08:03:10 2002
+++ Zope/lib/python/Products/PluginIndexes/PathIndex/tests/testPathIndex.py	Fri Aug 15 10:35:28 2003
@@ -19,13 +19,13 @@
 class Dummy:
 
     meta_type="foo"
+
     def __init__( self, path):
         self.path = path
 
     def getPhysicalPath(self):
         return self.path.split('/')
 
-
     def __str__( self ):
         return '<Dummy: %s>' % self.path
 
@@ -62,25 +62,35 @@
             self._index.index_object( k, v )
 
     def testEmpty(self):
-
         assert len( self._index ) == 0
         assert self._index.getEntryForObject( 1234 ) is None
         self._index.unindex_object( 1234 ) # nothrow
         assert self._index._apply_index( {"suxpath":"xxx"} ) is None
 
     def testUnIndex(self):
-
         self._populateIndex()
+        self.assertEqual(self._index.numObjects(), 18)
 
         for k in self._values.keys():
             self._index.unindex_object(k)
 
+        self.assertEqual(self._index.numObjects(), 0)
         assert len(self._index._index)==0
         assert len(self._index._unindex)==0
 
+    def testReindex(self):
+        self._populateIndex()
+        self.assertEqual(self._index.numObjects(), 18)
+
+        o = Dummy('/foo/bar')
+        self._index.index_object(19, o)
+        self.assertEqual(self._index.numObjects(), 19)
+        self._index.index_object(19, o)
+        self.assertEqual(self._index.numObjects(), 19)
+
+
     def testUnIndexError(self):
         self._populateIndex()
-        
         # this should not raise an error
         self._index.unindex_object(-1)
 
@@ -91,10 +101,7 @@
     def testRoot(self):
 
         self._populateIndex()
-
-        tests = [
-            ("/",0, range(1,19)),
-        ]
+        tests = ( ("/",0, range(1,19)), )
 
         for comp,level,results in tests:
             for path in [comp,"/"+comp,"/"+comp+"/"]:
@@ -110,14 +117,10 @@
                 lst = list(res[0].keys())
                 self.assertEqual(lst,results)
 
-
     def testRoot(self):
 
         self._populateIndex()
-
-        tests = [
-            ("/",0, range(1,19)),
-        ]
+        tests = ( ("/",0, range(1,19)), )
 
         for comp,level,results in tests:
             for path in [comp,"/"+comp,"/"+comp+"/"]:
@@ -137,7 +140,6 @@
     def testSimpleTests(self):
 
         self._populateIndex()
-
         tests = [
             ("aa", 0, [1,2,3,4,5,6,7,8,9]),
             ("aa", 1, [1,2,3,10,11,12] ),
@@ -172,7 +174,6 @@
     def testComplexOrTests(self):
 
         self._populateIndex()
-
         tests = [
             (['aa','bb'],1,[1,2,3,4,5,6,10,11,12,13,14,15]),
             (['aa','bb','xx'],1,[1,2,3,4,5,6,10,11,12,13,14,15]),
@@ -189,7 +190,6 @@
     def testComplexANDTests(self):
 
         self._populateIndex()
-
         tests = [
             (['aa','bb'],1,[]),
             ([('aa',0),('bb',1)],0,[4,5,6]),
@@ -197,7 +197,6 @@
         ]
 
         for lst ,level,results in tests:
-
             res = self._index._apply_index(
                             {"path":{'query':lst,"level":level,"operator":"and"}})
             lst = list(res[0].keys())




More information about the Zope-Checkins mailing list