[Zope3-checkins] CVS: Zope3/src/zope/keywordindex/tests - test_keywordindex.py:1.1.2.2

Andreas Jung andreas@andreas-jung.com
Sat, 12 Jul 2003 06:57:46 -0400


Update of /cvs-repository/Zope3/src/zope/keywordindex/tests
In directory cvs.zope.org:/tmp/cvs-serv6401/tests

Modified Files:
      Tag: ajung-keywordindex-branch
	test_keywordindex.py 
Log Message:
added search* methods


=== Zope3/src/zope/keywordindex/tests/test_keywordindex.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/keywordindex/tests/test_keywordindex.py:1.1.2.1	Sat Jul 12 05:31:59 2003
+++ Zope3/src/zope/keywordindex/tests/test_keywordindex.py	Sat Jul 12 06:57:42 2003
@@ -32,6 +32,24 @@
         self.index.index_doc(4, ())
         self.index.index_doc(5, ('cmf',))
 
+
+    def _search(self, query, expected, mode='and'):
+
+        results = self.index.search(query, mode)
+
+        # results and expected are IISets() but we can not
+        # compare them directly since __eq__() does not seem
+        # to be implemented for BTrees
+
+        self.assertEqual(results.keys(), expected.keys())
+
+    def _search_and(self, query, expected):
+        return self._search(query, expected, 'and')
+
+    def _search_or(self, query, expected):
+        return self._search(query, expected, 'or')
+
+
     def test_interface(self):
         verifyClass(IKeywordIndex, KeywordIndex)
 
@@ -78,7 +96,6 @@
     def test_simplesearch(self):
 
         self._populate_index()
-        self._search(None,    IISet())
         self._search('',      IISet())
         self._search('cmf',   IISet([1, 5]))
         self._search('zope',  IISet([1, 3]))