annotate MoinMoin/search/_tests/test_search.py @ 4974:eb5644419456

Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
author Dmitrijs Milajevs <dimazest@gmail.com>
date Mon, 03 Aug 2009 19:23:54 +0200
parents 75c067fb7d1b
children 2171281b6d79
rev   line source
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
2 """
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 892
diff changeset
3 MoinMoin - MoinMoin.search Tests
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
4
2955
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
5 @copyright: 2005 by Nir Soffer <nirs@freeshell.org>,
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
6 2007 by MoinMoin:ThomasWaldmann
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 892
diff changeset
7 @license: GNU GPL, see COPYING for details.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
8 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
9
4974
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
10
2955
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
11 import py
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
12
4514
af09c1b3a153 fixed search (see details below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3698
diff changeset
13 from MoinMoin.search import QueryError
3421
d71aa6092994 queryparser tests: import QueryParser without detour
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3408
diff changeset
14 from MoinMoin.search.queryparser import QueryParser
4751
09c345615cd8 Put the finish method back on the context object so we can delay process such as thread joined until the end
Andy Dawkins <andydawkins@gmail.com>
parents: 4749
diff changeset
15 from MoinMoin.search import Xapian
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
16 from MoinMoin import search
4974
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
17 from MoinMoin._tests import nuke_xapian_index, wikiconfig
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
18
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
19
2951
bca1a0c997a2 search: add queryparser tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2950
diff changeset
20 class TestQueryParsing:
bca1a0c997a2 search: add queryparser tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2950
diff changeset
21 """ search: query parser tests """
bca1a0c997a2 search: add queryparser tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2950
diff changeset
22
bca1a0c997a2 search: add queryparser tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2950
diff changeset
23 def testQueryParser(self):
2953
41138237f2a5 search: add test for title search with negative term (currently failing)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2951
diff changeset
24 """ search: test the query parser """
3421
d71aa6092994 queryparser tests: import QueryParser without detour
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3408
diff changeset
25 parser = QueryParser()
2951
bca1a0c997a2 search: add queryparser tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2950
diff changeset
26 for query, wanted in [
3698
23a5fefa9553 search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3421
diff changeset
27 # Even a single term is a and expression (this is needed for xapian because it
23a5fefa9553 search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3421
diff changeset
28 # only has AND_NOT, but not a simple NOT). This is why we have many many brackets here.
23a5fefa9553 search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3421
diff changeset
29 ("a", '["a"]'),
23a5fefa9553 search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3421
diff changeset
30 ("-a", '[-"a"]'),
2951
bca1a0c997a2 search: add queryparser tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2950
diff changeset
31 ("a b", '["a" "b"]'),
bca1a0c997a2 search: add queryparser tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2950
diff changeset
32 ("a -b c", '["a" -"b" "c"]'),
bca1a0c997a2 search: add queryparser tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2950
diff changeset
33 ("aaa bbb -ccc", '["aaa" "bbb" -"ccc"]'),
3406
ccdd2bbf76f7 reimplement and thereby fix QueryParser
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3115
diff changeset
34 ("title:aaa title:bbb -title:ccc", '[title:"aaa" title:"bbb" -title:"ccc"]'),
ccdd2bbf76f7 reimplement and thereby fix QueryParser
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3115
diff changeset
35 ("title:case:aaa title:re:bbb -title:re:case:ccc", '[title:case:"aaa" title:re:"bbb" -title:re:case:"ccc"]'),
3698
23a5fefa9553 search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3421
diff changeset
36 ("linkto:aaa", '[linkto:"aaa"]'),
23a5fefa9553 search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3421
diff changeset
37 ("category:aaa", '[category:"aaa"]'),
23a5fefa9553 search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3421
diff changeset
38 ("domain:aaa", '[domain:"aaa"]'),
23a5fefa9553 search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3421
diff changeset
39 ("re:case:title:aaa", '[title:re:case:"aaa"]'),
23a5fefa9553 search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3421
diff changeset
40 ("(aaa or bbb) and (ccc or ddd)", '[[[["aaa"] or ["bbb"]]] [[["ccc"] or ["ddd"]]]]'),
23a5fefa9553 search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3421
diff changeset
41 ("(aaa or bbb) (ccc or ddd)", '[[[["aaa"] or ["bbb"]]] [[["ccc"] or ["ddd"]]]]'),
23a5fefa9553 search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3421
diff changeset
42 ("aaa or bbb", '[[["aaa"] or ["bbb"]]]'),
23a5fefa9553 search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3421
diff changeset
43 ("aaa or bbb or ccc", '[[["aaa"] or [[["bbb"] or ["ccc"]]]]]'),
23a5fefa9553 search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3421
diff changeset
44 ("aaa or bbb and ccc", '[[["aaa"] or ["bbb" "ccc"]]]'),
23a5fefa9553 search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3421
diff changeset
45 ("aaa and bbb or ccc", '[[["aaa" "bbb"] or ["ccc"]]]'),
3406
ccdd2bbf76f7 reimplement and thereby fix QueryParser
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3115
diff changeset
46 ("aaa and bbb and ccc", '["aaa" "bbb" "ccc"]'),
3698
23a5fefa9553 search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3421
diff changeset
47 ("aaa or bbb and ccc or ddd", '[[["aaa"] or [[["bbb" "ccc"] or ["ddd"]]]]]'),
23a5fefa9553 search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3421
diff changeset
48 ("aaa or bbb ccc or ddd", '[[["aaa"] or [[["bbb" "ccc"] or ["ddd"]]]]]'),
23a5fefa9553 search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3421
diff changeset
49 ("(HelpOn) (Administration)", '[["HelpOn"] ["Administration"]]'),
23a5fefa9553 search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3421
diff changeset
50 ("(HelpOn) (-Administration)", '[["HelpOn"] [-"Administration"]]'),
23a5fefa9553 search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3421
diff changeset
51 ("(HelpOn) and (-Administration)", '[["HelpOn"] [-"Administration"]]'),
23a5fefa9553 search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3421
diff changeset
52 ("(HelpOn) and (Administration) or (Configuration)", '[[[["HelpOn"] ["Administration"]] or [["Configuration"]]]]'),
23a5fefa9553 search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3421
diff changeset
53 ("(a) and (b) or (c) or -d", '[[[["a"] ["b"]] or [[[["c"]] or [-"d"]]]]]'),
23a5fefa9553 search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3421
diff changeset
54 ("a b c d e or f g h", '[[["a" "b" "c" "d" "e"] or ["f" "g" "h"]]]'),
23a5fefa9553 search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3421
diff changeset
55 ('"no', '[""no"]'),
23a5fefa9553 search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3421
diff changeset
56 ('no"', '["no""]'),
23a5fefa9553 search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3421
diff changeset
57 ("'no", "[\"'no\"]"),
23a5fefa9553 search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3421
diff changeset
58 ("no'", "[\"no'\"]"),
23a5fefa9553 search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3421
diff changeset
59 ('"no\'', '[""no\'"]')
2951
bca1a0c997a2 search: add queryparser tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2950
diff changeset
60 ]:
bca1a0c997a2 search: add queryparser tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2950
diff changeset
61 result = parser.parse_query(query)
bca1a0c997a2 search: add queryparser tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2950
diff changeset
62 assert str(result) == wanted
bca1a0c997a2 search: add queryparser tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2950
diff changeset
63
3408
7fd796b2e573 queryparser: catch exceptions, raise exception on '""'
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3406
diff changeset
64 def testQueryParserExceptions(self):
7fd796b2e573 queryparser: catch exceptions, raise exception on '""'
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3406
diff changeset
65 """ search: test the query parser """
3421
d71aa6092994 queryparser tests: import QueryParser without detour
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3408
diff changeset
66 parser = QueryParser()
4974
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
67
3408
7fd796b2e573 queryparser: catch exceptions, raise exception on '""'
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3406
diff changeset
68 def _test(q):
4514
af09c1b3a153 fixed search (see details below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3698
diff changeset
69 py.test.raises(QueryError, parser.parse_query, q)
4974
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
70
3408
7fd796b2e573 queryparser: catch exceptions, raise exception on '""'
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3406
diff changeset
71 for query in ['""', '(', ')', '(a or b']:
7fd796b2e573 queryparser: catch exceptions, raise exception on '""'
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3406
diff changeset
72 yield _test, query
2951
bca1a0c997a2 search: add queryparser tests
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2950
diff changeset
73
4974
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
74
2953
41138237f2a5 search: add test for title search with negative term (currently failing)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2951
diff changeset
75 class TestSearch:
41138237f2a5 search: add test for title search with negative term (currently failing)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2951
diff changeset
76 """ search: test search """
2955
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
77 doesnotexist = u'jfhsdaASDLASKDJ'
2953
41138237f2a5 search: add test for title search with negative term (currently failing)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2951
diff changeset
78
41138237f2a5 search: add test for title search with negative term (currently failing)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2951
diff changeset
79 def testTitleSearchFrontPage(self):
41138237f2a5 search: add test for title search with negative term (currently failing)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2951
diff changeset
80 """ search: title search for FrontPage """
2955
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
81 result = search.searchPages(self.request, u"title:FrontPage")
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
82 assert len(result.hits) == 1
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
83
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
84 def testTitleSearchAND(self):
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
85 """ search: title search with AND expression """
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
86 result = search.searchPages(self.request, u"title:Help title:Index")
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
87 assert len(result.hits) == 1
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
88
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
89 def testTitleSearchOR(self):
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
90 """ search: title search with OR expression """
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
91 result = search.searchPages(self.request, u"title:FrontPage or title:RecentChanges")
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
92 assert len(result.hits) == 2
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
93
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
94 def testTitleSearchNegatedFindAll(self):
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
95 """ search: negated title search for some pagename that does not exist results in all pagenames """
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
96 result = search.searchPages(self.request, u"-title:%s" % self.doesnotexist)
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
97 assert len(result.hits) > 100 # XXX should be "all"
2953
41138237f2a5 search: add test for title search with negative term (currently failing)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2951
diff changeset
98
41138237f2a5 search: add test for title search with negative term (currently failing)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2951
diff changeset
99 def testTitleSearchNegativeTerm(self):
2955
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
100 """ search: title search for a AND expression with a negative term """
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
101 helpon_count = len(search.searchPages(self.request, u"title:HelpOn").hits)
4749
03ae8522b246 (xoraxax with Safe) Fix page title in the test which had been broken since the beginning. Please do not check in failing tests to avoid this!
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 4514
diff changeset
102 result = search.searchPages(self.request, u"title:HelpOn -title:AccessControlLists")
2955
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
103 assert len(result.hits) == helpon_count - 1 # finds all HelpOn* except one
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
104
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
105 def testFullSearchNegatedFindAll(self):
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
106 """ search: negated full search for some string that does not exist results in all pages """
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
107 result = search.searchPages(self.request, u"-%s" % self.doesnotexist)
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
108 assert len(result.hits) > 100 # XXX should be "all"
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
109
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
110 def testFullSearchNegativeTerm(self):
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
111 """ search: full search for a AND expression with a negative term """
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
112 helpon_count = len(search.searchPages(self.request, u"HelpOn").hits)
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
113 result = search.searchPages(self.request, u"HelpOn -ACL")
c8a3731ce61c search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2953
diff changeset
114 assert 0 < len(result.hits) < helpon_count
2953
41138237f2a5 search: add test for title search with negative term (currently failing)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2951
diff changeset
115
4974
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
116 def test_title_search(self):
2953
41138237f2a5 search: add test for title search with negative term (currently failing)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2951
diff changeset
117
4974
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
118 query = QueryParser(titlesearch=True).parse_query('Moin')
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
119 result = search.searchPages(self.request, query, sort='page_name')
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
120
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
121
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
122 class TestXapianIndex(TestSearch):
4751
09c345615cd8 Put the finish method back on the context object so we can delay process such as thread joined until the end
Andy Dawkins <andydawkins@gmail.com>
parents: 4749
diff changeset
123 """ search: test Xapian indexing """
4974
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
124 # XXX skip it if xapian is not available
4751
09c345615cd8 Put the finish method back on the context object so we can delay process such as thread joined until the end
Andy Dawkins <andydawkins@gmail.com>
parents: 4749
diff changeset
125
4974
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
126 class Config(wikiconfig.Config):
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
127
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
128 xapian_search = True
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
129
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
130 def setup_class(self):
4751
09c345615cd8 Put the finish method back on the context object so we can delay process such as thread joined until the end
Andy Dawkins <andydawkins@gmail.com>
parents: 4749
diff changeset
131 """ search: kicks off indexing for a single pages in Xapian """
4876
75c067fb7d1b xapian indexing tests: fix api usage, fix comments, add comment about slowness
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4762
diff changeset
132 # This only tests that the call to indexing doesn't raise.
75c067fb7d1b xapian indexing tests: fix api usage, fix comments, add comment about slowness
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4762
diff changeset
133 nuke_xapian_index(self.request)
4753
5db0151a2df3 Done PEP-8 compilance
Cezary Krzy?anowski <cezary.krzyzanowski@gmail.com>
parents: 4751
diff changeset
134 idx = Xapian.Index(self.request)
4876
75c067fb7d1b xapian indexing tests: fix api usage, fix comments, add comment about slowness
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4762
diff changeset
135 idx.indexPages(mode='add') # slow: builds an index of all pages
4753
5db0151a2df3 Done PEP-8 compilance
Cezary Krzy?anowski <cezary.krzyzanowski@gmail.com>
parents: 4751
diff changeset
136
4974
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
137 def teardown_class(self):
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
138 nuke_xapian_index(self.request)
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
139
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
140
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
141 class TestXapianInNewThread(object):
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
142 """ search: test Xapian indexing """
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
143 # XXX skip it if xapian is not available
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
144
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
145 def setup_class(self):
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
146 """ search: kicks off indexing for a single pages in Xapian """
4876
75c067fb7d1b xapian indexing tests: fix api usage, fix comments, add comment about slowness
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4762
diff changeset
147 # This only tests that the call to indexing doesn't raise.
75c067fb7d1b xapian indexing tests: fix api usage, fix comments, add comment about slowness
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4762
diff changeset
148 nuke_xapian_index(self.request)
4753
5db0151a2df3 Done PEP-8 compilance
Cezary Krzy?anowski <cezary.krzyzanowski@gmail.com>
parents: 4751
diff changeset
149 idx = Xapian.Index(self.request)
4876
75c067fb7d1b xapian indexing tests: fix api usage, fix comments, add comment about slowness
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4762
diff changeset
150 idx.indexPagesInNewThread(mode='add') # slow: builds an index of all pages
4751
09c345615cd8 Put the finish method back on the context object so we can delay process such as thread joined until the end
Andy Dawkins <andydawkins@gmail.com>
parents: 4749
diff changeset
151
4974
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
152 def teardown_class(self):
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
153 nuke_xapian_index(self.request)
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
154
eb5644419456 Xapian2009: pagename field now is sortable. test_search.py pep8 fixes, TestSearch is done for both Moin and Xapian searchers.
Dmitrijs Milajevs <dimazest@gmail.com>
parents: 4876
diff changeset
155
2448
c9949c55ff5e add coverage_modules attribute for coverage testing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
156 coverage_modules = ['MoinMoin.search']
c9949c55ff5e add coverage_modules attribute for coverage testing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
157