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

Chris McDonough chrism@zope.com
Tue, 8 Oct 2002 14:41:41 -0400


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

Modified Files:
      Tag: chrism-install-branch
	testPathIndex.py 
Log Message:
Merging HEAD into chrism-install-branch.


=== Zope/lib/python/Products/PluginIndexes/PathIndex/tests/testPathIndex.py 1.7 => 1.7.4.1 ===
--- Zope/lib/python/Products/PluginIndexes/PathIndex/tests/testPathIndex.py:1.7	Wed Aug 14 18:19:31 2002
+++ Zope/lib/python/Products/PluginIndexes/PathIndex/tests/testPathIndex.py	Tue Oct  8 14:41:11 2002
@@ -53,8 +53,8 @@
           14 : Dummy("/bb/bb/bb/14.html"),
           15 : Dummy("/bb/bb/cc/15.html"),
           16 : Dummy("/bb/cc/aa/16.html"),
-          17 : Dummy("/bb/cc/bb/17html"),
-          18 : Dummy("/bb/cc/cc/18html")
+          17 : Dummy("/bb/cc/bb/17.html"),
+          18 : Dummy("/bb/cc/cc/18.html")
         }
 
     def _populateIndex(self):
@@ -79,21 +79,48 @@
         assert len(self._index._unindex)==0
 
 
+    def testRoot(self):
+
+        self._populateIndex()
+
+        tests = [
+            ("/",0, range(1,19)),
+        ]
+
+        for comp,level,results in tests:
+            for path in [comp,"/"+comp,"/"+comp+"/"]:
+                res = self._index._apply_index(
+                                    {"path":{'query':path,"level":level}})
+                lst = list(res[0].keys())
+                self.assertEqual(lst,results)
+
+        for comp,level,results in tests:
+            for path in [comp,"/"+comp,"/"+comp+"/"]:
+                res = self._index._apply_index(
+                                    {"path":{'query':( (path,level),)}})
+                lst = list(res[0].keys())
+                self.assertEqual(lst,results)
+
+
     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] ),
-            ("bb",0, [10,11,12,13,14,15,16,17,18]),
-            ("bb",1, [4,5,6,13,14,15] ),
-            ("bb/cc",0, [16,17,18] ),
-            ("bb/cc",1, [6,15] ),
-            ("bb/aa",0, [10,11,12] ),
-            ("bb/aa",1, [4,13] ),
-            ("aa/cc",-1, [3,7,8,9,12] ),
-            ("bb/bb",-1, [5,13,14,15] )
+            ("aa", 0, [1,2,3,4,5,6,7,8,9]),
+            ("aa", 1, [1,2,3,10,11,12] ),
+            ("bb", 0, [10,11,12,13,14,15,16,17,18]),
+            ("bb", 1, [4,5,6,13,14,15] ),
+            ("bb/cc", 0, [16,17,18] ),
+            ("bb/cc", 1, [6,15] ),
+            ("bb/aa", 0, [10,11,12] ),
+            ("bb/aa", 1, [4,13] ),
+            ("aa/cc", -1, [3,7,8,9,12] ),
+            ("bb/bb", -1, [5,13,14,15] ),
+            ("18.html", 3, [18] ),
+            ("18.html", -1, [18] ),
+            ("cc/18.html", -1, [18] ),
+            ("cc/18.html", 2, [18] ),
         ]
 
         for comp,level,results in tests:
@@ -146,3 +173,9 @@
 
 def test_suite():
     return unittest.makeSuite( TestCase )
+
+def main():
+    unittest.TextTestRunner().run(test_suite())
+
+if __name__ == '__main__':
+    main()