From 58ad420ebeee5321f1e5bf330cb33c03bf3e9d8b Mon Sep 17 00:00:00 2001 From: Yoshinori Okuji <yo@nexedi.com> Date: Mon, 29 Oct 2007 23:19:28 +0000 Subject: [PATCH] Add tests for parameter passing to before and after scripts. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17265 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/tests/testInteractionWorkflow.py | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/product/ERP5/tests/testInteractionWorkflow.py b/product/ERP5/tests/testInteractionWorkflow.py index 2dc7cf7935..599691d994 100644 --- a/product/ERP5/tests/testInteractionWorkflow.py +++ b/product/ERP5/tests/testInteractionWorkflow.py @@ -425,6 +425,56 @@ class TestInteractionWorkflow(ERP5TypeTestCase): # - interaction:setVatCode(bara) self.assertEquals(organisation.getVatCode(),'bara') + def test_14_BeforeScriptParameters(self, quiet=0, run=run_all_test): + if not run: return + if not quiet: + self.logMessage('Before Script Parameters') + self.createInteractionWorkflow() + self.interaction.setProperties( + 'afterEdit', + method_id='getProperty', + script_name=('afterEdit',)) + params = 'sci,**kw' + body = """\ +context = sci['object'] +kwargs = sci['kwargs'] or {} +d = kwargs.get('d', None) +args = kwargs.get('workflow_method_args', ()) +result = kwargs.get('workflow_method_result', None) +context.setDescription('%s,%s,%s' % (d, args, result)) +""" + self.script.ZPythonScript_edit(params,body) + self.createData() + organisation = self.organisation + organisation.setDescription('bad') + value = organisation.getProperty('description', d='toto') + self.assertEquals(value, "toto,('description',),None") + + def test_15_AfterScriptParameters(self, quiet=0, run=run_all_test): + if not run: return + if not quiet: + self.logMessage('After Script Parameters') + self.createInteractionWorkflow() + self.interaction.setProperties( + 'afterEdit', + method_id='getProperty', + after_script_name=('afterEdit',)) + params = 'sci,**kw' + body = """\ +context = sci['object'] +kwargs = sci['kwargs'] or {} +d = kwargs.get('d', None) +args = kwargs.get('workflow_method_args', ()) +result = kwargs.get('workflow_method_result', None) +context.setDescription('%s,%s,%s' % (d, args, result)) +""" + self.script.ZPythonScript_edit(params,body) + self.createData() + organisation = self.organisation + organisation.setDescription('bad') + organisation.getProperty('description', d='toto') + value = organisation.getDescription() + self.assertEquals(value, "toto,('description',),bad") def test_suite(): suite = unittest.TestSuite() -- 2.30.9