changeset 2953:41138237f2a5

search: add test for title search with negative term (currently failing)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Fri, 30 Nov 2007 14:58:20 +0100
parents 1bb689d96ade
children 96319d867986
files MoinMoin/search/_tests/test_search.py
diffstat 1 files changed, 18 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/search/_tests/test_search.py	Fri Nov 30 14:16:41 2007 +0100
+++ b/MoinMoin/search/_tests/test_search.py	Fri Nov 30 14:58:20 2007 +0100
@@ -6,8 +6,6 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-import pprint
-
 from MoinMoin import search
 
 
@@ -35,18 +33,35 @@
     """ search: query parser tests """
 
     def testQueryParser(self):
-        """ search: ... """
+        """ search: test the query parser """
         parser = search.QueryParser()
         for query, wanted in [
             ("a", '"a"'),
             ("a b", '["a" "b"]'),
             ("a -b c", '["a" -"b" "c"]'),
             ("aaa bbb -ccc", '["aaa" "bbb" -"ccc"]'),
+            ("title:aaa title:bbb -title:ccc", '[!"aaa" !"bbb" -!"ccc"]'),
             ("aaa OR bbb", '["aaa" "OR" "bbb"]'),
             ]:
             result = parser.parse_query(query)
             assert str(result) == wanted
 
 
+class TestSearch:
+    """ search: test search """
+
+    def testTitleSearchFrontPage(self):
+        """ search: title search for FrontPage """
+        query, wanted  = "title:FrontPage", 1
+        result = search.searchPages(self.request, query)
+        assert len(result.hits) == wanted
+
+    def testTitleSearchNegativeTerm(self):
+        """ search: title search for FrontPage """
+        helpon_count = len(search.searchPages(self.request, "title:HelpOn").hits)
+        result = search.searchPages(self.request, "title:HelpOn -title:Acl")
+        assert len(result.hits) == helpon_count - 1
+
+
 coverage_modules = ['MoinMoin.search']