changeset 2951:bca1a0c997a2

search: add queryparser tests
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Fri, 30 Nov 2007 14:10:21 +0100
parents 42f93f4db9d0
children 1bb689d96ade
files MoinMoin/search/_tests/test_search.py
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/search/_tests/test_search.py	Fri Nov 30 13:32:36 2007 +0100
+++ b/MoinMoin/search/_tests/test_search.py	Fri Nov 30 14:10:21 2007 +0100
@@ -6,6 +6,8 @@
     @license: GNU GPL, see COPYING for details.
 """
 
+import pprint
+
 from MoinMoin import search
 
 
@@ -29,5 +31,22 @@
             assert not parser.isQuoted(case)
 
 
+class TestQueryParsing:
+    """ search: query parser tests """
+
+    def testQueryParser(self):
+        """ search: ... """
+        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"]'),
+            ("aaa OR bbb", '["aaa" "OR" "bbb"]'),
+            ]:
+            result = parser.parse_query(query)
+            assert str(result) == wanted
+
+
 coverage_modules = ['MoinMoin.search']