From 7a0c91ea6dba187f652ef2e88d4e5cd99376624f Mon Sep 17 00:00:00 2001 From: Vincent Pelletier <vincent@nexedi.com> Date: Mon, 12 Mar 2007 10:39:42 +0000 Subject: [PATCH] Update test to handle new Base_isAutomaticCheckCreationAllowed script. Add a cleanup step to empty module at the end of a sequence. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13343 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../tests/testERP5BankingCheckPayment.py | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/product/ERP5Banking/tests/testERP5BankingCheckPayment.py b/product/ERP5Banking/tests/testERP5BankingCheckPayment.py index 8d4770e62b..472b5c7f40 100755 --- a/product/ERP5Banking/tests/testERP5BankingCheckPayment.py +++ b/product/ERP5Banking/tests/testERP5BankingCheckPayment.py @@ -291,13 +291,26 @@ class TestERP5BankingCheckPaymentMixin: def stepCheckConsistency(self, sequence=None, sequence_list=None, **kwd): """ Check the consistency of the check payment + Enable automatic check creation before passing workflow transition, and + disable at the end of the test. FIXME: check if the transition fails when a category or property is invalid. """ + check_creation_script = self.getPortal().Base_isAutomaticCheckCreationAllowed + original_script_source = check_creation_script._body + check_creation_script.ZPythonScript_edit(check_creation_script._params, 'return True') self.workflow_tool.doActionFor(self.check_payment, 'plan_action', wf_id='check_payment_workflow') self.assertNotEqual(self.check_payment.getAggregateValue(), None) self.assertEqual(self.check_payment.getSimulationState(), 'planned') + check_creation_script.ZPythonScript_edit(check_creation_script._params, original_script_source) + def stepTryCheckConsistencyWithoutAutomaticCheckCreation(self, sequence=None, sequence_list=None, **kwd): + """ + Do not enable automatic check creation and verify that validation fails. + """ + self.assertRaises(ValidationFailed, self.workflow_tool.doActionFor, self.check_payment, 'plan_action', wf_id='check_payment_workflow') + self.assertEqual(self.check_payment.getAggregateValue(), None) + self.assertNotEqual(self.check_payment.getSimulationState(), 'planned') def stepSendToCounter(self, sequence=None, sequence_list=None, **kwd): """ @@ -376,6 +389,15 @@ class TestERP5BankingCheckPaymentMixin: self.assertEqual(self.simulation_tool.getCurrentInventory(payment=self.bank_account_1.getRelativeUrl()), 80000) self.assertEqual(self.simulation_tool.getFutureInventory(payment=self.bank_account_1.getRelativeUrl()), 80000) + def stepCleanup(self, sequence=None, sequence_list=None, **kwd): + """ + Cleanup test remains + """ + # Fetch all ids before deleting the objects, otherwise the iterator will + # skip objects as the list dynamicaly shrinks. + object_id_list = [x for x in self.check_payment_module.objectIds()] + for id in object_id_list: + self.check_payment_module.deleteContent(id) class TestERP5BankingCheckPayment(TestERP5BankingCheckPaymentMixin, TestERP5BankingMixin, ERP5TypeTestCase): @@ -401,8 +423,16 @@ class TestERP5BankingCheckPayment(TestERP5BankingCheckPaymentMixin, 'stepValidateAnotherCheckPaymentFailsAgain Tic ' \ 'InputCashDetails Tic ' \ 'Pay Tic ' \ - 'CheckFinalInventory ' + 'CheckFinalInventory Cleanup Tic' + # sequence 2 : check if validating with non-exiting check fail if + # automatic check creation is disabled. + sequence_string_2 = 'Tic CheckObjects Tic CheckInitialInventory ' \ + 'CreateCheckPayment Tic ' \ + 'TryCheckConsistencyWithoutAutomaticCheckCreation Tic ' \ + 'CheckConsistency Tic ' \ + 'Cleanup Tic' sequence_list.addSequenceString(sequence_string) + sequence_list.addSequenceString(sequence_string_2) # play the sequence sequence_list.play(self) -- 2.30.9