[IMP] base: test for expression distribute_not
Testing the use case of c28a28e
, in which distribute_not was refactored
with iteration instead of recursion.
This commit is contained in:
parent
c28a28e69e
commit
d24fcd1d2e
|
@ -1,5 +1,6 @@
|
|||
import unittest2
|
||||
|
||||
import openerp.osv.expression as expression
|
||||
from openerp.osv.expression import get_unaccent_wrapper
|
||||
from openerp.osv.orm import BaseModel
|
||||
import openerp.tests.common as common
|
||||
|
@ -459,6 +460,25 @@ class test_expression(common.TransactionCase):
|
|||
partner_parent_id_col._auto_join = False
|
||||
state_country_id_col._auto_join = False
|
||||
|
||||
def test_40_negating_long_expression(self):
|
||||
source = ['!','&',('user_id','=',4),('partner_id','in',[1,2])]
|
||||
expect = ['|',('user_id','!=',4),('partner_id','not in',[1,2])]
|
||||
self.assertEqual(expression.distribute_not(source), expect,
|
||||
"distribute_not on expression applied wrongly")
|
||||
|
||||
pos_leaves = [[('a', 'in', [])], [('d', '!=', 3)]]
|
||||
neg_leaves = [[('a', 'not in', [])], [('d', '=', 3)]]
|
||||
|
||||
source = expression.OR([expression.AND(pos_leaves)] * 1000)
|
||||
expect = source
|
||||
self.assertEqual(expression.distribute_not(source), expect,
|
||||
"distribute_not on long expression without negation operator should not alter it")
|
||||
|
||||
source = ['!'] + source
|
||||
expect = expression.AND([expression.OR(neg_leaves)] * 1000)
|
||||
self.assertEqual(expression.distribute_not(source), expect,
|
||||
"distribute_not on long expression applied wrongly")
|
||||
|
||||
def test_translate_search(self):
|
||||
Country = self.registry('res.country')
|
||||
be = self.ref('base.be')
|
||||
|
|
Loading…
Reference in New Issue