Commit c6510189 authored by Vincent Pelletier's avatar Vincent Pelletier

Split test_001_DefaultKey, test_003_DateTimeKey and test_004_KeywordKey into 2...

Split test_001_DefaultKey, test_003_DateTimeKey and test_004_KeywordKey into 2 tests each, instead of using a 2-items loop in each.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25837 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 372c7949
...@@ -166,44 +166,49 @@ class TestSQLCatalog(unittest.TestCase): ...@@ -166,44 +166,49 @@ class TestSQLCatalog(unittest.TestCase):
'Query: %r\nSearchText: %r\nReference: %r\nSecond rendering: %r' % \ 'Query: %r\nSearchText: %r\nReference: %r\nSecond rendering: %r' % \
(query, search_text, reference_param_dict, search_text_param_dict)) (query, search_text, reference_param_dict, search_text_param_dict))
def test_001_DefaultKey(self): def _testDefaultKey(self, column):
for column in ('default', 'related_default'): self.catalog(ReferenceQuery(ReferenceQuery(operator='=', default='a'), operator='and'),
self.catalog(ReferenceQuery(ReferenceQuery(operator='=', default='a'), operator='and'), {column: 'a'})
{column: 'a'}) self.catalog(ReferenceQuery(ReferenceQuery(operator='like', default='%a'), operator='and'),
self.catalog(ReferenceQuery(ReferenceQuery(operator='like', default='%a'), operator='and'), {column: '%a'})
{column: '%a'}) self.catalog(ReferenceQuery(ReferenceQuery(operator='<', default='a'), operator='and'),
self.catalog(ReferenceQuery(ReferenceQuery(operator='<', default='a'), operator='and'), {column: '<a'})
{column: '<a'}) self.catalog(ReferenceQuery(ReferenceQuery(operator='<=', default='a'), operator='and'),
self.catalog(ReferenceQuery(ReferenceQuery(operator='<=', default='a'), operator='and'), {column: '<=a'})
{column: '<=a'}) self.catalog(ReferenceQuery(ReferenceQuery(operator='>=', default='a'), operator='and'),
self.catalog(ReferenceQuery(ReferenceQuery(operator='>=', default='a'), operator='and'), {column: '>=a'})
{column: '>=a'}) self.catalog(ReferenceQuery(ReferenceQuery(operator='>', default='a'), operator='and'),
self.catalog(ReferenceQuery(ReferenceQuery(operator='>', default='a'), operator='and'), {column: '>a'})
{column: '>a'}) self.catalog(ReferenceQuery(ReferenceQuery(operator='!=', default='a'), operator='and'),
self.catalog(ReferenceQuery(ReferenceQuery(operator='!=', default='a'), operator='and'), {column: '!=a'})
{column: '!=a'}) self.catalog(ReferenceQuery(ReferenceQuery(operator='=', default='a b'), operator='and'),
self.catalog(ReferenceQuery(ReferenceQuery(operator='=', default='a b'), operator='and'), {column: 'a b'})
{column: 'a b'}) self.catalog(ReferenceQuery(ReferenceQuery(ReferenceQuery(operator='=', default='a'), ReferenceQuery(operator='>', default='b'), operator='or'), operator='and'),
self.catalog(ReferenceQuery(ReferenceQuery(ReferenceQuery(operator='=', default='a'), ReferenceQuery(operator='>', default='b'), operator='or'), operator='and'), {column: 'a >b'})
{column: 'a >b'}) self.catalog(ReferenceQuery(ReferenceQuery(operator='=', default='a > b'), operator='and'),
self.catalog(ReferenceQuery(ReferenceQuery(operator='=', default='a > b'), operator='and'), {column: 'a > b'})
{column: 'a > b'}) self.catalog(ReferenceQuery(ReferenceQuery(ReferenceQuery(operator='>', default='a'), ReferenceQuery(operator='>', default='b'), operator='or'), operator='and'),
self.catalog(ReferenceQuery(ReferenceQuery(ReferenceQuery(operator='>', default='a'), ReferenceQuery(operator='>', default='b'), operator='or'), operator='and'), {column: '>a >b'})
{column: '>a >b'}) self.catalog(ReferenceQuery(ReferenceQuery(operator='=', default='>a >b'), operator='and'),
self.catalog(ReferenceQuery(ReferenceQuery(operator='=', default='>a >b'), operator='and'), {column: '">a >b"'})
{column: '">a >b"'}) self.catalog(ReferenceQuery(ReferenceQuery(operator='>', default='>a >b'), operator='and'),
self.catalog(ReferenceQuery(ReferenceQuery(operator='>', default='>a >b'), operator='and'), {column: '>">a >b"'})
{column: '>">a >b"'}) self.catalog(ReferenceQuery(ReferenceQuery(operator='in', default=['a', 'b']), operator='and'),
self.catalog(ReferenceQuery(ReferenceQuery(operator='in', default=['a', 'b']), operator='and'), {column: 'a OR b'})
{column: 'a OR b'}) self.catalog(ReferenceQuery(ReferenceQuery(operator='=', default='a OR b'), operator='and'),
self.catalog(ReferenceQuery(ReferenceQuery(operator='=', default='a OR b'), operator='and'), {column: '"a OR b"'})
{column: '"a OR b"'}) self.catalog(ReferenceQuery(ReferenceQuery(operator='<', default='path'), operator='and'),
self.catalog(ReferenceQuery(ReferenceQuery(operator='<', default='path'), operator='and'), {column: {'query': 'path', 'range': 'max'}})
{column: {'query': 'path', 'range': 'max'}}) self.catalog(ReferenceQuery(ReferenceQuery(operator='in', default=['a', 'b']), operator='and'),
self.catalog(ReferenceQuery(ReferenceQuery(operator='in', default=['a', 'b']), operator='and'), {column: ['a', 'b']})
{column: ['a', 'b']}) self.catalog(ReferenceQuery(ReferenceQuery(operator='in', default=['a', 'b']), operator='and'),
self.catalog(ReferenceQuery(ReferenceQuery(operator='in', default=['a', 'b']), operator='and'), {column: ['=a', '=b']})
{column: ['=a', '=b']})
def test_DefaultKey(self):
self._testDefaultKey('default')
def test_relatedDefaultKey(self):
self._testDefaultKey('related_default')
def test_002_keyOverride(self): def test_002_keyOverride(self):
self.catalog(ReferenceQuery(ReferenceQuery(operator='=', default='%a'), operator='and'), self.catalog(ReferenceQuery(ReferenceQuery(operator='=', default='%a'), operator='and'),
...@@ -213,111 +218,121 @@ class TestSQLCatalog(unittest.TestCase): ...@@ -213,111 +218,121 @@ class TestSQLCatalog(unittest.TestCase):
{'default': {'query': '<a', 'key': 'ExactMatch'}}, {'default': {'query': '<a', 'key': 'ExactMatch'}},
check_search_text=False) check_search_text=False)
def test_003_DateTimeKey(self): def _testDateTimeKey(self, column):
for column in ('date', 'related_date'): self.catalog(ReferenceQuery(ReferenceQuery(operator='>=', date=DateTime('2008/10/01 12:10:21')), operator='and'),
self.catalog(ReferenceQuery(ReferenceQuery(operator='>=', date=DateTime('2008/10/01 12:10:21')), operator='and'), {column: {'query': '>2008/10/01 12:10:20', 'format': '%y/%m/%d'}})
{column: {'query': '>2008/10/01 12:10:20', 'format': '%y/%m/%d'}}) self.catalog(ReferenceQuery(ReferenceQuery(operator='>=', date=DateTime('2008/10/01 12:10:21 CEST')), operator='and'),
self.catalog(ReferenceQuery(ReferenceQuery(operator='>=', date=DateTime('2008/10/01 12:10:21 CEST')), operator='and'), {column: {'query': '>2008/10/01 12:10:20 CEST', 'format': '%y/%m/%d'}})
{column: {'query': '>2008/10/01 12:10:20 CEST', 'format': '%y/%m/%d'}}) self.catalog(ReferenceQuery(ReferenceQuery(operator='>=', date=DateTime('2008/10/01 12:10:21 CET')), operator='and'),
self.catalog(ReferenceQuery(ReferenceQuery(operator='>=', date=DateTime('2008/10/01 12:10:21 CET')), operator='and'), {column: {'query': '>2008/10/01 12:10:20 CET', 'format': '%y/%m/%d'}})
{column: {'query': '>2008/10/01 12:10:20 CET', 'format': '%y/%m/%d'}}) self.catalog(ReferenceQuery(ReferenceQuery(
self.catalog(ReferenceQuery(ReferenceQuery( ReferenceQuery(operator='>=', date=DateTime('2008/10/01 UTC')),
ReferenceQuery(operator='>=', date=DateTime('2008/10/01 UTC')), ReferenceQuery(operator='<', date=DateTime('2008/10/02 UTC'))
ReferenceQuery(operator='<', date=DateTime('2008/10/02 UTC')) , operator='and'), operator='and'),
, operator='and'), operator='and'), {column: '2008/10/01 UTC'})
{column: '2008/10/01 UTC'}) self.catalog(ReferenceQuery(ReferenceQuery(
self.catalog(ReferenceQuery(ReferenceQuery( ReferenceQuery(operator='>=', date=DateTime('2008/01/01 UTC')),
ReferenceQuery(operator='>=', date=DateTime('2008/01/01 UTC')), ReferenceQuery(operator='<', date=DateTime('2009/01/01 UTC'))
ReferenceQuery(operator='<', date=DateTime('2009/01/01 UTC')) , operator='and'), operator='and'),
, operator='and'), operator='and'), {column: '2008 UTC'})
{column: '2008 UTC'}) self.catalog(ReferenceQuery(ReferenceQuery(
self.catalog(ReferenceQuery(ReferenceQuery( ReferenceQuery(operator='>=', date=DateTime('2008/01/01 UTC')),
ReferenceQuery(operator='>=', date=DateTime('2008/01/01 UTC')), ReferenceQuery(operator='<', date=DateTime('2008/02/01 UTC'))
ReferenceQuery(operator='<', date=DateTime('2008/02/01 UTC')) , operator='and'), operator='and'),
, operator='and'), operator='and'), {column: '2008/01 UTC'})
{column: '2008/01 UTC'}) self.catalog(ReferenceQuery(ReferenceQuery(
self.catalog(ReferenceQuery(ReferenceQuery( ReferenceQuery(operator='>=', date=DateTime('2008/10/01 UTC')),
ReferenceQuery(operator='>=', date=DateTime('2008/10/01 UTC')), ReferenceQuery(operator='<', date=DateTime('2008/10/02 UTC'))
ReferenceQuery(operator='<', date=DateTime('2008/10/02 UTC')) , operator='and'), operator='and'),
, operator='and'), operator='and'), {column: {'type': 'date', 'query': '10/01/2008 UTC', 'format': '%m/%d/%Y'}})
{column: {'type': 'date', 'query': '10/01/2008 UTC', 'format': '%m/%d/%Y'}}) self.catalog(ReferenceQuery(ReferenceQuery(
self.catalog(ReferenceQuery(ReferenceQuery( ReferenceQuery(operator='>=', date=DateTime('2008/10/01 UTC')),
ReferenceQuery(operator='>=', date=DateTime('2008/10/01 UTC')), ReferenceQuery(operator='<', date=DateTime('2008/10/02 UTC'))
ReferenceQuery(operator='<', date=DateTime('2008/10/02 UTC')) , operator='and'), operator='and'),
, operator='and'), operator='and'), {column: {'type': 'date', 'query': '01/10/2008 UTC', 'format': '%d/%m/%Y'}})
{column: {'type': 'date', 'query': '01/10/2008 UTC', 'format': '%d/%m/%Y'}}) self.catalog(ReferenceQuery(ReferenceQuery(operator='in', date=[DateTime('2008/01/10 UTC'), DateTime('2008/01/09 UTC')]), operator='and'),
self.catalog(ReferenceQuery(ReferenceQuery(operator='in', date=[DateTime('2008/01/10 UTC'), DateTime('2008/01/09 UTC')]), operator='and'), {column: {'query': ['2008/01/10 UTC', '2008/01/09 UTC'], 'operator': 'in'}},
{column: {'query': ['2008/01/10 UTC', '2008/01/09 UTC'], 'operator': 'in'}}, check_search_text=False)
check_search_text=False) self.catalog(ReferenceQuery(ReferenceQuery(operator='>', date=DateTime('2008/01/10 UTC')), operator='and'),
self.catalog(ReferenceQuery(ReferenceQuery(operator='>', date=DateTime('2008/01/10 UTC')), operator='and'), {column: {'query': '2008/01/10 UTC', 'range': 'nlt'}},
{column: {'query': '2008/01/10 UTC', 'range': 'nlt'}}, check_search_text=False)
check_search_text=False) self.catalog(ReferenceQuery(ReferenceQuery(
self.catalog(ReferenceQuery(ReferenceQuery( ReferenceQuery(operator='>=', date=DateTime('2008/01/01 UTC')),
ReferenceQuery(operator='>=', date=DateTime('2008/01/01 UTC')), ReferenceQuery(operator='<', date=DateTime('2009/01/01 UTC'))
ReferenceQuery(operator='<', date=DateTime('2009/01/01 UTC')) , operator='and'), operator='and'),
, operator='and'), operator='and'), {column: '2008 UTC'})
{column: '2008 UTC'}) self.catalog(ReferenceQuery(ReferenceQuery(
self.catalog(ReferenceQuery(ReferenceQuery( ReferenceQuery(operator='>=', date=DateTime('2008/02/01 UTC')),
ReferenceQuery(operator='>=', date=DateTime('2008/02/01 UTC')), ReferenceQuery(operator='<', date=DateTime('2008/03/01 UTC'))
ReferenceQuery(operator='<', date=DateTime('2008/03/01 UTC')) , operator='and'), operator='and'),
, operator='and'), operator='and'), {column: '2008/02 UTC'})
{column: '2008/02 UTC'}) self.catalog(ReferenceQuery(ReferenceQuery(
self.catalog(ReferenceQuery(ReferenceQuery( ReferenceQuery(operator='>=', date=DateTime('2008/02/02 UTC')),
ReferenceQuery(operator='>=', date=DateTime('2008/02/02 UTC')), ReferenceQuery(operator='<', date=DateTime('2008/02/03 UTC'))
ReferenceQuery(operator='<', date=DateTime('2008/02/03 UTC')) , operator='and'), operator='and'),
, operator='and'), operator='and'), {column: '2008/02/02 UTC'})
{column: '2008/02/02 UTC'}) self.catalog(ReferenceQuery(ReferenceQuery(
self.catalog(ReferenceQuery(ReferenceQuery( ReferenceQuery(operator='>=', date=DateTime('2008/02/02 10:00:00 UTC')),
ReferenceQuery(operator='>=', date=DateTime('2008/02/02 10:00:00 UTC')), ReferenceQuery(operator='<', date=DateTime('2008/02/02 11:00:00 UTC'))
ReferenceQuery(operator='<', date=DateTime('2008/02/02 11:00:00 UTC')) , operator='and'), operator='and'),
, operator='and'), operator='and'), {column: '2008/02/02 10 UTC'})
{column: '2008/02/02 10 UTC'}) self.catalog(ReferenceQuery(ReferenceQuery(
self.catalog(ReferenceQuery(ReferenceQuery( ReferenceQuery(operator='>=', date=DateTime('2008/02/02 10:10:00 UTC')),
ReferenceQuery(operator='>=', date=DateTime('2008/02/02 10:10:00 UTC')), ReferenceQuery(operator='<', date=DateTime('2008/02/02 10:11:00 UTC'))
ReferenceQuery(operator='<', date=DateTime('2008/02/02 10:11:00 UTC')) , operator='and'), operator='and'),
, operator='and'), operator='and'), {column: '2008/02/02 10:10 UTC'})
{column: '2008/02/02 10:10 UTC'}) self.catalog(ReferenceQuery(ReferenceQuery(
self.catalog(ReferenceQuery(ReferenceQuery( ReferenceQuery(operator='>=', date=DateTime('2008/02/02 10:10:10 UTC')),
ReferenceQuery(operator='>=', date=DateTime('2008/02/02 10:10:10 UTC')), ReferenceQuery(operator='<', date=DateTime('2008/02/02 10:10:11 UTC'))
ReferenceQuery(operator='<', date=DateTime('2008/02/02 10:10:11 UTC')) , operator='and'), operator='and'),
, operator='and'), operator='and'), {column: '2008/02/02 10:10:10 UTC'})
{column: '2008/02/02 10:10:10 UTC'})
def test_DateTimeKey(self):
def test_004_KeywordKey(self): self._testDateTimeKey('date')
for column in ('keyword', 'related_keyword'):
self.catalog(ReferenceQuery(ReferenceQuery(operator='like', keyword='%a%'), operator='and'), def test_relatedDateTimeKey(self):
{column: 'a'}) self._testDateTimeKey('related_date')
self.catalog(ReferenceQuery(ReferenceQuery(operator='like', keyword='%a b%'), operator='and'),
{column: 'a b'}) def _testKeywordKey(self, column):
self.catalog(ReferenceQuery(ReferenceQuery(operator='like', keyword='%a b%'), operator='and'), self.catalog(ReferenceQuery(ReferenceQuery(operator='like', keyword='%a%'), operator='and'),
{column: '"a b"'}) {column: 'a'})
self.catalog(ReferenceQuery(ReferenceQuery(operator='!=', keyword='a'), operator='and'), self.catalog(ReferenceQuery(ReferenceQuery(operator='like', keyword='%a b%'), operator='and'),
{column: '!=a'}) {column: 'a b'})
self.catalog(ReferenceQuery(ReferenceQuery(operator='not like', keyword='%a'), operator='and'), self.catalog(ReferenceQuery(ReferenceQuery(operator='like', keyword='%a b%'), operator='and'),
{column: '!=%a'}) {column: '"a b"'})
self.catalog(ReferenceQuery(ReferenceQuery(operator='like', keyword='%a'), operator='and'), self.catalog(ReferenceQuery(ReferenceQuery(operator='!=', keyword='a'), operator='and'),
{column: '%a'}) {column: '!=a'})
self.catalog(ReferenceQuery(ReferenceQuery(operator='<', keyword='a'), operator='and'), self.catalog(ReferenceQuery(ReferenceQuery(operator='not like', keyword='%a'), operator='and'),
{column: '<a'}) {column: '!=%a'})
self.catalog(ReferenceQuery(ReferenceQuery(operator='<', keyword='path'), operator='and'), self.catalog(ReferenceQuery(ReferenceQuery(operator='like', keyword='%a'), operator='and'),
{column: {'query': 'path', 'range': 'max'}}) {column: '%a'})
self.catalog(ReferenceQuery(ReferenceQuery( self.catalog(ReferenceQuery(ReferenceQuery(operator='<', keyword='a'), operator='and'),
ReferenceQuery(operator='like', keyword='%a%'), {column: '<a'})
ReferenceQuery(operator='like', keyword='%b%') self.catalog(ReferenceQuery(ReferenceQuery(operator='<', keyword='path'), operator='and'),
, operator='or'), operator='and'), {column: {'query': 'path', 'range': 'max'}})
{column: ['a', 'b']}) self.catalog(ReferenceQuery(ReferenceQuery(
self.catalog(ReferenceQuery(ReferenceQuery(operator='in', keyword=['a', 'b']), operator='and'), ReferenceQuery(operator='like', keyword='%a%'),
{column: ['=a', '=b']}) ReferenceQuery(operator='like', keyword='%b%')
self.catalog(ReferenceQuery(ReferenceQuery( , operator='or'), operator='and'),
ReferenceQuery(operator='like', keyword='%a%'), {column: ['a', 'b']})
ReferenceQuery(operator='<', keyword='b') self.catalog(ReferenceQuery(ReferenceQuery(operator='in', keyword=['a', 'b']), operator='and'),
, operator='or'), operator='and'), {column: ['=a', '=b']})
{column: ['a', '<b']}) self.catalog(ReferenceQuery(ReferenceQuery(
self.catalog(ReferenceQuery(ReferenceQuery( ReferenceQuery(operator='like', keyword='%a%'),
ReferenceQuery(operator='like', keyword='%a%'), ReferenceQuery(operator='<', keyword='b')
ReferenceQuery(operator='like', keyword='%b') , operator='or'), operator='and'),
, operator='or'), operator='and'), {column: ['a', '<b']})
{column: ['a', '%b']}) self.catalog(ReferenceQuery(ReferenceQuery(
ReferenceQuery(operator='like', keyword='%a%'),
ReferenceQuery(operator='like', keyword='%b')
, operator='or'), operator='and'),
{column: ['a', '%b']})
def test_KeywordKey(self):
self._testKeywordKey('keyword')
def test_relatedKeywordKey(self):
self._testKeywordKey('related_keyword')
def test_005_SearchText(self): def test_005_SearchText(self):
self.catalog(ReferenceQuery(ReferenceQuery(ReferenceQuery(operator='like', keyword='%=a%'), ReferenceQuery(operator='like', keyword='%=b%'), operator='or'), operator='and'), self.catalog(ReferenceQuery(ReferenceQuery(ReferenceQuery(operator='like', keyword='%=a%'), ReferenceQuery(operator='like', keyword='%=b%'), operator='or'), operator='and'),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment