From afae7b7c00bc32477c870e6cfed3700d4f3412f0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Wed, 14 May 2008 08:31:50 +0000
Subject: [PATCH] Add a few more tests for full text keys.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20949 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ZSQLCatalog/tests/testSearchKeys.py  | 4 +++-
 product/ZSQLCatalog/tests/testZSQLCatalog.py | 8 ++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/product/ZSQLCatalog/tests/testSearchKeys.py b/product/ZSQLCatalog/tests/testSearchKeys.py
index a1570ae994..61c57c8470 100644
--- a/product/ZSQLCatalog/tests/testSearchKeys.py
+++ b/product/ZSQLCatalog/tests/testSearchKeys.py
@@ -121,12 +121,14 @@ size/Child/34"""
   def test_05FullTextKey(self, quiet=quiet, run=run_all_test):
     """ Check lexer for FullTextKey."""
     if not run: return
+    self.compare(FullTextKey, 'John', ('WORD',))
     self.compare(FullTextKey, 'John Doe', ('WORD', 'WORD',))
     self.compare(FullTextKey, '+John -Doe',
                  ('PLUS', 'WORD', 'MINUS', 'WORD',))
+    self.compare(FullTextKey, 'John*', ('WORD', 'ASTERISK'))
+    self.compare(FullTextKey, '+John*', ('PLUS', 'WORD', 'ASTERISK'))
     self.compare(FullTextKey, '.', ('WORD',))
     self.compare(FullTextKey, '"John Doe"', ('DOUBLEQUOTE', 'WORD', 'WORD', 'DOUBLEQUOTE'))
-    self.compare(FullTextKey, 'John*', ('WORD', 'ASTERISK'))
     self.compare(FullTextKey, '+apple +(>turnover <strudel)',
                  ('PLUS', 'WORD', 'PLUS', 'LEFTPARENTHES', 'GREATERTHAN', 'WORD',
                   'LESSTHAN', 'WORD', 'RIGHTPARENTHES',))
diff --git a/product/ZSQLCatalog/tests/testZSQLCatalog.py b/product/ZSQLCatalog/tests/testZSQLCatalog.py
index 26d5cbcaeb..e5b783ec79 100644
--- a/product/ZSQLCatalog/tests/testZSQLCatalog.py
+++ b/product/ZSQLCatalog/tests/testZSQLCatalog.py
@@ -223,6 +223,14 @@ class TestQuery(unittest.TestCase):
                             datetime_search_keys = [],
                             full_text_search_keys=['title']))
   
+  def testSimpleQueryFullAutomaticTextSearchMode(self):
+    q = Query(title='Foo*',)
+    self.assertEquals(dict(
+      where_expression="MATCH title AGAINST ('Foo*' IN BOOLEAN MODE)",
+      select_expression_list=
+        ["MATCH title AGAINST ('Foo*' IN BOOLEAN MODE) AS title_relevance"]),
+          q.asSQLExpression(full_text_search_keys=['title']))
+
   def testSimpleQueryFullTextStat__(self):
     # stat__ is an internal implementation artifact to prevent adding
     # select_expression for countFolder
-- 
2.30.9