Commit a0a0fbf2 authored by Aurel's avatar Aurel

test method on predicate now take the predicate as parameter


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14964 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a538cde8
...@@ -162,7 +162,7 @@ class Predicate(XMLObject, Folder): ...@@ -162,7 +162,7 @@ class Predicate(XMLObject, Folder):
for test_method_id in test_method_id_list : for test_method_id in test_method_id_list :
if (test_method_id is not None) and result: if (test_method_id is not None) and result:
method = getattr(context,test_method_id) method = getattr(context,test_method_id)
result = result and method() result = result and method(self)
# LOG('predicate test', 0, # LOG('predicate test', 0,
# '%s after method %s ' % (result, test_method_id)) # '%s after method %s ' % (result, test_method_id))
return result return result
......
...@@ -130,13 +130,13 @@ class TestPredicates(ERP5TypeTestCase): ...@@ -130,13 +130,13 @@ class TestPredicates(ERP5TypeTestCase):
def stepCreatePredicateTrueScript(self, sequence=None, **kw) : def stepCreatePredicateTrueScript(self, sequence=None, **kw) :
"""Creates a script that always return true""" """Creates a script that always return true"""
createZODBPythonScript(self.getPortal().portal_skins.erp5_base, createZODBPythonScript(self.getPortal().portal_skins.erp5_base,
'Predicate_true', '', """return 1""") 'Predicate_true', 'predicate', """return 1""")
sequence.edit(test_method_id = 'Predicate_true') sequence.edit(test_method_id = 'Predicate_true')
def stepCreatePredicateFalseScript(self, sequence=None, **kw) : def stepCreatePredicateFalseScript(self, sequence=None, **kw) :
"""Creates a script that always return false""" """Creates a script that always return false"""
createZODBPythonScript(self.getPortal().portal_skins.erp5_base, createZODBPythonScript(self.getPortal().portal_skins.erp5_base,
'Predicate_false', '', """return 0""") 'Predicate_false', 'predicate', """return 0""")
sequence.edit(test_method_id = 'Predicate_false') sequence.edit(test_method_id = 'Predicate_false')
def stepCreateTestMethodIdPredicate(self, sequence=None, **kw) : def stepCreateTestMethodIdPredicate(self, sequence=None, **kw) :
...@@ -330,11 +330,11 @@ class TestPredicates(ERP5TypeTestCase): ...@@ -330,11 +330,11 @@ class TestPredicates(ERP5TypeTestCase):
def test_TestMethodId(self): def test_TestMethodId(self):
doc = self.createDocument(region='europe/western_europe/france',) doc = self.createDocument(region='europe/western_europe/france',)
calls = [] calls = []
def true_method(): def true_method(predicate):
calls.append(True) calls.append(True)
return True return True
doc.true_method = true_method doc.true_method = true_method
def false_method(): def false_method(predicate):
calls.append(False) calls.append(False)
return False return False
doc.false_method = false_method doc.false_method = false_method
......
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