[Erp5-report] r38360 vincent - /erp5/trunk/products/ZSQLCatalog/tests/testSQLCatalog.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Sep 14 15:33:11 CEST 2010
Author: vincent
Date: Tue Sep 14 15:33:09 2010
New Revision: 38360
URL: http://svn.erp5.org?rev=38360&view=rev
Log:
Make it possible to check multiple equivalent results.
Modified:
erp5/trunk/products/ZSQLCatalog/tests/testSQLCatalog.py
Modified: erp5/trunk/products/ZSQLCatalog/tests/testSQLCatalog.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/tests/testSQLCatalog.py?rev=38360&r1=38359&r2=38360&view=diff
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/tests/testSQLCatalog.py [utf8] (original)
+++ erp5/trunk/products/ZSQLCatalog/tests/testSQLCatalog.py [utf8] Tue Sep 14 15:33:09 2010
@@ -38,6 +38,9 @@ from Products.ZSQLCatalog.Query.RelatedQ
from DateTime import DateTime
from Products.ZSQLCatalog.SQLExpression import MergeConflictError
+class MatchList(list):
+ pass
+
class ReferenceQuery:
"""
This class is made to be able to compare a generated query tree with a
@@ -92,7 +95,10 @@ class ReferenceQuery:
else:
self.args.append(arg)
if len(kw) == 1:
- self.column, self.value = kw.items()[0]
+ self.column, value = kw.items()[0]
+ if not isinstance(value, MatchList):
+ value = MatchList([value])
+ self.value = value
elif len(kw) > 1:
raise ValueError, 'kw must not have more than one item: %r' % (kw, )
@@ -100,7 +106,7 @@ class ReferenceQuery:
if isinstance(other, SimpleQuery):
return self.column is not None and \
other.getColumn() == self.column and \
- other.getValue() == self.value and \
+ other.getValue() in self.value and \
other.comparison_operator == self.operator
elif isinstance(other, ComplexQuery):
if not (len(other.query_list) == len(self.args) and \
@@ -431,7 +437,8 @@ class TestSQLCatalog(unittest.TestCase):
{'fulltext': 'a NOT b', 'order_by_list': [('fulltext', ), ]},
check_search_text=False)
# If one want to sort on, he must use the equivalent FullText syntax:
- self.catalog(ReferenceQuery(ReferenceQuery(operator='match_boolean', fulltext='a -b'), operator='and'),
+ self.catalog(ReferenceQuery(ReferenceQuery(operator='match_boolean',
+ fulltext=MatchList(['a -b', '-b a'])), operator='and'),
{'fulltext': 'a -b', 'order_by_list': [('fulltext', ), ]},
check_search_text=False)
self.catalog(ReferenceQuery(ReferenceQuery(ReferenceQuery(operator='match', fulltext='a'),
@@ -510,11 +517,14 @@ class TestSQLCatalog(unittest.TestCase):
"""
self.catalog(ReferenceQuery(ReferenceQuery(operator='match', fulltext='a+b'), operator='and'),
{'fulltext': 'a+b'})
- self.catalog(ReferenceQuery(ReferenceQuery(operator='match_boolean', fulltext='a +b'), operator='and'),
+ self.catalog(ReferenceQuery(ReferenceQuery(operator='match_boolean',
+ fulltext=MatchList(['a +b', '+b a'])), operator='and'),
{'fulltext': 'a +b'})
- self.catalog(ReferenceQuery(ReferenceQuery( ReferenceQuery(operator='=', uid='foo'),
- ReferenceQuery(operator='match_boolean', fulltext='+a b'), operator='and'
- ), operator='and'), {'fulltext': '+a b uid:foo'})
+ self.catalog(ReferenceQuery(ReferenceQuery(
+ ReferenceQuery(operator='=', uid='foo'),
+ ReferenceQuery(operator='match_boolean',
+ fulltext=MatchList(['+a b', 'b +a'])),
+ operator='and'), operator='and'), {'fulltext': '+a b uid:foo'})
def test_DefaultKeyTextRendering(self):
self.catalog(ReferenceQuery(ReferenceQuery(operator='like', default='a% b'), operator='and'),
More information about the Erp5-report
mailing list