Back to index

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

List of all members.

Classes

class  Config

Public Member Functions

def get_searcher
def get_moin_search_connection
def setup_class
def teardown_class
def test_get_all_documents
def test_xapian_term
def test_stemming
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

Public Attributes

 searcher_class

Static Public Attributes

string doesnotexist = u'jfhsdaASDLASKDJ'
dictionary pages

Private Member Functions

def _index_update

Detailed Description

search: test Xapian indexing 

Definition at line 343 of file test_search.py.


Member Function Documentation

Reimplemented from test_search.BaseSearchTest.

Definition at line 350 of file test_search.py.

00350 
00351     def _index_update(self):
00352         # for xapian, we queue index updates so they can get indexed later.
00353         # here we make sure the queue will be processed completely,
00354         # before we continue:
00355         from MoinMoin.search.Xapian import XapianIndex
00356         XapianIndex(self.request).do_queued_updates()

Here is the call graph for this function:

Definition at line 361 of file test_search.py.

00361 
00362     def get_moin_search_connection(self):
00363         from MoinMoin.search.Xapian import XapianIndex
00364         return XapianIndex(self.request).get_search_connection()

Here is the call graph for this function:

Here is the caller graph for this function:

def test_search.TestXapianSearch.get_searcher (   self,
  query 
)

Reimplemented from test_search.BaseSearchTest.

Definition at line 357 of file test_search.py.

00357 
00358     def get_searcher(self, query):
00359         from MoinMoin.search.Xapian.search import XapianSearch
00360         return XapianSearch(self.request, query)

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:

Reimplemented from test_search.BaseSearchTest.

Definition at line 365 of file test_search.py.

00365 
00366     def setup_class(self):
00367 
00368         try:
00369             from MoinMoin.search.Xapian import XapianIndex
00370             from MoinMoin.search.Xapian.search import XapianSearch
00371             self.searcher_class = XapianSearch
00372 
00373         except ImportError, error:
00374             if not str(error).startswith('Xapian '):
00375                 raise
00376 
00377             py.test.skip('xapian is not installed')
00378 
00379         nuke_xapian_index(self.request)
00380         index = XapianIndex(self.request)
00381         # Additionally, pages which were not created but supposed to be searched
00382         # are indexed.
00383         pages_to_index = [page for page in self.pages if not self.pages[page]]
00384         index.indexPages(mode='add', pages=pages_to_index)
00385 
00386         super(TestXapianSearch, self).setup_class()

Reimplemented from test_search.BaseSearchTest.

Definition at line 387 of file test_search.py.

00387 
00388     def teardown_class(self):
00389         nuke_xapian_index(self.request)

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 390 of file test_search.py.

00390 
00391     def test_get_all_documents(self):
00392         connection = self.get_moin_search_connection()
00393         documents = connection.get_all_documents()
00394 
00395         assert len(self.pages) == len(documents)
00396         for document in documents:
00397             assert document.data['pagename'][0] in self.pages.keys()

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:

Reimplemented in test_search.TestXapianSearchStemmed.

Definition at line 421 of file test_search.py.

00421 
00422     def test_stemming(self):
00423         result = self.search(u"title:edit")
00424         assert len(result.hits) == 1
00425 
00426         result = self.search(u"title:editing")
00427         assert len(result.hits) == 1
00428 

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:

Definition at line 398 of file test_search.py.

00398 
00399     def test_xapian_term(self):
00400         parser = QueryParser()
00401         connection = self.get_moin_search_connection()
00402 
00403         prefixes = {u'': ([u'', u're:', u'case:', u'case:re:'], u'SearchTestPage'),
00404                     u'title:': ([u'', u're:', u'case:', u'case:re:'], u'SearchTestPage'),
00405                     u'linkto:': ([u'', u're:', u'case:', u'case:re:'], u'FrontPage'),
00406                     u'category:': ([u'', u're:', u'case:', u'case:re:'], u'CategoryHomepage'),
00407                     u'mimetype:': ([u'', u're:'], u'text/wiki'),
00408                     u'language:': ([u''], u'en'),
00409                     u'domain:': ([u''], u'system')}
00410 
00411         def test_query(query):
00412             query_ = parser.parse_query(query).xapian_term(self.request, connection)
00413             print str(query_)
00414             assert not query_.empty()
00415 
00416         for prefix, data in prefixes.iteritems():
00417             modifiers, term = data
00418             for modifier in modifiers:
00419                 query = ''.join([prefix, modifier, term])
00420                 yield query, test_query, query

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 370 of file test_search.py.


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