[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TopicIndex/test - testTopicIndex.py:1.1.2.2
Andreas Jung
andreas@zope.com
Tue, 16 Oct 2001 10:22:11 -0400
Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TopicIndex/test
In directory cvs.zope.org:/tmp/cvs-serv11527/test
Modified Files:
Tag: ajung-topicindex
testTopicIndex.py
Log Message:
added support for customizable FilteredSets
=== Zope/lib/python/Products/PluginIndexes/TopicIndex/test/testTopicIndex.py 1.1.2.1 => 1.1.2.2 ===
-
class TestTopicIndex(unittest.TestCase):
def setUp(self):
self.TI = TopicIndex("topicIndex")
- self.TI.addFilteredSet("doc1","meta_type=='doc1'")
- self.TI.addFilteredSet("doc2","meta_type=='doc2'")
+ self.TI.addFilteredSet("doc1","PythonFilteredSet","o.meta_type=='doc1'")
+ self.TI.addFilteredSet("doc2","PythonFilteredSet","o.meta_type=='doc2'")
self.TI.index_object(0 , Obj())
self.TI.index_object(1 , Obj('doc1'))
@@ -29,38 +28,42 @@
def testOr(self):
""" test 1 """
- self._searchOr('doc1')
- self._searchOr(['doc1'])
- self._searchOr('doc2')
- self._searchOr(['doc2'])
- self._searchOr('doc2')
- self._searchOr(['doc1','doc2'])
+ self._searchOr('doc1',[1,2])
+ self._searchOr(['doc1'],[1,2])
+ self._searchOr('doc2',[3,4]),
+ self._searchOr(['doc2'],[3,4])
+ self._searchOr(['doc1','doc2'], [1,2,3,4])
def testAnd(self):
""" test 1 """
- self._searchAnd('doc1')
- self._searchAnd(['doc1'])
- self._searchAnd('doc2')
- self._searchAnd(['doc2'])
- self._searchAnd('doc2')
- self._searchAnd(['doc1','doc2'])
+ self._searchAnd('doc1',[1,2])
+ self._searchAnd(['doc1'],[1,2])
+ self._searchAnd('doc2',[3,4])
+ self._searchAnd(['doc2'],[3,4])
+ self._searchAnd(['doc1','doc2'],[])
- def _searchAnd(self,query):
- return self._search(query,'and')
+ def _searchAnd(self,query,expected):
+ return self._search(query,'and',expected)
- def _searchOr(self,query):
- return self._search(query,'or')
+ def _searchOr(self,query,expected):
+ return self._search(query,'or',expected)
- def _search(self,query,operator):
+ def _search(self,query,operator,expected):
res = self.TI._apply_index({'topicIndex':{'query':query,'operator':operator}})
- print 'query: %s (%s), result: %s' % (query,operator,res)
- return res
-
+ rows = list(res[0])
+ rows.sort()
+ expected.sort()
+ assert rows==expected
+
+
+def test_suite():
+
+ return unittest.makeSuite(TestTopicIndex)
framework()