changeset 4993:1d7a28cfc0f6

Xapian2009: Tests for xapian_term() which should not return empty query.
author Dmitrijs Milajevs <dimazest@gmail.com>
date Mon, 10 Aug 2009 21:30:54 +0200
parents c6da526a8c30
children 605b2da7765e
files MoinMoin/search/_tests/test_search.py
diffstat 1 files changed, 22 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/search/_tests/test_search.py	Mon Aug 10 21:30:51 2009 +0200
+++ b/MoinMoin/search/_tests/test_search.py	Mon Aug 10 21:30:54 2009 +0200
@@ -242,7 +242,7 @@
         assert len(result.hits) == len(self.pages)
 
     def test_title_search(self):
-        query = QueryParser(titlesearch=True).parse_query('Moin')
+        query = QueryParser(titlesearch=True).parse_query('FrontPage')
         result = self.search(query)
         assert len(result.hits) == 1
 
@@ -272,6 +272,27 @@
     def teardown_method(self, method):
         nuke_xapian_index(self.request)
 
+    def test_xapian_term(self):
+
+        from MoinMoin.search.Xapian import MoinSearchConnection
+
+        parser = QueryParser()
+        connection = MoinSearchConnection('tests/wiki/data/cache/xapian/index') # XXX Index location should not be hardcoded!
+        prefixes = {'title:': ['', 're:', 'case:', 'case:re:'],
+                    'linkto:': ['', 're:', 'case:', 'case:re:'],
+                    'category:': ['re:', 'case:', 'case:re:'],
+                    'mimetype:': ['re:'],
+                    'language:': [''],
+                    'domain:': ['']}
+
+        def test_query(query):
+            print query
+            assert not parser.parse_query(query).xapian_term(self.request, connection).empty()
+
+        for prefix, modifiers in prefixes.iteritems():
+            for modifier in modifiers:
+                query = ''.join([prefix, modifier, 'something'])
+                yield test_query, query
 
 class TestXapianIndexingInNewThread(object):
     """ search: test Xapian indexing """