From 796ae00febb137123870b133b565da4ee51a1dda Mon Sep 17 00:00:00 2001 From: Kazuhiko Shiozaki <kazuhiko@nexedi.com> Date: Fri, 18 Dec 2009 13:27:33 +0000 Subject: [PATCH] reuse already existing rule. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31392 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/tests/testERP5Simulation.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/product/ERP5/tests/testERP5Simulation.py b/product/ERP5/tests/testERP5Simulation.py index 258bf38192..99dbd05737 100644 --- a/product/ERP5/tests/testERP5Simulation.py +++ b/product/ERP5/tests/testERP5Simulation.py @@ -43,12 +43,20 @@ class TestERP5SimulationMixin(TestPackingListMixin): TestPackingListMixin.afterSetUp(self, quiet, run) self.validateNewRules() - def validateNewRules(self): - portal_types = self.portal.portal_types + def beforeTearDown(self): + portal_rules = self.portal.portal_rules + for rule in portal_rules.objectValues(portal_type='New Order Rule'): + if rule.getValidationState() == 'validated': + rule.invalidate() + def validateNewRules(self): # create a New Order Rule document. portal_rules = self.portal.portal_rules - if portal_rules._getOb('new_order_rule', None) is None: + try: + new_order_rule = filter( + lambda x:x.title == 'New Default Order Rule', + portal_rules.objectValues(portal_type='New Order Rule'))[0] + except IndexError: new_order_rule = portal_rules.newContent( title='New Default Order Rule', portal_type='New Order Rule', @@ -113,6 +121,7 @@ class TestERP5SimulationMixin(TestPackingListMixin): tested_property=i, use_delivery_ratio=1, quantity=0) + if new_order_rule.getValidationState() != 'validated': new_order_rule.validate() class TestERP5Simulation(TestERP5SimulationMixin, TestPackingList): -- 2.30.9