changeset 5644:3100da24a7fa

search tests: some cosmetic fixes, improve comments/docstrings
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Fri, 02 Apr 2010 23:59:31 +0200
parents 6282bd44c14c
children 028f38513d8e
files MoinMoin/search/_tests/test_search.py
diffstat 1 files changed, 14 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/search/_tests/test_search.py	Fri Apr 02 23:41:15 2010 +0200
+++ b/MoinMoin/search/_tests/test_search.py	Fri Apr 02 23:59:31 2010 +0200
@@ -2,8 +2,7 @@
 """
     MoinMoin - MoinMoin.search Tests
 
-    We exclude underlay/system pages for some search tests
-    to save time.
+    We exclude underlay/system pages for some search tests to save time.
 
     @copyright: 2005 by Nir Soffer <nirs@freeshell.org>,
                 2007-2010 by MoinMoin:ThomasWaldmann
@@ -104,7 +103,8 @@
              u'FrontPage': None,
              u'RecentChanges': None,
              u'HelpOnCreoleSyntax': None,
-             u'HelpIndex': None}
+             u'HelpIndex': None,
+            }
 
     searcher_class = None
 
@@ -142,7 +142,8 @@
                     u'title:TestOn': 1,
                     u'title:SearchTestNotExisting': 0,
                     u'title:FrontPage': 1,
-                    u'title:TestOnEditing': 1}
+                    u'title:TestOnEditing': 1,
+                   }
 
         def test(query, res_count):
             result = self.search(query)
@@ -336,7 +337,7 @@
         assert test_result == n_pages
 
     def testFullSearchRegexCaseInsensitive(self):
-        """ search: full search for regular expression """
+        """ search: full search for regular expression (case insensitive) """
         search_re = 'ne{2}dle' # matches 'NEEDLE' or 'needle' or ...
         expected_pages = set(['ContentSearchUpper', 'ContentSearchLower', ])
         result = self.search(u'-domain:underlay -domain:system re:%s' % search_re)
@@ -344,7 +345,7 @@
         assert found_pages == expected_pages
 
     def testFullSearchRegexCaseSensitive(self):
-        """ search: full search for regular expression """
+        """ search: full search for regular expression (case sensitive) """
         search_re = 'ne{2}dle' # matches 'needle'
         expected_pages = set(['ContentSearchLower', ])
         result = self.search(u'-domain:underlay -domain:system re:case:%s' % search_re)
@@ -396,7 +397,7 @@
             found_attachments = set([(hit.page_name, hit.attachment) for hit in result.hits])
             assert (page_name, '') in found_attachments
             assert 1 <= len(found_attachments) <= 2
-            # note: moin search on returns (page_name, '') as only result
+            # Note: moin search returns (page_name, '') as only result
             #       xapian search returns 2 results: (page_name, '') and (page_name, filename)
             # TODO: make behaviour the same, if possible
         finally:
@@ -412,7 +413,7 @@
 
 
 class TestMoinSearch(BaseSearchTest):
-
+    """ search: test Moin search """
     searcher_class = MoinSearch
 
     def get_searcher(self, query):
@@ -432,10 +433,9 @@
 
 
 class TestXapianSearch(BaseSearchTest):
-    """ search: test Xapian indexing """
+    """ search: test Xapian indexing / search """
 
     class Config(wikiconfig.Config):
-
         xapian_search = True
 
     def _index_update(self):
@@ -454,7 +454,6 @@
         return XapianIndex(self.request).get_search_connection()
 
     def setup_class(self):
-
         try:
             from MoinMoin.search.Xapian import XapianIndex
             from MoinMoin.search.Xapian.search import XapianSearch
@@ -463,7 +462,6 @@
         except ImportError, error:
             if not str(error).startswith('Xapian '):
                 raise
-
             py.test.skip('xapian is not installed')
 
         nuke_xapian_index(self.request)
@@ -497,7 +495,8 @@
                     u'category:': ([u'', u're:', u'case:', u'case:re:'], u'CategoryHomepage'),
                     u'mimetype:': ([u'', u're:'], u'text/wiki'),
                     u'language:': ([u''], u'en'),
-                    u'domain:': ([u''], u'system')}
+                    u'domain:': ([u''], u'system'),
+                   }
 
         def test_query(query):
             query_ = parser.parse_query(query).xapian_term(self.request, connection)
@@ -523,8 +522,9 @@
 
 
 class TestXapianSearchStemmed(TestXapianSearch):
+    """ search: test Xapian indexing / search - with stemming enabled """
+
     class Config(wikiconfig.Config):
-
         xapian_search = True
         xapian_stemming = True
 
@@ -545,7 +545,6 @@
 class TestGetSearcher(object):
 
     class Config(wikiconfig.Config):
-
         xapian_search = True
 
     def test_get_searcher(self):