changeset 4994:605b2da7765e

Xapian2009: Test for xapian search was added which checks that index consists all required pages.
author Dmitrijs Milajevs <dimazest@gmail.com>
date Tue, 11 Aug 2009 22:30:26 +0200
parents 1d7a28cfc0f6
children 77496dd99338
files MoinMoin/search/_tests/test_search.py
diffstat 1 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/search/_tests/test_search.py	Mon Aug 10 21:30:54 2009 +0200
+++ b/MoinMoin/search/_tests/test_search.py	Tue Aug 11 22:30:26 2009 +0200
@@ -258,6 +258,10 @@
     def get_searcher(self, query):
         return XapianSearch(self.request, query)
 
+    def get_moin_search_connection(self):
+        from MoinMoin.search.Xapian import MoinSearchConnection
+        return  MoinSearchConnection('tests/wiki/data/cache/xapian/index') # XXX Index location should not be hardcoded!
+
     def setup_method(self, method):
 
         try:
@@ -272,12 +276,18 @@
     def teardown_method(self, method):
         nuke_xapian_index(self.request)
 
-    def test_xapian_term(self):
+    def test_get_all_documents(self):
+        connection = self.get_moin_search_connection()
+        documents = connection.get_all_documents()
 
-        from MoinMoin.search.Xapian import MoinSearchConnection
+        assert len(self.pages) == len(documents)
+        for document in documents:
+            assert document.data['pagename'][0] in self.pages.keys()
 
+    def test_xapian_term(self):
         parser = QueryParser()
-        connection = MoinSearchConnection('tests/wiki/data/cache/xapian/index') # XXX Index location should not be hardcoded!
+        connection = self.get_moin_search_connection()
+
         prefixes = {'title:': ['', 're:', 'case:', 'case:re:'],
                     'linkto:': ['', 're:', 'case:', 'case:re:'],
                     'category:': ['re:', 'case:', 'case:re:'],