Back to index

moin  1.9.0~rc2
Public Member Functions | Static Public Attributes
test_search.TestMoinSearch Class Reference
Inheritance diagram for test_search.TestMoinSearch:
Inheritance graph
[legend]
Collaboration diagram for test_search.TestMoinSearch:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def get_searcher
def test_stemming
def setup_class
def teardown_class
def search
def test_title_search_simple
def test_title_search_re
def test_title_search_case
def test_title_search_case_re
def test_linkto_search_simple
def test_linkto_search_re
def test_linkto_search_case
def test_linkto_search_case_re
def test_category_search_simple
def test_category_search_re
def test_category_search_case
def test_category_search_case_re
def test_mimetype_search_simple
def test_mimetype_search_re
def test_language_search_simple
def test_domain_search_simple
def test_search_and
def testTitleSearchOR
def testTitleSearchNegatedFindAll
def testTitleSearchNegativeTerm
def testFullSearchNegatedFindAll
def test_title_search
def test_create_page
def test_attachment
def test_get_searcher

Static Public Attributes

 searcher_class = MoinSearch
string doesnotexist = u'jfhsdaASDLASKDJ'
dictionary pages

Detailed Description

Definition at line 327 of file test_search.py.


Member Function Documentation

def test_search.TestMoinSearch.get_searcher (   self,
  query 
)

Reimplemented from test_search.BaseSearchTest.

Definition at line 331 of file test_search.py.

00331 
00332     def get_searcher(self, query):
00333         pages = [{'pagename': page, 'attachment': '', 'wikiname': 'Self', } for page in self.pages]
00334         return MoinSearch(self.request, query, pages=pages)

Here is the call graph for this function:

def test_search.BaseSearchTest.search (   self,
  query 
) [inherited]

Definition at line 126 of file test_search.py.

00126 
00127     def search(self, query):
00128         if isinstance(query, str) or isinstance(query, unicode):
00129             query = QueryParser().parse_query(query)
00130 
00131         return self.get_searcher(query).run()

Here is the call graph for this function:

Here is the caller graph for this function:

def test_search.BaseSearchTest.setup_class (   cls) [inherited]

Reimplemented in test_search.TestXapianSearch.

Definition at line 110 of file test_search.py.

00110 
00111     def setup_class(cls):
00112         request = cls.request
00113         become_trusted(request)
00114 
00115         for page, text in cls.pages.iteritems():
00116             if text:
00117                 create_page(request, page, text)

Here is the call graph for this function:

def test_search.BaseSearchTest.teardown_class (   self) [inherited]

Reimplemented in test_search.TestXapianSearch.

Definition at line 118 of file test_search.py.

00118 
00119     def teardown_class(self):
00120         for page, text in self.pages.iteritems():
00121             if text:
00122                 nuke_page(self.request, page)

Here is the call graph for this function:

def test_search.BaseSearchTest.test_attachment (   self) [inherited]

Definition at line 298 of file test_search.py.

00298 
00299     def test_attachment(self):
00300         page_name = u'TestAttachment'
00301         self.pages[page_name] = 'some text' # Moin search must search this page
00302 
00303         filename = "AutoCreatedSillyAttachmentForSearching.png"
00304         data = "Test content"
00305         filecontent = StringIO.StringIO(data)
00306 
00307         result = self.search(filename)
00308         assert len(result.hits) == 0
00309 
00310         try:
00311             create_page(self.request, page_name, self.pages[page_name])
00312             AttachFile.add_attachment(self.request, page_name, filename, filecontent, True)
00313             append_page(self.request, page_name, '[[attachment:%s]]' % filename)
00314             self._index_update()
00315             result = self.search(filename)
00316             assert len(result.hits) > 0
00317         finally:
00318             nuke_page(self.request, page_name)
00319             del self.pages[page_name]
00320             self._index_update()
00321             result = self.search(filename)
00322             assert len(result.hits) == 0

Here is the call graph for this function:

Definition at line 212 of file test_search.py.

00212 
00213     def test_category_search_case(self):
00214         result = self.search(u'category:case:CategoryHomepage')
00215         assert len(result.hits) == 1
00216 
00217         result = self.search(u'category:case:categoryhomepage')
00218         assert not result.hits

Here is the call graph for this function:

Definition at line 219 of file test_search.py.

00219 
00220     def test_category_search_case_re(self):
00221         result = self.search(ur'category:case:re:\bCategoryHomepage\b')
00222         assert len(result.hits) == 1
00223 
00224         result = self.search(ur'category:case:re:\bcategoryhomepage\b')
00225         assert not result.hits

Here is the call graph for this function:

Definition at line 205 of file test_search.py.

00205 
00206     def test_category_search_re(self):
00207         result = self.search(ur'category:re:\bCategoryHomepage\b')
00208         assert len(result.hits) == 1
00209 
00210         result = self.search(ur'category:re:\bCategoryHomepa\b')
00211         assert not result.hits

Here is the call graph for this function:

Definition at line 198 of file test_search.py.

00198 
00199     def test_category_search_simple(self):
00200         result = self.search(u'category:CategoryHomepage')
00201         assert len(result.hits) == 1
00202 
00203         result = self.search(u'category:CategorySearchTestNotExisting')
00204         assert not result.hits

Here is the call graph for this function:

def test_search.BaseSearchTest.test_create_page (   self) [inherited]

Definition at line 284 of file test_search.py.

00284 
00285     def test_create_page(self):
00286         self.pages['TestCreatePage'] = 'some text' # Moin search must search this page
00287         try:
00288             create_page(self.request, 'TestCreatePage', self.pages['TestCreatePage'])
00289             self._index_update()
00290             result = self.search(u'TestCreatePage')
00291             assert len(result.hits) == 1
00292         finally:
00293             nuke_page(self.request, 'TestCreatePage')
00294             self._index_update()
00295             del self.pages['TestCreatePage']
00296             result = self.search(u'TestCreatePage')
00297             assert len(result.hits) == 0

Here is the call graph for this function:

Definition at line 241 of file test_search.py.

00241 
00242     def test_domain_search_simple(self):
00243         result = self.search(u'domain:system')
00244         assert result.hits

Here is the call graph for this function:

Definition at line 323 of file test_search.py.

00323 
00324     def test_get_searcher(self):
00325         assert isinstance(_get_searcher(self.request, ''), self.searcher_class)
00326 

Here is the call graph for this function:

Definition at line 237 of file test_search.py.

00237 
00238     def test_language_search_simple(self):
00239         result = self.search(u'language:en')
00240         assert len(result.hits) == 12

Here is the call graph for this function:

Definition at line 184 of file test_search.py.

00184 
00185     def test_linkto_search_case(self):
00186         result = self.search(u'linkto:case:SearchTestPage')
00187         assert len(result.hits) == 1
00188 
00189         result = self.search(u'linkto:case:searchtestpage')
00190         assert not result.hits

Here is the call graph for this function:

Definition at line 191 of file test_search.py.

00191 
00192     def test_linkto_search_case_re(self):
00193         result = self.search(ur'linkto:case:re:\bSearchTestPage\b')
00194         assert len(result.hits) == 1
00195 
00196         result = self.search(ur'linkto:case:re:\bsearchtestpage\b')
00197         assert not result.hits

Here is the call graph for this function:

Definition at line 177 of file test_search.py.

00177 
00178     def test_linkto_search_re(self):
00179         result = self.search(ur'linkto:re:\bSearchTest')
00180         assert len(result.hits) == 2
00181 
00182         result = self.search(ur'linkto:re:\bSearchTest\b')
00183         assert not result.hits

Here is the call graph for this function:

Definition at line 170 of file test_search.py.

00170 
00171     def test_linkto_search_simple(self):
00172         result = self.search(u'linkto:SearchTestPage')
00173         assert len(result.hits) == 1
00174 
00175         result = self.search(u'linkto:SearchTestNotExisting')
00176         assert not result.hits

Here is the call graph for this function:

Definition at line 230 of file test_search.py.

00230 
00231     def test_mimetype_search_re(self):
00232         result = self.search(ur'mimetype:re:\btext/wiki\b')
00233         assert len(result.hits) == 12
00234 
00235         result = self.search(ur'category:re:\bCategoryHomepa\b')
00236         assert not result.hits

Here is the call graph for this function:

Definition at line 226 of file test_search.py.

00226 
00227     def test_mimetype_search_simple(self):
00228         result = self.search(u'mimetype:text/wiki')
00229         assert len(result.hits) == 12

Here is the call graph for this function:

def test_search.BaseSearchTest.test_search_and (   self) [inherited]
search: title search with AND expression 

Definition at line 245 of file test_search.py.

00245 
00246     def test_search_and(self):
00247         """ search: title search with AND expression """
00248         result = self.search(u"title:HelpOnCreoleSyntax lang:en")
00249         assert len(result.hits) == 1
00250 
00251         result = self.search(u"title:HelpOnCreoleSyntax lang:de")
00252         assert len(result.hits) == 0
00253 
00254         result = self.search(u"title:Help title:%s" % self.doesnotexist)
00255         assert not result.hits

Here is the call graph for this function:

Definition at line 335 of file test_search.py.

00335 
00336     def test_stemming(self):
00337         result = self.search(u"title:edit")
00338         assert len(result.hits) == 2
00339 
00340         result = self.search(u"title:editing")
00341         assert len(result.hits) == 1
00342 

Here is the call graph for this function:

Definition at line 279 of file test_search.py.

00279 
00280     def test_title_search(self):
00281         query = QueryParser(titlesearch=True).parse_query('FrontPage')
00282         result = self.search(query)
00283         assert len(result.hits) == 1

Here is the call graph for this function:

Definition at line 156 of file test_search.py.

00156 
00157     def test_title_search_case(self):
00158         result = self.search(u'title:case:SearchTestPage')
00159         assert len(result.hits) == 1
00160 
00161         result = self.search(u'title:case:searchtestpage')
00162         assert not result.hits

Here is the call graph for this function:

Definition at line 163 of file test_search.py.

00163 
00164     def test_title_search_case_re(self):
00165         result = self.search(ur'title:case:re:\bSearchTestPage\b')
00166         assert len(result.hits) == 1
00167 
00168         result = self.search(ur'title:case:re:\bsearchtestpage\b')
00169         assert not result.hits

Here is the call graph for this function:

Definition at line 149 of file test_search.py.

00149 
00150     def test_title_search_re(self):
00151         result = self.search(ur'title:re:\bSearchTest')
00152         assert len(result.hits) == 4
00153 
00154         result = self.search(ur'title:re:\bSearchTest\b')
00155         assert not result.hits

Here is the call graph for this function:

Definition at line 132 of file test_search.py.

00132 
00133     def test_title_search_simple(self):
00134         searches = {u'title:SearchTestPage': 1,
00135                     u'title:LanguageSetup': 1,
00136                     u'title:HelpIndex': 1,
00137                     u'title:Help': 3,
00138                     u'title:HelpOn': 2,
00139                     u'title:SearchTestNotExisting': 0,
00140                     u'title:FrontPage': 1,
00141                     u'title:HelpOnEditing': 1}
00142 
00143         def test(query, res_count):
00144             result = self.search(query)
00145             assert len(result.hits) == res_count
00146 
00147         for query, res_count in searches.iteritems():
00148             yield query, test, query, res_count

Here is the call graph for this function:

search: negated full search for some string that does not exist results in all pages 

Definition at line 274 of file test_search.py.

00274 
00275     def testFullSearchNegatedFindAll(self):
00276         """ search: negated full search for some string that does not exist results in all pages """
00277         result = self.search(u"-%s" % self.doesnotexist)
00278         assert len(result.hits) == len(self.pages)

Here is the call graph for this function:

search: negated title search for some pagename that does not exist results in all pagenames 

Definition at line 261 of file test_search.py.

00261 
00262     def testTitleSearchNegatedFindAll(self):
00263         """ search: negated title search for some pagename that does not exist results in all pagenames """
00264         result = self.search(u"-title:%s" % self.doesnotexist)
00265         assert len(result.hits) == len(self.pages)

Here is the call graph for this function:

search: title search for a AND expression with a negative term 

Definition at line 266 of file test_search.py.

00266 
00267     def testTitleSearchNegativeTerm(self):
00268         """ search: title search for a AND expression with a negative term """
00269         result = self.search(u"-title:FrontPage")
00270         assert len(result.hits) == len(self.pages) - 1
00271 
00272         result = self.search(u"-title:HelpOn")
00273         assert len(result.hits) == len(self.pages) - 2

Here is the call graph for this function:

search: title search with OR expression 

Definition at line 256 of file test_search.py.

00256 
00257     def testTitleSearchOR(self):
00258         """ search: title search with OR expression """
00259         result = self.search(u"title:FrontPage or title:RecentChanges")
00260         assert len(result.hits) == 2

Here is the call graph for this function:


Member Data Documentation

string test_search.BaseSearchTest.doesnotexist = u'jfhsdaASDLASKDJ' [static, inherited]

Definition at line 85 of file test_search.py.

dictionary test_search.BaseSearchTest.pages [static, inherited]
Initial value:
{u'SearchTestPage': u'this is a test page',
             u'SearchTestLinks': u'SearchTestPage',
             u'SearchTestLinksLowerCase': u'searchtestpage',
             u'SearchTestOtherLinks': u'SearchTestLinks',
             u'TestEdit': u'TestEdit',
             u'LanguageSetup': None,
             u'CategoryHomepage': None,
             u'HomePageWiki': None,
             u'FrontPage': None,
             u'RecentChanges': None,
             u'HelpOnCreoleSyntax': None,
             u'HelpOnEditing': None,
             u'HelpIndex': None}

Definition at line 90 of file test_search.py.

Reimplemented from test_search.BaseSearchTest.

Definition at line 329 of file test_search.py.


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