Mercurial > moin > 1.9
annotate MoinMoin/search/_tests/test_search.py @ 6133:a6283e189869 tip
fixup: remove nonexisting passlib.utils._blowfish
this was removed by the passlib 1.7.1 upgrade.
author  Thomas Waldmann <tw AT waldmannedv DOT de> 

date  Thu, 01 Jun 2017 18:10:19 +0200 
parents  3100da24a7fa 
children 
rev  line source 

0
77665d8e2254
tag of nonpublic@localhostarchive/moinenterprise1.5base0
Thomas Waldmann <twpublic@gmx.de>
parents:
diff
changeset

1 # * coding: iso88591 * 
77665d8e2254
tag of nonpublic@localhostarchive/moinenterprise1.5base0
Thomas Waldmann <twpublic@gmx.de>
parents:
diff
changeset

2 """ 
1918
bb2e053067fb
fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
892
diff
changeset

3 MoinMoin  MoinMoin.search Tests 
0
77665d8e2254
tag of nonpublic@localhostarchive/moinenterprise1.5base0
Thomas Waldmann <twpublic@gmx.de>
parents:
diff
changeset

4 
5644
3100da24a7fa
search tests: some cosmetic fixes, improve comments/docstrings
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5643
diff
changeset

5 We exclude underlay/system pages for some search tests to save time. 
5604
bd4419916312
test_search: doc string "exclude underlay/system pages" added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5603
diff
changeset

6 
2955
c8a3731ce61c
search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2953
diff
changeset

7 @copyright: 2005 by Nir Soffer <nirs@freeshell.org>, 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

8 20072010 by MoinMoin:ThomasWaldmann 
1918
bb2e053067fb
fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
892
diff
changeset

9 @license: GNU GPL, see COPYING for details. 
0
77665d8e2254
tag of nonpublic@localhostarchive/moinenterprise1.5base0
Thomas Waldmann <twpublic@gmx.de>
parents:
diff
changeset

10 """ 
77665d8e2254
tag of nonpublic@localhostarchive/moinenterprise1.5base0
Thomas Waldmann <twpublic@gmx.de>
parents:
diff
changeset

11 
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

12 
5281
5f0ec1f315bc
xapian: new locking, removed threading and signing (details see below)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5276
diff
changeset

13 import os, StringIO, time 
5f0ec1f315bc
xapian: new locking, removed threading and signing (details see below)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5276
diff
changeset

14 
5f0ec1f315bc
xapian: new locking, removed threading and signing (details see below)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5276
diff
changeset

15 import py 
2955
c8a3731ce61c
search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2953
diff
changeset

16 
5045
d77ac3c87ac8
Xapian2009: refactoring of searchPages. Tests for it.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5044
diff
changeset

17 from MoinMoin.search import QueryError, _get_searcher 
3421
d71aa6092994
queryparser tests: import QueryParser without detour
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
3408
diff
changeset

18 from MoinMoin.search.queryparser import QueryParser 
5044
f5f3d7348564
Xapian2009: Class Xapian.indexing.Index is renamed to XapianIndex. _check_version() was removed, xapian binding check is done by xappy. XapianSearch was moved to Xapian.search. Log message is shown if xapian version is too old.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5036
diff
changeset

19 from MoinMoin.search.builtin import MoinSearch 
5167
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

20 from MoinMoin._tests import nuke_xapian_index, wikiconfig, become_trusted, create_page, nuke_page, append_page 
5031
d0af0cf05fc2
Xapian2009: py version is checked using new MoinMoin.wikiutil.Version class.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5029
diff
changeset

21 from MoinMoin.wikiutil import Version 
5167
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

22 from MoinMoin.action import AttachFile 
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

23 
5031
d0af0cf05fc2
Xapian2009: py version is checked using new MoinMoin.wikiutil.Version class.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5029
diff
changeset

24 PY_MIN_VERSION = '1.0.0' 
d0af0cf05fc2
Xapian2009: py version is checked using new MoinMoin.wikiutil.Version class.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5029
diff
changeset

25 if Version(version=py.version) < Version(version=PY_MIN_VERSION): 
4995
77496dd99338
Xapian2009: Search tests are skipped if py version is not 1.0.0
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4994
diff
changeset

26 # There are some generative tests, which won't run on older versions! 
77496dd99338
Xapian2009: Search tests are skipped if py version is not 1.0.0
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4994
diff
changeset

27 # XXX These tests should be refactored to be able to be run with older versions of py. 
5031
d0af0cf05fc2
Xapian2009: py version is checked using new MoinMoin.wikiutil.Version class.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5029
diff
changeset

28 py.test.skip('Currently py version %s is needed' % PY_MIN_VERSION) 
4995
77496dd99338
Xapian2009: Search tests are skipped if py version is not 1.0.0
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4994
diff
changeset

29 
0
77665d8e2254
tag of nonpublic@localhostarchive/moinenterprise1.5base0
Thomas Waldmann <twpublic@gmx.de>
parents:
diff
changeset

30 
4978
0b5aaec043cd
Xapian2009: Tests for mimetype, language and domain. Test classes are new style classes.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4977
diff
changeset

31 class TestQueryParsing(object): 
2951
bca1a0c997a2
search: add queryparser tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2950
diff
changeset

32 """ search: query parser tests """ 
bca1a0c997a2
search: add queryparser tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2950
diff
changeset

33 
bca1a0c997a2
search: add queryparser tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2950
diff
changeset

34 def testQueryParser(self): 
2953
41138237f2a5
search: add test for title search with negative term (currently failing)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2951
diff
changeset

35 """ search: test the query parser """ 
3421
d71aa6092994
queryparser tests: import QueryParser without detour
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
3408
diff
changeset

36 parser = QueryParser() 
2951
bca1a0c997a2
search: add queryparser tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2950
diff
changeset

37 for query, wanted in [ 
3698
23a5fefa9553
search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
3421
diff
changeset

38 # 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 waldmannedv DOT de>
parents:
3421
diff
changeset

39 # 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 waldmannedv DOT de>
parents:
3421
diff
changeset

40 ("a", '["a"]'), 
23a5fefa9553
search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
3421
diff
changeset

41 ("a", '["a"]'), 
2951
bca1a0c997a2
search: add queryparser tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2950
diff
changeset

42 ("a b", '["a" "b"]'), 
bca1a0c997a2
search: add queryparser tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2950
diff
changeset

43 ("a b c", '["a" "b" "c"]'), 
bca1a0c997a2
search: add queryparser tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2950
diff
changeset

44 ("aaa bbb ccc", '["aaa" "bbb" "ccc"]'), 
3406
ccdd2bbf76f7
reimplement and thereby fix QueryParser
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
3115
diff
changeset

45 ("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

46 ("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 waldmannedv DOT de>
parents:
3421
diff
changeset

47 ("linkto:aaa", '[linkto:"aaa"]'), 
23a5fefa9553
search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
3421
diff
changeset

48 ("category:aaa", '[category:"aaa"]'), 
23a5fefa9553
search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
3421
diff
changeset

49 ("domain:aaa", '[domain:"aaa"]'), 
23a5fefa9553
search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
3421
diff
changeset

50 ("re:case:title:aaa", '[title:re:case:"aaa"]'), 
23a5fefa9553
search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
3421
diff
changeset

51 ("(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 waldmannedv DOT de>
parents:
3421
diff
changeset

52 ("(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 waldmannedv DOT de>
parents:
3421
diff
changeset

53 ("aaa or bbb", '[[["aaa"] or ["bbb"]]]'), 
23a5fefa9553
search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
3421
diff
changeset

54 ("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 waldmannedv DOT de>
parents:
3421
diff
changeset

55 ("aaa or bbb and ccc", '[[["aaa"] or ["bbb" "ccc"]]]'), 
23a5fefa9553
search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
3421
diff
changeset

56 ("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

57 ("aaa and bbb and ccc", '["aaa" "bbb" "ccc"]'), 
3698
23a5fefa9553
search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
3421
diff
changeset

58 ("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 waldmannedv DOT de>
parents:
3421
diff
changeset

59 ("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 waldmannedv DOT de>
parents:
3421
diff
changeset

60 ("(HelpOn) (Administration)", '[["HelpOn"] ["Administration"]]'), 
23a5fefa9553
search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
3421
diff
changeset

61 ("(HelpOn) (Administration)", '[["HelpOn"] ["Administration"]]'), 
23a5fefa9553
search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
3421
diff
changeset

62 ("(HelpOn) and (Administration)", '[["HelpOn"] ["Administration"]]'), 
23a5fefa9553
search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
3421
diff
changeset

63 ("(HelpOn) and (Administration) or (Configuration)", '[[[["HelpOn"] ["Administration"]] or [["Configuration"]]]]'), 
23a5fefa9553
search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
3421
diff
changeset

64 ("(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 waldmannedv DOT de>
parents:
3421
diff
changeset

65 ("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 waldmannedv DOT de>
parents:
3421
diff
changeset

66 ('"no', '[""no"]'), 
23a5fefa9553
search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
3421
diff
changeset

67 ('no"', '["no""]'), 
23a5fefa9553
search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
3421
diff
changeset

68 ("'no", "[\"'no\"]"), 
23a5fefa9553
search query parser tests: adapt to current query parser behaviour
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
3421
diff
changeset

69 ("no'", "[\"no'\"]"), 
4981
f1d1d8105d52
Xapian2009: pep8 fixes.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4978
diff
changeset

70 ('"no\'', '[""no\'"]')]: 
2951
bca1a0c997a2
search: add queryparser tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2950
diff
changeset

71 result = parser.parse_query(query) 
bca1a0c997a2
search: add queryparser tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2950
diff
changeset

72 assert str(result) == wanted 
bca1a0c997a2
search: add queryparser tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2950
diff
changeset

73 
3408
7fd796b2e573
queryparser: catch exceptions, raise exception on '""'
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
3406
diff
changeset

74 def testQueryParserExceptions(self): 
7fd796b2e573
queryparser: catch exceptions, raise exception on '""'
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
3406
diff
changeset

75 """ search: test the query parser """ 
3421
d71aa6092994
queryparser tests: import QueryParser without detour
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
3408
diff
changeset

76 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

77 
3408
7fd796b2e573
queryparser: catch exceptions, raise exception on '""'
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
3406
diff
changeset

78 def _test(q): 
4514
af09c1b3a153
fixed search (see details below)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
3698
diff
changeset

79 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

80 
3408
7fd796b2e573
queryparser: catch exceptions, raise exception on '""'
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
3406
diff
changeset

81 for query in ['""', '(', ')', '(a or b']: 
7fd796b2e573
queryparser: catch exceptions, raise exception on '""'
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
3406
diff
changeset

82 yield _test, query 
2951
bca1a0c997a2
search: add queryparser tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2950
diff
changeset

83 
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

84 
4992
c6da526a8c30
Xapian2009: Moin serach doesn't search in all available pages during tests, but only in listed in the BaseSearchTest.pages. Tests check number of returned hits.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4991
diff
changeset

85 class BaseSearchTest(object): 
2953
41138237f2a5
search: add test for title search with negative term (currently failing)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2951
diff
changeset

86 """ search: test search """ 
2955
c8a3731ce61c
search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2953
diff
changeset

87 doesnotexist = u'jfhsdaASDLASKDJ' 
2953
41138237f2a5
search: add test for title search with negative term (currently failing)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2951
diff
changeset

88 
5167
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

89 # key  page name, value  page content. If value is None page 
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

90 # will not be created but will be used for a search. None should 
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

91 # be used for pages which already exist. 
5007
2df0f9d09669
Xapian2009: grammar fix.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5006
diff
changeset

92 pages = {u'SearchTestPage': u'this is a test page', 
5000
52f2454de7ab
Xapian2009: unicode objects are used instead of strings in search tests.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4999
diff
changeset

93 u'SearchTestLinks': u'SearchTestPage', 
52f2454de7ab
Xapian2009: unicode objects are used instead of strings in search tests.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4999
diff
changeset

94 u'SearchTestLinksLowerCase': u'searchtestpage', 
52f2454de7ab
Xapian2009: unicode objects are used instead of strings in search tests.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4999
diff
changeset

95 u'SearchTestOtherLinks': u'SearchTestLinks', 
5035
93becb451375
Xapian2009: BaseTextFieldSearch.xapian_term() refactoring. Tests for a search with stemming.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5031
diff
changeset

96 u'TestEdit': u'TestEdit', 
5603
5e01b23e0a37
test_search: replaced testpage name HelpOnEditing by TestOnEditing, because we need a page with a similiar name but without attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5602
diff
changeset

97 u'TestOnEditing': u'another test page', 
5642
226e1b0aa79c
search tests: simplify and extend test for regex search
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5641
diff
changeset

98 u'ContentSearchUpper': u'Find the NEEDLE in the haystack.', 
226e1b0aa79c
search tests: simplify and extend test for regex search
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5641
diff
changeset

99 u'ContentSearchLower': u'Find the needle in the haystack.', 
5000
52f2454de7ab
Xapian2009: unicode objects are used instead of strings in search tests.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4999
diff
changeset

100 u'LanguageSetup': None, 
52f2454de7ab
Xapian2009: unicode objects are used instead of strings in search tests.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4999
diff
changeset

101 u'CategoryHomepage': None, 
52f2454de7ab
Xapian2009: unicode objects are used instead of strings in search tests.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4999
diff
changeset

102 u'HomePageWiki': None, 
52f2454de7ab
Xapian2009: unicode objects are used instead of strings in search tests.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4999
diff
changeset

103 u'FrontPage': None, 
52f2454de7ab
Xapian2009: unicode objects are used instead of strings in search tests.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4999
diff
changeset

104 u'RecentChanges': None, 
52f2454de7ab
Xapian2009: unicode objects are used instead of strings in search tests.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4999
diff
changeset

105 u'HelpOnCreoleSyntax': None, 
5644
3100da24a7fa
search tests: some cosmetic fixes, improve comments/docstrings
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5643
diff
changeset

106 u'HelpIndex': None, 
3100da24a7fa
search tests: some cosmetic fixes, improve comments/docstrings
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5643
diff
changeset

107 } 
4977
2171281b6d79
Xapian2009: Search tests update. regex: and case: prefixes tests were added for title, linkto and category.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4974
diff
changeset

108 
5045
d77ac3c87ac8
Xapian2009: refactoring of searchPages. Tests for it.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5044
diff
changeset

109 searcher_class = None 
d77ac3c87ac8
Xapian2009: refactoring of searchPages. Tests for it.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5044
diff
changeset

110 
5281
5f0ec1f315bc
xapian: new locking, removed threading and signing (details see below)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5276
diff
changeset

111 def _index_update(self): 
5167
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

112 pass 
4977
2171281b6d79
Xapian2009: Search tests update. regex: and case: prefixes tests were added for title, linkto and category.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4974
diff
changeset

113 
5167
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

114 @classmethod 
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

115 def setup_class(cls): 
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

116 request = cls.request 
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

117 become_trusted(request) 
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

118 
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

119 for page, text in cls.pages.iteritems(): 
4992
c6da526a8c30
Xapian2009: Moin serach doesn't search in all available pages during tests, but only in listed in the BaseSearchTest.pages. Tests check number of returned hits.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4991
diff
changeset

120 if text: 
5167
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

121 create_page(request, page, text) 
4977
2171281b6d79
Xapian2009: Search tests update. regex: and case: prefixes tests were added for title, linkto and category.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4974
diff
changeset

122 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

123 def teardown_class(self): 
4992
c6da526a8c30
Xapian2009: Moin serach doesn't search in all available pages during tests, but only in listed in the BaseSearchTest.pages. Tests check number of returned hits.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4991
diff
changeset

124 for page, text in self.pages.iteritems(): 
c6da526a8c30
Xapian2009: Moin serach doesn't search in all available pages during tests, but only in listed in the BaseSearchTest.pages. Tests check number of returned hits.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4991
diff
changeset

125 if text: 
c6da526a8c30
Xapian2009: Moin serach doesn't search in all available pages during tests, but only in listed in the BaseSearchTest.pages. Tests check number of returned hits.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4991
diff
changeset

126 nuke_page(self.request, page) 
c6da526a8c30
Xapian2009: Moin serach doesn't search in all available pages during tests, but only in listed in the BaseSearchTest.pages. Tests check number of returned hits.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4991
diff
changeset

127 
4997
8b51025823e0
Xapian2009: pep8 and typo fixes.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4996
diff
changeset

128 def get_searcher(self, query): 
4992
c6da526a8c30
Xapian2009: Moin serach doesn't search in all available pages during tests, but only in listed in the BaseSearchTest.pages. Tests check number of returned hits.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4991
diff
changeset

129 raise NotImplementedError 
2955
c8a3731ce61c
search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2953
diff
changeset

130 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

131 def search(self, query): 
4992
c6da526a8c30
Xapian2009: Moin serach doesn't search in all available pages during tests, but only in listed in the BaseSearchTest.pages. Tests check number of returned hits.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4991
diff
changeset

132 if isinstance(query, str) or isinstance(query, unicode): 
c6da526a8c30
Xapian2009: Moin serach doesn't search in all available pages during tests, but only in listed in the BaseSearchTest.pages. Tests check number of returned hits.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4991
diff
changeset

133 query = QueryParser().parse_query(query) 
c6da526a8c30
Xapian2009: Moin serach doesn't search in all available pages during tests, but only in listed in the BaseSearchTest.pages. Tests check number of returned hits.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4991
diff
changeset

134 
c6da526a8c30
Xapian2009: Moin serach doesn't search in all available pages during tests, but only in listed in the BaseSearchTest.pages. Tests check number of returned hits.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4991
diff
changeset

135 return self.get_searcher(query).run() 
4978
0b5aaec043cd
Xapian2009: Tests for mimetype, language and domain. Test classes are new style classes.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4977
diff
changeset

136 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

137 def test_title_search_simple(self): 
5000
52f2454de7ab
Xapian2009: unicode objects are used instead of strings in search tests.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4999
diff
changeset

138 searches = {u'title:SearchTestPage': 1, 
52f2454de7ab
Xapian2009: unicode objects are used instead of strings in search tests.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4999
diff
changeset

139 u'title:LanguageSetup': 1, 
5015
bc42755b5820
Xapian2009: AndExpression.xapian_term() was refactored. Tests for "and" were updated.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5007
diff
changeset

140 u'title:HelpIndex': 1, 
5603
5e01b23e0a37
test_search: replaced testpage name HelpOnEditing by TestOnEditing, because we need a page with a similiar name but without attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5602
diff
changeset

141 u'title:Help': 2, 
5e01b23e0a37
test_search: replaced testpage name HelpOnEditing by TestOnEditing, because we need a page with a similiar name but without attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5602
diff
changeset

142 u'title:TestOn': 1, 
5035
93becb451375
Xapian2009: BaseTextFieldSearch.xapian_term() refactoring. Tests for a search with stemming.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5031
diff
changeset

143 u'title:SearchTestNotExisting': 0, 
93becb451375
Xapian2009: BaseTextFieldSearch.xapian_term() refactoring. Tests for a search with stemming.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5031
diff
changeset

144 u'title:FrontPage': 1, 
5644
3100da24a7fa
search tests: some cosmetic fixes, improve comments/docstrings
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5643
diff
changeset

145 u'title:TestOnEditing': 1, 
3100da24a7fa
search tests: some cosmetic fixes, improve comments/docstrings
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5643
diff
changeset

146 } 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

147 
4999
b73ced174002
Xapian2009: test_title_search_simple is now generative test.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4998
diff
changeset

148 def test(query, res_count): 
b73ced174002
Xapian2009: test_title_search_simple is now generative test.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4998
diff
changeset

149 result = self.search(query) 
5602
8d3799e97a01
test_search: for failing tests show the wrong value and not the expression
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5601
diff
changeset

150 test_result = len(result.hits) 
8d3799e97a01
test_search: for failing tests show the wrong value and not the expression
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5601
diff
changeset

151 assert test_result == res_count 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

152 
4999
b73ced174002
Xapian2009: test_title_search_simple is now generative test.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4998
diff
changeset

153 for query, res_count in searches.iteritems(): 
b73ced174002
Xapian2009: test_title_search_simple is now generative test.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4998
diff
changeset

154 yield query, test, query, res_count 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

155 
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

156 def test_title_search_re(self): 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

157 expected_pages = set([u'SearchTestPage', u'SearchTestLinks', u'SearchTestLinksLowerCase', u'SearchTestOtherLinks', ]) 
5601
0c94d0486a5c
test_search: ignore domain underlay and system for various tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5282
diff
changeset

158 result = self.search(ur'domain:underlay domain:system title:re:\bSearchTest') 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

159 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

160 assert found_pages == expected_pages 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

161 
5601
0c94d0486a5c
test_search: ignore domain underlay and system for various tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5282
diff
changeset

162 result = self.search(ur'domain:underlay domain:system title:re:\bSearchTest\b') 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

163 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

164 assert not found_pages 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

165 
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

166 def test_title_search_case(self): 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

167 expected_pages = set([u'SearchTestPage', ]) 
5601
0c94d0486a5c
test_search: ignore domain underlay and system for various tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5282
diff
changeset

168 result = self.search(u'domain:underlay domain:system title:case:SearchTestPage') 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

169 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

170 assert found_pages == expected_pages 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

171 
5601
0c94d0486a5c
test_search: ignore domain underlay and system for various tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5282
diff
changeset

172 result = self.search(u'domain:underlay domain:system title:case:searchtestpage') 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

173 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

174 assert not found_pages 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

175 
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

176 def test_title_search_case_re(self): 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

177 expected_pages = set([u'SearchTestPage', ]) 
5601
0c94d0486a5c
test_search: ignore domain underlay and system for various tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5282
diff
changeset

178 result = self.search(ur'domain:underlay domain:system title:case:re:\bSearchTestPage\b') 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

179 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

180 assert found_pages == expected_pages 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

181 
5601
0c94d0486a5c
test_search: ignore domain underlay and system for various tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5282
diff
changeset

182 result = self.search(ur'domain:underlay domain:system title:case:re:\bsearchtestpage\b') 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

183 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

184 assert not found_pages 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

185 
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

186 def test_linkto_search_simple(self): 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

187 expected_pages = set([u'SearchTestLinks', ]) 
5601
0c94d0486a5c
test_search: ignore domain underlay and system for various tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5282
diff
changeset

188 result = self.search(u'domain:underlay domain:system linkto:SearchTestPage') 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

189 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

190 assert found_pages == expected_pages 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

191 
5601
0c94d0486a5c
test_search: ignore domain underlay and system for various tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5282
diff
changeset

192 result = self.search(u'domain:underlay domain:system linkto:SearchTestNotExisting') 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

193 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

194 assert not found_pages 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

195 
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

196 def test_linkto_search_re(self): 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

197 expected_pages = set([u'SearchTestLinks', u'SearchTestOtherLinks', ]) 
5601
0c94d0486a5c
test_search: ignore domain underlay and system for various tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5282
diff
changeset

198 result = self.search(ur'domain:underlay domain:system linkto:re:\bSearchTest') 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

199 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

200 assert found_pages == expected_pages 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

201 
5601
0c94d0486a5c
test_search: ignore domain underlay and system for various tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5282
diff
changeset

202 result = self.search(ur'domain:underlay domain:system linkto:re:\bSearchTest\b') 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

203 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

204 assert not found_pages 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

205 
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

206 def test_linkto_search_case(self): 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

207 expected_pages = set([u'SearchTestLinks', ]) 
5601
0c94d0486a5c
test_search: ignore domain underlay and system for various tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5282
diff
changeset

208 result = self.search(u'domain:underlay domain:system linkto:case:SearchTestPage') 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

209 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

210 assert found_pages == expected_pages 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

211 
5601
0c94d0486a5c
test_search: ignore domain underlay and system for various tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5282
diff
changeset

212 result = self.search(u'domain:underlay domain:system linkto:case:searchtestpage') 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

213 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

214 assert not found_pages 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

215 
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

216 def test_linkto_search_case_re(self): 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

217 expected_pages = set([u'SearchTestLinks', ]) 
5601
0c94d0486a5c
test_search: ignore domain underlay and system for various tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5282
diff
changeset

218 result = self.search(ur'domain:underlay domain:system linkto:case:re:\bSearchTestPage\b') 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

219 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

220 assert found_pages == expected_pages 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

221 
5601
0c94d0486a5c
test_search: ignore domain underlay and system for various tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5282
diff
changeset

222 result = self.search(ur'domain:underlay domain:system linkto:case:re:\bsearchtestpage\b') 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

223 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

224 assert not found_pages 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

225 
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

226 def test_category_search_simple(self): 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

227 expected_pages = set([u'HomePageWiki', ]) 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

228 result = self.search(u'category:CategoryHomepage') 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

229 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

230 assert found_pages == expected_pages 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

231 
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

232 result = self.search(u'category:CategorySearchTestNotExisting') 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

233 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

234 assert not found_pages 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

235 
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

236 def test_category_search_re(self): 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

237 expected_pages = set([u'HomePageWiki', ]) 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

238 result = self.search(ur'category:re:\bCategoryHomepage\b') 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

239 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

240 assert found_pages == expected_pages 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

241 
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

242 result = self.search(ur'category:re:\bCategoryHomepa\b') 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

243 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

244 assert not found_pages 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

245 
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

246 def test_category_search_case(self): 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

247 expected_pages = set([u'HomePageWiki', ]) 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

248 result = self.search(u'category:case:CategoryHomepage') 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

249 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

250 assert found_pages == expected_pages 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

251 
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

252 result = self.search(u'category:case:categoryhomepage') 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

253 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

254 assert not found_pages 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

255 
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

256 def test_category_search_case_re(self): 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

257 expected_pages = set([u'HomePageWiki', ]) 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

258 result = self.search(ur'category:case:re:\bCategoryHomepage\b') 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

259 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

260 assert found_pages == expected_pages 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

261 
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

262 result = self.search(ur'category:case:re:\bcategoryhomepage\b') 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

263 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

264 assert not found_pages 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

265 
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

266 def test_mimetype_search_simple(self): 
5006
8e0a95b9508a
Xapian2009: text/wiki mimetype is used in tests.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5004
diff
changeset

267 result = self.search(u'mimetype:text/wiki') 
5602
8d3799e97a01
test_search: for failing tests show the wrong value and not the expression
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5601
diff
changeset

268 test_result = len(result.hits) 
5642
226e1b0aa79c
search tests: simplify and extend test for regex search
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5641
diff
changeset

269 assert test_result == 14 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

270 
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

271 def test_mimetype_search_re(self): 
5006
8e0a95b9508a
Xapian2009: text/wiki mimetype is used in tests.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5004
diff
changeset

272 result = self.search(ur'mimetype:re:\btext/wiki\b') 
5602
8d3799e97a01
test_search: for failing tests show the wrong value and not the expression
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5601
diff
changeset

273 test_result = len(result.hits) 
5642
226e1b0aa79c
search tests: simplify and extend test for regex search
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5641
diff
changeset

274 assert test_result == 14 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

275 
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

276 result = self.search(ur'category:re:\bCategoryHomepa\b') 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

277 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

278 assert not found_pages 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

279 
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

280 def test_language_search_simple(self): 
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

281 result = self.search(u'language:en') 
5602
8d3799e97a01
test_search: for failing tests show the wrong value and not the expression
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5601
diff
changeset

282 test_result = len(result.hits) 
5642
226e1b0aa79c
search tests: simplify and extend test for regex search
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5641
diff
changeset

283 assert test_result == 14 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

284 
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

285 def test_domain_search_simple(self): 
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

286 result = self.search(u'domain:system') 
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

287 assert result.hits 
4978
0b5aaec043cd
Xapian2009: Tests for mimetype, language and domain. Test classes are new style classes.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4977
diff
changeset

288 
5015
bc42755b5820
Xapian2009: AndExpression.xapian_term() was refactored. Tests for "and" were updated.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5007
diff
changeset

289 def test_search_and(self): 
2955
c8a3731ce61c
search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2953
diff
changeset

290 """ search: title search with AND expression """ 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

291 expected_pages = set([u'HelpOnCreoleSyntax', ]) 
5015
bc42755b5820
Xapian2009: AndExpression.xapian_term() was refactored. Tests for "and" were updated.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5007
diff
changeset

292 result = self.search(u"title:HelpOnCreoleSyntax lang:en") 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

293 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

294 assert found_pages == expected_pages 
2955
c8a3731ce61c
search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2953
diff
changeset

295 
5015
bc42755b5820
Xapian2009: AndExpression.xapian_term() was refactored. Tests for "and" were updated.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5007
diff
changeset

296 result = self.search(u"title:HelpOnCreoleSyntax lang:de") 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

297 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

298 assert not found_pages 
5015
bc42755b5820
Xapian2009: AndExpression.xapian_term() was refactored. Tests for "and" were updated.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5007
diff
changeset

299 
4992
c6da526a8c30
Xapian2009: Moin serach doesn't search in all available pages during tests, but only in listed in the BaseSearchTest.pages. Tests check number of returned hits.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4991
diff
changeset

300 result = self.search(u"title:Help title:%s" % self.doesnotexist) 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

301 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

302 assert not found_pages 
4977
2171281b6d79
Xapian2009: Search tests update. regex: and case: prefixes tests were added for title, linkto and category.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4974
diff
changeset

303 
2955
c8a3731ce61c
search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2953
diff
changeset

304 def testTitleSearchOR(self): 
c8a3731ce61c
search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2953
diff
changeset

305 """ search: title search with OR expression """ 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

306 expected_pages = set([u'FrontPage', u'RecentChanges', ]) 
4992
c6da526a8c30
Xapian2009: Moin serach doesn't search in all available pages during tests, but only in listed in the BaseSearchTest.pages. Tests check number of returned hits.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4991
diff
changeset

307 result = self.search(u"title:FrontPage or title:RecentChanges") 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

308 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

309 assert found_pages == expected_pages 
2955
c8a3731ce61c
search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2953
diff
changeset

310 
c8a3731ce61c
search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2953
diff
changeset

311 def testTitleSearchNegatedFindAll(self): 
c8a3731ce61c
search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2953
diff
changeset

312 """ search: negated title search for some pagename that does not exist results in all pagenames """ 
4992
c6da526a8c30
Xapian2009: Moin serach doesn't search in all available pages during tests, but only in listed in the BaseSearchTest.pages. Tests check number of returned hits.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4991
diff
changeset

313 result = self.search(u"title:%s" % self.doesnotexist) 
5602
8d3799e97a01
test_search: for failing tests show the wrong value and not the expression
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5601
diff
changeset

314 n_pages = len(self.pages) 
8d3799e97a01
test_search: for failing tests show the wrong value and not the expression
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5601
diff
changeset

315 test_result = len(result.hits) 
8d3799e97a01
test_search: for failing tests show the wrong value and not the expression
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5601
diff
changeset

316 assert test_result == n_pages 
2953
41138237f2a5
search: add test for title search with negative term (currently failing)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2951
diff
changeset

317 
41138237f2a5
search: add test for title search with negative term (currently failing)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2951
diff
changeset

318 def testTitleSearchNegativeTerm(self): 
2955
c8a3731ce61c
search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2953
diff
changeset

319 """ search: title search for a AND expression with a negative term """ 
4992
c6da526a8c30
Xapian2009: Moin serach doesn't search in all available pages during tests, but only in listed in the BaseSearchTest.pages. Tests check number of returned hits.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4991
diff
changeset

320 result = self.search(u"title:FrontPage") 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

321 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

322 assert u'FrontPage' not in found_pages 
5602
8d3799e97a01
test_search: for failing tests show the wrong value and not the expression
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5601
diff
changeset

323 test_result = len(result.hits) 
8d3799e97a01
test_search: for failing tests show the wrong value and not the expression
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5601
diff
changeset

324 n_pages = len(self.pages)  1 
8d3799e97a01
test_search: for failing tests show the wrong value and not the expression
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5601
diff
changeset

325 assert test_result == n_pages 
2955
c8a3731ce61c
search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2953
diff
changeset

326 
5027
f531ccc68313
Xapian2009: xapian_term() was refactored for the TextSearch and TitleSearch. Title and content fields are tokenized (and stemmed) in the search index.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5015
diff
changeset

327 result = self.search(u"title:HelpOn") 
5602
8d3799e97a01
test_search: for failing tests show the wrong value and not the expression
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5601
diff
changeset

328 test_result = len(result.hits) 
5603
5e01b23e0a37
test_search: replaced testpage name HelpOnEditing by TestOnEditing, because we need a page with a similiar name but without attachments.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5602
diff
changeset

329 n_pages = len(self.pages)  1 
5602
8d3799e97a01
test_search: for failing tests show the wrong value and not the expression
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5601
diff
changeset

330 assert test_result == n_pages 
5027
f531ccc68313
Xapian2009: xapian_term() was refactored for the TextSearch and TitleSearch. Title and content fields are tokenized (and stemmed) in the search index.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5015
diff
changeset

331 
2955
c8a3731ce61c
search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2953
diff
changeset

332 def testFullSearchNegatedFindAll(self): 
c8a3731ce61c
search: add tests, add debug logging, fix bugs (negative search terms failing, and others)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2953
diff
changeset

333 """ search: negated full search for some string that does not exist results in all pages """ 
4992
c6da526a8c30
Xapian2009: Moin serach doesn't search in all available pages during tests, but only in listed in the BaseSearchTest.pages. Tests check number of returned hits.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4991
diff
changeset

334 result = self.search(u"%s" % self.doesnotexist) 
5602
8d3799e97a01
test_search: for failing tests show the wrong value and not the expression
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5601
diff
changeset

335 test_result = len(result.hits) 
8d3799e97a01
test_search: for failing tests show the wrong value and not the expression
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5601
diff
changeset

336 n_pages = len(self.pages) 
8d3799e97a01
test_search: for failing tests show the wrong value and not the expression
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5601
diff
changeset

337 assert test_result == n_pages 
2953
41138237f2a5
search: add test for title search with negative term (currently failing)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2951
diff
changeset

338 
5642
226e1b0aa79c
search tests: simplify and extend test for regex search
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5641
diff
changeset

339 def testFullSearchRegexCaseInsensitive(self): 
5644
3100da24a7fa
search tests: some cosmetic fixes, improve comments/docstrings
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5643
diff
changeset

340 """ search: full search for regular expression (case insensitive) """ 
5642
226e1b0aa79c
search tests: simplify and extend test for regex search
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5641
diff
changeset

341 search_re = 'ne{2}dle' # matches 'NEEDLE' or 'needle' or ... 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

342 expected_pages = set(['ContentSearchUpper', 'ContentSearchLower', ]) 
5642
226e1b0aa79c
search tests: simplify and extend test for regex search
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5641
diff
changeset

343 result = self.search(u'domain:underlay domain:system re:%s' % search_re) 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

344 found_pages = set([hit.page_name for hit in result.hits]) 
5642
226e1b0aa79c
search tests: simplify and extend test for regex search
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5641
diff
changeset

345 assert found_pages == expected_pages 
226e1b0aa79c
search tests: simplify and extend test for regex search
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5641
diff
changeset

346 
226e1b0aa79c
search tests: simplify and extend test for regex search
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5641
diff
changeset

347 def testFullSearchRegexCaseSensitive(self): 
5644
3100da24a7fa
search tests: some cosmetic fixes, improve comments/docstrings
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5643
diff
changeset

348 """ search: full search for regular expression (case sensitive) """ 
5642
226e1b0aa79c
search tests: simplify and extend test for regex search
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5641
diff
changeset

349 search_re = 'ne{2}dle' # matches 'needle' 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

350 expected_pages = set(['ContentSearchLower', ]) 
5642
226e1b0aa79c
search tests: simplify and extend test for regex search
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5641
diff
changeset

351 result = self.search(u'domain:underlay domain:system re:case:%s' % search_re) 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

352 found_pages = set([hit.page_name for hit in result.hits]) 
5642
226e1b0aa79c
search tests: simplify and extend test for regex search
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5641
diff
changeset

353 assert found_pages == expected_pages 
226e1b0aa79c
search tests: simplify and extend test for regex search
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5641
diff
changeset

354 
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

355 def test_title_search(self): 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

356 expected_pages = set(['FrontPage', ]) 
4993
1d7a28cfc0f6
Xapian2009: Tests for xapian_term() which should not return empty query.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4992
diff
changeset

357 query = QueryParser(titlesearch=True).parse_query('FrontPage') 
4992
c6da526a8c30
Xapian2009: Moin serach doesn't search in all available pages during tests, but only in listed in the BaseSearchTest.pages. Tests check number of returned hits.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4991
diff
changeset

358 result = self.search(query) 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

359 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

360 assert found_pages == expected_pages 
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

361 
5001
2b00cc68f8c2
Xapian2009: BaseSearchTest.test_create_page() tests that pages created by create_page are indexed and available for searching.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5000
diff
changeset

362 def test_create_page(self): 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

363 expected_pages = set([u'TestCreatePage', ]) 
5276
195db0fdbb80
Fixed and cleaned up Xapian based search (details below)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5225
diff
changeset

364 self.pages['TestCreatePage'] = 'some text' # Moin search must search this page 
5225
92eac8134765
Serch tests use try ... finally what makes code more readable.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5224
diff
changeset

365 try: 
92eac8134765
Serch tests use try ... finally what makes code more readable.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5224
diff
changeset

366 create_page(self.request, 'TestCreatePage', self.pages['TestCreatePage']) 
5281
5f0ec1f315bc
xapian: new locking, removed threading and signing (details see below)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5276
diff
changeset

367 self._index_update() 
5601
0c94d0486a5c
test_search: ignore domain underlay and system for various tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5282
diff
changeset

368 result = self.search(u'domain:underlay domain:system TestCreatePage') 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

369 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

370 assert found_pages == expected_pages 
5225
92eac8134765
Serch tests use try ... finally what makes code more readable.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5224
diff
changeset

371 finally: 
92eac8134765
Serch tests use try ... finally what makes code more readable.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5224
diff
changeset

372 nuke_page(self.request, 'TestCreatePage') 
5281
5f0ec1f315bc
xapian: new locking, removed threading and signing (details see below)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5276
diff
changeset

373 self._index_update() 
5225
92eac8134765
Serch tests use try ... finally what makes code more readable.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5224
diff
changeset

374 del self.pages['TestCreatePage'] 
5601
0c94d0486a5c
test_search: ignore domain underlay and system for various tests
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5282
diff
changeset

375 result = self.search(u'domain:underlay domain:system TestCreatePage') 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

376 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

377 assert not found_pages 
5001
2b00cc68f8c2
Xapian2009: BaseSearchTest.test_create_page() tests that pages created by create_page are indexed and available for searching.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5000
diff
changeset

378 
5167
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

379 def test_attachment(self): 
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

380 page_name = u'TestAttachment' 
5276
195db0fdbb80
Fixed and cleaned up Xapian based search (details below)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5225
diff
changeset

381 self.pages[page_name] = 'some text' # Moin search must search this page 
5167
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

382 
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

383 filename = "AutoCreatedSillyAttachmentForSearching.png" 
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

384 data = "Test content" 
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

385 filecontent = StringIO.StringIO(data) 
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

386 
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

387 result = self.search(filename) 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

388 found_attachments = set([(hit.page_name, hit.attachment) for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

389 assert not found_attachments 
5167
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

390 
5225
92eac8134765
Serch tests use try ... finally what makes code more readable.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5224
diff
changeset

391 try: 
92eac8134765
Serch tests use try ... finally what makes code more readable.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5224
diff
changeset

392 create_page(self.request, page_name, self.pages[page_name]) 
92eac8134765
Serch tests use try ... finally what makes code more readable.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5224
diff
changeset

393 AttachFile.add_attachment(self.request, page_name, filename, filecontent, True) 
92eac8134765
Serch tests use try ... finally what makes code more readable.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5224
diff
changeset

394 append_page(self.request, page_name, '[[attachment:%s]]' % filename) 
5281
5f0ec1f315bc
xapian: new locking, removed threading and signing (details see below)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5276
diff
changeset

395 self._index_update() 
5225
92eac8134765
Serch tests use try ... finally what makes code more readable.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5224
diff
changeset

396 result = self.search(filename) 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

397 found_attachments = set([(hit.page_name, hit.attachment) for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

398 assert (page_name, '') in found_attachments 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

399 assert 1 <= len(found_attachments) <= 2 
5644
3100da24a7fa
search tests: some cosmetic fixes, improve comments/docstrings
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5643
diff
changeset

400 # Note: moin search returns (page_name, '') as only result 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

401 # xapian search returns 2 results: (page_name, '') and (page_name, filename) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

402 # TODO: make behaviour the same, if possible 
5225
92eac8134765
Serch tests use try ... finally what makes code more readable.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5224
diff
changeset

403 finally: 
92eac8134765
Serch tests use try ... finally what makes code more readable.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5224
diff
changeset

404 nuke_page(self.request, page_name) 
92eac8134765
Serch tests use try ... finally what makes code more readable.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5224
diff
changeset

405 del self.pages[page_name] 
5281
5f0ec1f315bc
xapian: new locking, removed threading and signing (details see below)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5276
diff
changeset

406 self._index_update() 
5f0ec1f315bc
xapian: new locking, removed threading and signing (details see below)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5276
diff
changeset

407 result = self.search(filename) 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

408 found_attachments = set([(hit.page_name, hit.attachment) for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

409 assert not found_attachments 
5167
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

410 
5045
d77ac3c87ac8
Xapian2009: refactoring of searchPages. Tests for it.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5044
diff
changeset

411 def test_get_searcher(self): 
d77ac3c87ac8
Xapian2009: refactoring of searchPages. Tests for it.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5044
diff
changeset

412 assert isinstance(_get_searcher(self.request, ''), self.searcher_class) 
d77ac3c87ac8
Xapian2009: refactoring of searchPages. Tests for it.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5044
diff
changeset

413 
5036
4b2ef153ad4f
Xapian2009: pep8 and typo fixes.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5035
diff
changeset

414 
4992
c6da526a8c30
Xapian2009: Moin serach doesn't search in all available pages during tests, but only in listed in the BaseSearchTest.pages. Tests check number of returned hits.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4991
diff
changeset

415 class TestMoinSearch(BaseSearchTest): 
5644
3100da24a7fa
search tests: some cosmetic fixes, improve comments/docstrings
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5643
diff
changeset

416 """ search: test Moin search """ 
5045
d77ac3c87ac8
Xapian2009: refactoring of searchPages. Tests for it.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5044
diff
changeset

417 searcher_class = MoinSearch 
d77ac3c87ac8
Xapian2009: refactoring of searchPages. Tests for it.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5044
diff
changeset

418 
4992
c6da526a8c30
Xapian2009: Moin serach doesn't search in all available pages during tests, but only in listed in the BaseSearchTest.pages. Tests check number of returned hits.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4991
diff
changeset

419 def get_searcher(self, query): 
c6da526a8c30
Xapian2009: Moin serach doesn't search in all available pages during tests, but only in listed in the BaseSearchTest.pages. Tests check number of returned hits.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4991
diff
changeset

420 pages = [{'pagename': page, 'attachment': '', 'wikiname': 'Self', } for page in self.pages] 
c6da526a8c30
Xapian2009: Moin serach doesn't search in all available pages during tests, but only in listed in the BaseSearchTest.pages. Tests check number of returned hits.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4991
diff
changeset

421 return MoinSearch(self.request, query, pages=pages) 
c6da526a8c30
Xapian2009: Moin serach doesn't search in all available pages during tests, but only in listed in the BaseSearchTest.pages. Tests check number of returned hits.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4991
diff
changeset

422 
5035
93becb451375
Xapian2009: BaseTextFieldSearch.xapian_term() refactoring. Tests for a search with stemming.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5031
diff
changeset

423 def test_stemming(self): 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

424 expected_pages = set([u'TestEdit', u'TestOnEditing', ]) 
5035
93becb451375
Xapian2009: BaseTextFieldSearch.xapian_term() refactoring. Tests for a search with stemming.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5031
diff
changeset

425 result = self.search(u"title:edit") 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

426 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

427 assert found_pages == expected_pages 
5035
93becb451375
Xapian2009: BaseTextFieldSearch.xapian_term() refactoring. Tests for a search with stemming.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5031
diff
changeset

428 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

429 expected_pages = set([u'TestOnEditing', ]) 
5035
93becb451375
Xapian2009: BaseTextFieldSearch.xapian_term() refactoring. Tests for a search with stemming.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5031
diff
changeset

430 result = self.search(u"title:editing") 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

431 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

432 assert found_pages == expected_pages 
5035
93becb451375
Xapian2009: BaseTextFieldSearch.xapian_term() refactoring. Tests for a search with stemming.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5031
diff
changeset

433 
4997
8b51025823e0
Xapian2009: pep8 and typo fixes.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4996
diff
changeset

434 
4992
c6da526a8c30
Xapian2009: Moin serach doesn't search in all available pages during tests, but only in listed in the BaseSearchTest.pages. Tests check number of returned hits.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4991
diff
changeset

435 class TestXapianSearch(BaseSearchTest): 
5644
3100da24a7fa
search tests: some cosmetic fixes, improve comments/docstrings
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5643
diff
changeset

436 """ search: test Xapian indexing / search """ 
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

437 
5001
2b00cc68f8c2
Xapian2009: BaseSearchTest.test_create_page() tests that pages created by create_page are indexed and available for searching.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5000
diff
changeset

438 class Config(wikiconfig.Config): 
2b00cc68f8c2
Xapian2009: BaseSearchTest.test_create_page() tests that pages created by create_page are indexed and available for searching.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5000
diff
changeset

439 xapian_search = True 
2b00cc68f8c2
Xapian2009: BaseSearchTest.test_create_page() tests that pages created by create_page are indexed and available for searching.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5000
diff
changeset

440 
5281
5f0ec1f315bc
xapian: new locking, removed threading and signing (details see below)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5276
diff
changeset

441 def _index_update(self): 
5f0ec1f315bc
xapian: new locking, removed threading and signing (details see below)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5276
diff
changeset

442 # for xapian, we queue index updates so they can get indexed later. 
5f0ec1f315bc
xapian: new locking, removed threading and signing (details see below)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5276
diff
changeset

443 # here we make sure the queue will be processed completely, 
5f0ec1f315bc
xapian: new locking, removed threading and signing (details see below)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5276
diff
changeset

444 # before we continue: 
5167
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

445 from MoinMoin.search.Xapian import XapianIndex 
5281
5f0ec1f315bc
xapian: new locking, removed threading and signing (details see below)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5276
diff
changeset

446 XapianIndex(self.request).do_queued_updates() 
5167
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

447 
4992
c6da526a8c30
Xapian2009: Moin serach doesn't search in all available pages during tests, but only in listed in the BaseSearchTest.pages. Tests check number of returned hits.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4991
diff
changeset

448 def get_searcher(self, query): 
5044
f5f3d7348564
Xapian2009: Class Xapian.indexing.Index is renamed to XapianIndex. _check_version() was removed, xapian binding check is done by xappy. XapianSearch was moved to Xapian.search. Log message is shown if xapian version is too old.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5036
diff
changeset

449 from MoinMoin.search.Xapian.search import XapianSearch 
4992
c6da526a8c30
Xapian2009: Moin serach doesn't search in all available pages during tests, but only in listed in the BaseSearchTest.pages. Tests check number of returned hits.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4991
diff
changeset

450 return XapianSearch(self.request, query) 
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

451 
4994
605b2da7765e
Xapian2009: Test for xapian search was added which checks that index consists all required pages.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4993
diff
changeset

452 def get_moin_search_connection(self): 
5282
bee5567d7084
xapian: remove assumption that xapian db is a directory
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5281
diff
changeset

453 from MoinMoin.search.Xapian import XapianIndex 
bee5567d7084
xapian: remove assumption that xapian db is a directory
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5281
diff
changeset

454 return XapianIndex(self.request).get_search_connection() 
4994
605b2da7765e
Xapian2009: Test for xapian search was added which checks that index consists all required pages.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4993
diff
changeset

455 
5167
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

456 def setup_class(self): 
4991
d39bdb239da4
Xapian2009: py.test.importorskip in tests was removed, tests try import Xapian, and on ImportError skip a test. Index.indexPages now takes a pages parameter  list of pages which must be indexed.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4990
diff
changeset

457 try: 
5044
f5f3d7348564
Xapian2009: Class Xapian.indexing.Index is renamed to XapianIndex. _check_version() was removed, xapian binding check is done by xappy. XapianSearch was moved to Xapian.search. Log message is shown if xapian version is too old.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5036
diff
changeset

458 from MoinMoin.search.Xapian import XapianIndex 
5045
d77ac3c87ac8
Xapian2009: refactoring of searchPages. Tests for it.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5044
diff
changeset

459 from MoinMoin.search.Xapian.search import XapianSearch 
d77ac3c87ac8
Xapian2009: refactoring of searchPages. Tests for it.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5044
diff
changeset

460 self.searcher_class = XapianSearch 
d77ac3c87ac8
Xapian2009: refactoring of searchPages. Tests for it.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5044
diff
changeset

461 
5044
f5f3d7348564
Xapian2009: Class Xapian.indexing.Index is renamed to XapianIndex. _check_version() was removed, xapian binding check is done by xappy. XapianSearch was moved to Xapian.search. Log message is shown if xapian version is too old.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5036
diff
changeset

462 except ImportError, error: 
f5f3d7348564
Xapian2009: Class Xapian.indexing.Index is renamed to XapianIndex. _check_version() was removed, xapian binding check is done by xappy. XapianSearch was moved to Xapian.search. Log message is shown if xapian version is too old.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5036
diff
changeset

463 if not str(error).startswith('Xapian '): 
f5f3d7348564
Xapian2009: Class Xapian.indexing.Index is renamed to XapianIndex. _check_version() was removed, xapian binding check is done by xappy. XapianSearch was moved to Xapian.search. Log message is shown if xapian version is too old.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5036
diff
changeset

464 raise 
4991
d39bdb239da4
Xapian2009: py.test.importorskip in tests was removed, tests try import Xapian, and on ImportError skip a test. Index.indexPages now takes a pages parameter  list of pages which must be indexed.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4990
diff
changeset

465 py.test.skip('xapian is not installed') 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

466 
4876
75c067fb7d1b
xapian indexing tests: fix api usage, fix comments, add comment about slowness
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
4762
diff
changeset

467 nuke_xapian_index(self.request) 
5044
f5f3d7348564
Xapian2009: Class Xapian.indexing.Index is renamed to XapianIndex. _check_version() was removed, xapian binding check is done by xappy. XapianSearch was moved to Xapian.search. Log message is shown if xapian version is too old.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5036
diff
changeset

468 index = XapianIndex(self.request) 
5167
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

469 # Additionally, pages which were not created but supposed to be searched 
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

470 # are indexed. 
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

471 pages_to_index = [page for page in self.pages if not self.pages[page]] 
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

472 index.indexPages(mode='add', pages=pages_to_index) 
4990
6f87dbd8f895
Xapian2009: test_search was refactored. Xappy test does not index all pages. Generative test was killed. TestXapianIndexingInNewThread is skipped.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4989
diff
changeset

473 
5167
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

474 super(TestXapianSearch, self).setup_class() 
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

475 
b86c7b348862
Test for searching an attachment was added. time.sleep() is not used anymore to wait for the index update.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5057
diff
changeset

476 def teardown_class(self): 
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

477 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

478 
4994
605b2da7765e
Xapian2009: Test for xapian search was added which checks that index consists all required pages.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4993
diff
changeset

479 def test_get_all_documents(self): 
605b2da7765e
Xapian2009: Test for xapian search was added which checks that index consists all required pages.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4993
diff
changeset

480 connection = self.get_moin_search_connection() 
605b2da7765e
Xapian2009: Test for xapian search was added which checks that index consists all required pages.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4993
diff
changeset

481 documents = connection.get_all_documents() 
5602
8d3799e97a01
test_search: for failing tests show the wrong value and not the expression
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5601
diff
changeset

482 n_pages = len(self.pages) 
8d3799e97a01
test_search: for failing tests show the wrong value and not the expression
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5601
diff
changeset

483 test_result = len(documents) 
8d3799e97a01
test_search: for failing tests show the wrong value and not the expression
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
5601
diff
changeset

484 assert test_result == n_pages 
4994
605b2da7765e
Xapian2009: Test for xapian search was added which checks that index consists all required pages.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4993
diff
changeset

485 for document in documents: 
605b2da7765e
Xapian2009: Test for xapian search was added which checks that index consists all required pages.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4993
diff
changeset

486 assert document.data['pagename'][0] in self.pages.keys() 
4993
1d7a28cfc0f6
Xapian2009: Tests for xapian_term() which should not return empty query.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4992
diff
changeset

487 
4994
605b2da7765e
Xapian2009: Test for xapian search was added which checks that index consists all required pages.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4993
diff
changeset

488 def test_xapian_term(self): 
4993
1d7a28cfc0f6
Xapian2009: Tests for xapian_term() which should not return empty query.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4992
diff
changeset

489 parser = QueryParser() 
4994
605b2da7765e
Xapian2009: Test for xapian search was added which checks that index consists all required pages.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4993
diff
changeset

490 connection = self.get_moin_search_connection() 
605b2da7765e
Xapian2009: Test for xapian search was added which checks that index consists all required pages.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4993
diff
changeset

491 
5000
52f2454de7ab
Xapian2009: unicode objects are used instead of strings in search tests.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4999
diff
changeset

492 prefixes = {u'': ([u'', u're:', u'case:', u'case:re:'], u'SearchTestPage'), 
52f2454de7ab
Xapian2009: unicode objects are used instead of strings in search tests.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4999
diff
changeset

493 u'title:': ([u'', u're:', u'case:', u'case:re:'], u'SearchTestPage'), 
52f2454de7ab
Xapian2009: unicode objects are used instead of strings in search tests.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4999
diff
changeset

494 u'linkto:': ([u'', u're:', u'case:', u'case:re:'], u'FrontPage'), 
52f2454de7ab
Xapian2009: unicode objects are used instead of strings in search tests.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4999
diff
changeset

495 u'category:': ([u'', u're:', u'case:', u'case:re:'], u'CategoryHomepage'), 
5006
8e0a95b9508a
Xapian2009: text/wiki mimetype is used in tests.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5004
diff
changeset

496 u'mimetype:': ([u'', u're:'], u'text/wiki'), 
5000
52f2454de7ab
Xapian2009: unicode objects are used instead of strings in search tests.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4999
diff
changeset

497 u'language:': ([u''], u'en'), 
5644
3100da24a7fa
search tests: some cosmetic fixes, improve comments/docstrings
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5643
diff
changeset

498 u'domain:': ([u''], u'system'), 
3100da24a7fa
search tests: some cosmetic fixes, improve comments/docstrings
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5643
diff
changeset

499 } 
4993
1d7a28cfc0f6
Xapian2009: Tests for xapian_term() which should not return empty query.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4992
diff
changeset

500 
1d7a28cfc0f6
Xapian2009: Tests for xapian_term() which should not return empty query.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4992
diff
changeset

501 def test_query(query): 
5035
93becb451375
Xapian2009: BaseTextFieldSearch.xapian_term() refactoring. Tests for a search with stemming.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5031
diff
changeset

502 query_ = parser.parse_query(query).xapian_term(self.request, connection) 
93becb451375
Xapian2009: BaseTextFieldSearch.xapian_term() refactoring. Tests for a search with stemming.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5031
diff
changeset

503 print str(query_) 
93becb451375
Xapian2009: BaseTextFieldSearch.xapian_term() refactoring. Tests for a search with stemming.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5031
diff
changeset

504 assert not query_.empty() 
4993
1d7a28cfc0f6
Xapian2009: Tests for xapian_term() which should not return empty query.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4992
diff
changeset

505 
4996
0e4eff722cac
Xapian2009: Test for xapian_term builds queries which should not be empty, it also checks queries like 'case:moin' (without specified prefix like language:)
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4995
diff
changeset

506 for prefix, data in prefixes.iteritems(): 
0e4eff722cac
Xapian2009: Test for xapian_term builds queries which should not be empty, it also checks queries like 'case:moin' (without specified prefix like language:)
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4995
diff
changeset

507 modifiers, term = data 
4993
1d7a28cfc0f6
Xapian2009: Tests for xapian_term() which should not return empty query.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4992
diff
changeset

508 for modifier in modifiers: 
4996
0e4eff722cac
Xapian2009: Test for xapian_term builds queries which should not be empty, it also checks queries like 'case:moin' (without specified prefix like language:)
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4995
diff
changeset

509 query = ''.join([prefix, modifier, term]) 
0e4eff722cac
Xapian2009: Test for xapian_term builds queries which should not be empty, it also checks queries like 'case:moin' (without specified prefix like language:)
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4995
diff
changeset

510 yield query, test_query, query 
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

511 
5035
93becb451375
Xapian2009: BaseTextFieldSearch.xapian_term() refactoring. Tests for a search with stemming.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5031
diff
changeset

512 def test_stemming(self): 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

513 expected_pages = set([u'TestEdit', ]) 
5035
93becb451375
Xapian2009: BaseTextFieldSearch.xapian_term() refactoring. Tests for a search with stemming.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5031
diff
changeset

514 result = self.search(u"title:edit") 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

515 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

516 assert found_pages == expected_pages 
5035
93becb451375
Xapian2009: BaseTextFieldSearch.xapian_term() refactoring. Tests for a search with stemming.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5031
diff
changeset

517 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

518 expected_pages = set([u'TestOnEditing', ]) 
5035
93becb451375
Xapian2009: BaseTextFieldSearch.xapian_term() refactoring. Tests for a search with stemming.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5031
diff
changeset

519 result = self.search(u"title:editing") 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

520 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

521 assert found_pages == expected_pages 
5035
93becb451375
Xapian2009: BaseTextFieldSearch.xapian_term() refactoring. Tests for a search with stemming.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5031
diff
changeset

522 
93becb451375
Xapian2009: BaseTextFieldSearch.xapian_term() refactoring. Tests for a search with stemming.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5031
diff
changeset

523 
93becb451375
Xapian2009: BaseTextFieldSearch.xapian_term() refactoring. Tests for a search with stemming.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5031
diff
changeset

524 class TestXapianSearchStemmed(TestXapianSearch): 
5644
3100da24a7fa
search tests: some cosmetic fixes, improve comments/docstrings
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5643
diff
changeset

525 """ search: test Xapian indexing / search  with stemming enabled """ 
3100da24a7fa
search tests: some cosmetic fixes, improve comments/docstrings
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5643
diff
changeset

526 
5035
93becb451375
Xapian2009: BaseTextFieldSearch.xapian_term() refactoring. Tests for a search with stemming.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5031
diff
changeset

527 class Config(wikiconfig.Config): 
93becb451375
Xapian2009: BaseTextFieldSearch.xapian_term() refactoring. Tests for a search with stemming.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5031
diff
changeset

528 xapian_search = True 
93becb451375
Xapian2009: BaseTextFieldSearch.xapian_term() refactoring. Tests for a search with stemming.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5031
diff
changeset

529 xapian_stemming = True 
93becb451375
Xapian2009: BaseTextFieldSearch.xapian_term() refactoring. Tests for a search with stemming.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5031
diff
changeset

530 
93becb451375
Xapian2009: BaseTextFieldSearch.xapian_term() refactoring. Tests for a search with stemming.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5031
diff
changeset

531 def test_stemming(self): 
5224
45d36f027793
Only a Xapian stemming test is skipped other search related tests are executed.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5220
diff
changeset

532 py.test.skip("TODO fix TestXapianSearchStemmed  strange effects with stemming") 
45d36f027793
Only a Xapian stemming test is skipped other search related tests are executed.
Dmitrii Miliaev <dimazest@gmail.com>
parents:
5220
diff
changeset

533 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

534 expected_pages = set([u'TestEdit', u'TestOnEditing', ]) 
5035
93becb451375
Xapian2009: BaseTextFieldSearch.xapian_term() refactoring. Tests for a search with stemming.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5031
diff
changeset

535 result = self.search(u"title:edit") 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

536 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

537 assert found_pages == expected_pages 
5035
93becb451375
Xapian2009: BaseTextFieldSearch.xapian_term() refactoring. Tests for a search with stemming.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5031
diff
changeset

538 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

539 expected_pages = set([u'TestEdit', u'TestOnEditing', ]) 
5035
93becb451375
Xapian2009: BaseTextFieldSearch.xapian_term() refactoring. Tests for a search with stemming.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5031
diff
changeset

540 result = self.search(u"title:editing") 
5643
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

541 found_pages = set([hit.page_name for hit in result.hits]) 
6282bd44c14c
search tests: get rid of most crappy len() based tests
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5642
diff
changeset

542 assert found_pages == expected_pages 
4997
8b51025823e0
Xapian2009: pep8 and typo fixes.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
4996
diff
changeset

543 
5036
4b2ef153ad4f
Xapian2009: pep8 and typo fixes.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5035
diff
changeset

544 
5045
d77ac3c87ac8
Xapian2009: refactoring of searchPages. Tests for it.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5044
diff
changeset

545 class TestGetSearcher(object): 
d77ac3c87ac8
Xapian2009: refactoring of searchPages. Tests for it.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5044
diff
changeset

546 
d77ac3c87ac8
Xapian2009: refactoring of searchPages. Tests for it.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5044
diff
changeset

547 class Config(wikiconfig.Config): 
d77ac3c87ac8
Xapian2009: refactoring of searchPages. Tests for it.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5044
diff
changeset

548 xapian_search = True 
d77ac3c87ac8
Xapian2009: refactoring of searchPages. Tests for it.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5044
diff
changeset

549 
d77ac3c87ac8
Xapian2009: refactoring of searchPages. Tests for it.
Dmitrijs Milajevs <dimazest@gmail.com>
parents:
5044
diff
changeset

550 def test_get_searcher(self): 
5281
5f0ec1f315bc
xapian: new locking, removed threading and signing (details see below)
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
5276
diff
changeset

551 assert isinstance(_get_searcher(self.request, ''), MoinSearch), 'Xapian index is not created, despite the configuration, MoinSearch must be used!' 
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

552 
2448
c9949c55ff5e
add coverage_modules attribute for coverage testing
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2286
diff
changeset

553 coverage_modules = ['MoinMoin.search'] 
c9949c55ff5e
add coverage_modules attribute for coverage testing
Thomas Waldmann <tw AT waldmannedv DOT de>
parents:
2286
diff
changeset

554 