changeset 3698:23a5fefa9553

search query parser tests: adapt to current query parser behaviour
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 10 Jun 2008 21:22:48 +0200
parents 57d85b82bc3e
children 7b4a32481d1e
files MoinMoin/search/_tests/test_search.py
diffstat 1 files changed, 27 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/search/_tests/test_search.py	Tue Jun 10 09:02:51 2008 +0200
+++ b/MoinMoin/search/_tests/test_search.py	Tue Jun 10 21:22:48 2008 +0200
@@ -20,37 +20,39 @@
         """ search: test the query parser """
         parser = QueryParser()
         for query, wanted in [
-            ("a", '"a"'),
+            # Even a single term is a and expression (this is needed for xapian because it
+            # only has AND_NOT, but not a simple NOT).  This is why we have many many brackets here.
+            ("a", '["a"]'),
+            ("-a", '[-"a"]'),
             ("a b", '["a" "b"]'),
             ("a -b c", '["a" -"b" "c"]'),
             ("aaa bbb -ccc", '["aaa" "bbb" -"ccc"]'),
             ("title:aaa title:bbb -title:ccc", '[title:"aaa" title:"bbb" -title:"ccc"]'),
             ("title:case:aaa title:re:bbb -title:re:case:ccc", '[title:case:"aaa" title:re:"bbb" -title:re:case:"ccc"]'),
-            ("linkto:aaa", 'linkto:"aaa"'),
-            ("category:aaa", 'category:"aaa"'),
-            ("domain:aaa", 'domain:"aaa"'),
-            ("re:case:title:aaa", 'title:re:case:"aaa"'),
-            ("(aaa or bbb) and (ccc or ddd)", '[["aaa" or "bbb"] ["ccc" or "ddd"]]'),
-            ("(aaa or bbb) (ccc or ddd)", '[["aaa" or "bbb"] ["ccc" or "ddd"]]'),
-            ("aaa or bbb", '["aaa" or "bbb"]'),
-            ("aaa or bbb or ccc", '["aaa" or "bbb" or "ccc"]'),
-            ("aaa or bbb and ccc", '["aaa" or ["bbb" "ccc"]]'),
-            ("aaa and bbb or ccc", '[["aaa" "bbb"] or "ccc"]'),
+            ("linkto:aaa", '[linkto:"aaa"]'),
+            ("category:aaa", '[category:"aaa"]'),
+            ("domain:aaa", '[domain:"aaa"]'),
+            ("re:case:title:aaa", '[title:re:case:"aaa"]'),
+            ("(aaa or bbb) and (ccc or ddd)", '[[[["aaa"] or ["bbb"]]] [[["ccc"] or ["ddd"]]]]'),
+            ("(aaa or bbb) (ccc or ddd)", '[[[["aaa"] or ["bbb"]]] [[["ccc"] or ["ddd"]]]]'),
+            ("aaa or bbb", '[[["aaa"] or ["bbb"]]]'),
+            ("aaa or bbb or ccc", '[[["aaa"] or [[["bbb"] or ["ccc"]]]]]'),
+            ("aaa or bbb and ccc", '[[["aaa"] or ["bbb" "ccc"]]]'),
+            ("aaa and bbb or ccc", '[[["aaa" "bbb"] or ["ccc"]]]'),
             ("aaa and bbb and ccc", '["aaa" "bbb" "ccc"]'),
-            ("aaa or bbb or ccc", '["aaa" or "bbb" or "ccc"]'),
-            ("aaa or bbb and ccc or ddd", '["aaa" or ["bbb" "ccc"] or "ddd"]'),
-            ("aaa or bbb ccc or ddd", '["aaa" or ["bbb" "ccc"] or "ddd"]'),
-            ("(HelpOn) (Administration)", '["HelpOn" "Administration"]'),
-            ("(HelpOn) (-Administration)", '["HelpOn" -"Administration"]'),
-            ("(HelpOn) and (-Administration)", '["HelpOn" -"Administration"]'),
-            ("(HelpOn) and (Administration) or (Configuration)", '[["HelpOn" "Administration"] or "Configuration"]'),
-            ("(a) and (b) or (c) or -d", '[["a" "b"] or "c" or -"d"]'),
-            ("a b c d e or f g h", '[["a" "b" "c" "d" "e"] or ["f" "g" "h"]]'),
-            ('"no', '""no"'),
-            ('no"', '"no""'),
-            ("'no", "\"'no\""),
-            ("no'", "\"no'\""),
-            ('"no\'', '""no\'"')
+            ("aaa or bbb and ccc or ddd", '[[["aaa"] or [[["bbb" "ccc"] or ["ddd"]]]]]'),
+            ("aaa or bbb ccc or ddd", '[[["aaa"] or [[["bbb" "ccc"] or ["ddd"]]]]]'),
+            ("(HelpOn) (Administration)", '[["HelpOn"] ["Administration"]]'),
+            ("(HelpOn) (-Administration)", '[["HelpOn"] [-"Administration"]]'),
+            ("(HelpOn) and (-Administration)", '[["HelpOn"] [-"Administration"]]'),
+            ("(HelpOn) and (Administration) or (Configuration)", '[[[["HelpOn"] ["Administration"]] or [["Configuration"]]]]'),
+            ("(a) and (b) or (c) or -d", '[[[["a"] ["b"]] or [[[["c"]] or [-"d"]]]]]'),
+            ("a b c d e or f g h", '[[["a" "b" "c" "d" "e"] or ["f" "g" "h"]]]'),
+            ('"no', '[""no"]'),
+            ('no"', '["no""]'),
+            ("'no", "[\"'no\"]"),
+            ("no'", "[\"no'\"]"),
+            ('"no\'', '[""no\'"]')
             ]:
             result = parser.parse_query(query)
             assert str(result) == wanted