Back to index

moin  1.9.0~rc2
Public Member Functions
test_search.TestQueryParsing Class Reference

List of all members.

Public Member Functions

def testQueryParser
def testQueryParserExceptions

Detailed Description

search: query parser tests 

Definition at line 29 of file

Member Function Documentation

search: test the query parser 

Definition at line 32 of file

00033     def testQueryParser(self):
00034         """ search: test the query parser """
00035         parser = QueryParser()
00036         for query, wanted in [
00037             # Even a single term is a and expression (this is needed for xapian because it
00038             # only has AND_NOT, but not a simple NOT).  This is why we have many many brackets here.
00039             ("a", '["a"]'),
00040             ("-a", '[-"a"]'),
00041             ("a b", '["a" "b"]'),
00042             ("a -b c", '["a" -"b" "c"]'),
00043             ("aaa bbb -ccc", '["aaa" "bbb" -"ccc"]'),
00044             ("title:aaa title:bbb -title:ccc", '[title:"aaa" title:"bbb" -title:"ccc"]'),
00045             ("title:case:aaa title:re:bbb -title:re:case:ccc", '[title:case:"aaa" title:re:"bbb" -title:re:case:"ccc"]'),
00046             ("linkto:aaa", '[linkto:"aaa"]'),
00047             ("category:aaa", '[category:"aaa"]'),
00048             ("domain:aaa", '[domain:"aaa"]'),
00049             ("re:case:title:aaa", '[title:re:case:"aaa"]'),
00050             ("(aaa or bbb) and (ccc or ddd)", '[[[["aaa"] or ["bbb"]]] [[["ccc"] or ["ddd"]]]]'),
00051             ("(aaa or bbb) (ccc or ddd)", '[[[["aaa"] or ["bbb"]]] [[["ccc"] or ["ddd"]]]]'),
00052             ("aaa or bbb", '[[["aaa"] or ["bbb"]]]'),
00053             ("aaa or bbb or ccc", '[[["aaa"] or [[["bbb"] or ["ccc"]]]]]'),
00054             ("aaa or bbb and ccc", '[[["aaa"] or ["bbb" "ccc"]]]'),
00055             ("aaa and bbb or ccc", '[[["aaa" "bbb"] or ["ccc"]]]'),
00056             ("aaa and bbb and ccc", '["aaa" "bbb" "ccc"]'),
00057             ("aaa or bbb and ccc or ddd", '[[["aaa"] or [[["bbb" "ccc"] or ["ddd"]]]]]'),
00058             ("aaa or bbb ccc or ddd", '[[["aaa"] or [[["bbb" "ccc"] or ["ddd"]]]]]'),
00059             ("(HelpOn) (Administration)", '[["HelpOn"] ["Administration"]]'),
00060             ("(HelpOn) (-Administration)", '[["HelpOn"] [-"Administration"]]'),
00061             ("(HelpOn) and (-Administration)", '[["HelpOn"] [-"Administration"]]'),
00062             ("(HelpOn) and (Administration) or (Configuration)", '[[[["HelpOn"] ["Administration"]] or [["Configuration"]]]]'),
00063             ("(a) and (b) or (c) or -d", '[[[["a"] ["b"]] or [[[["c"]] or [-"d"]]]]]'),
00064             ("a b c d e or f g h", '[[["a" "b" "c" "d" "e"] or ["f" "g" "h"]]]'),
00065             ('"no', '[""no"]'),
00066             ('no"', '["no""]'),
00067             ("'no", "[\"'no\"]"),
00068             ("no'", "[\"no'\"]"),
00069             ('"no\'', '[""no\'"]')]:
00070             result = parser.parse_query(query)
00071             assert str(result) == wanted

search: test the query parser 

Definition at line 72 of file

00073     def testQueryParserExceptions(self):
00074         """ search: test the query parser """
00075         parser = QueryParser()
00077         def _test(q):
00078             py.test.raises(QueryError, parser.parse_query, q)
00080         for query in ['""', '(', ')', '(a or b']:
00081             yield _test, query

Here is the call graph for this function:

The documentation for this class was generated from the following file: