[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/PathIndex/tests - testPathIndex.py:1.3
Andreas Jung
andreas@zope.com
Mon, 26 Nov 2001 13:15:26 -0500
Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/PathIndex/tests
In directory cvs.zope.org:/tmp/cvs-serv16878/lib/python/Products/PluginIndexes/PathIndex/tests
Modified Files:
testPathIndex.py
Log Message:
added more tests for complex searches
=== Zope/lib/python/Products/PluginIndexes/PathIndex/tests/testPathIndex.py 1.2 => 1.3 ===
- def testPopulateIndex( self ):
+ def testSimpleTests( self ):
self._populateIndex()
@@ -186,14 +186,49 @@
res = self._index._apply_index(
{"path":{'query':path,"level":level}})
lst = list(res[0].keys())
- assert lst==results,res
+ 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())
- assert lst==results,res
+ self.assertEqual(lst,results)
+
+
+ def testComplexOrTests( self ):
+
+ self._populateIndex()
+
+ tests = [
+ (['aa','bb'],1,[1,2,3,4,5,6,10,11,12,13,14,15]),
+ ([('cc',1),('cc',2)],0,[3,6,7,8,9,12,15,16,17,18]),
+ ]
+
+ for lst ,level,results in tests:
+
+ res = self._index._apply_index(
+ {"path":{'query':lst,"level":level,"operator":"or"}})
+ lst = list(res[0].keys())
+ self.assertEqual(lst,results)
+
+ def testComplexANDTests( self ):
+
+ self._populateIndex()
+
+ tests = [
+ (['aa','bb'],1,[]),
+ ([('aa',0),('bb',1)],0,[4,5,6]),
+ ([('aa',0),('cc',2)],0,[3,6,9]),
+ ]
+
+ for lst ,level,results in tests:
+
+ res = self._index._apply_index(
+ {"path":{'query':lst,"level":level,"operator":"and"}})
+ lst = list(res[0].keys())
+ self.assertEqual(lst,results)
+
def test_suite():
return unittest.makeSuite( TestCase )