From 303d21dd164ebb187f74a6fabe4f92fee1cd32c5 Mon Sep 17 00:00:00 2001 From: Julien Muchembled <jm@nexedi.com> Date: Sun, 7 Nov 2010 03:11:29 +0000 Subject: [PATCH] ERP5TypeTestCase: new getRule method git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@40002 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/tests/testDivergenceTester.py | 12 +++++------- product/ERP5/tests/testERP5Commerce.py | 4 ---- product/ERP5/tests/testInventoryAPI.py | 4 ---- product/ERP5/tests/testMRP.py | 4 ---- product/ERP5Type/tests/ERP5TypeTestCase.py | 4 ++++ 5 files changed, 9 insertions(+), 19 deletions(-) diff --git a/product/ERP5/tests/testDivergenceTester.py b/product/ERP5/tests/testDivergenceTester.py index 2f050b718e..da284a53ef 100644 --- a/product/ERP5/tests/testDivergenceTester.py +++ b/product/ERP5/tests/testDivergenceTester.py @@ -43,17 +43,15 @@ class TestDivergenceTester(TestPackingListMixin, ERP5TypeTestCase): def getTitle(self): return "Divergence Tester" - def getRule(self): - rule_reference = 'default_delivering_rule' - return self.portal.portal_rules.searchFolder(reference=rule_reference, - validation_state="validated", sort_on='version', - sort_order='descending')[0].getObject() + def getDeliveringRule(self): + return self.getRule(reference='default_delivering_rule', + validation_state="validated") def afterSetUp(self): """ Remove all divergence testers from order_rule. """ - rule = self.getRule() + rule = self.getDeliveringRule() tester_list = rule.contentValues( portal_type=rule.getPortalDivergenceTesterTypeList()) rule.deleteContent([x.getId() for x in tester_list]) @@ -108,7 +106,7 @@ class TestDivergenceTester(TestPackingListMixin, ERP5TypeTestCase): packing_list = sql_result[0].getObject() # XXX Hardcoded id movement=packing_list['1'] - rule = self.getRule() + rule = self.getDeliveringRule() sequence.edit( packing_list=packing_list, movement=movement, diff --git a/product/ERP5/tests/testERP5Commerce.py b/product/ERP5/tests/testERP5Commerce.py index 565e96ab55..03ef24195b 100644 --- a/product/ERP5/tests/testERP5Commerce.py +++ b/product/ERP5/tests/testERP5Commerce.py @@ -110,10 +110,6 @@ class TestCommerce(ERP5TypeTestCase): 'erp5_commerce', 'erp5_simulation_test') - def getRule(self, **kw): - return self.portal.portal_rules.searchFolder( - sort_on='version', sort_order='descending', **kw)[0].getObject() - def afterSetUp(self): uf = self.getPortal().acl_users uf._doAddUser('ivan', '', ['Manager'], []) diff --git a/product/ERP5/tests/testInventoryAPI.py b/product/ERP5/tests/testInventoryAPI.py index 7a6acc4638..318fe8da22 100644 --- a/product/ERP5/tests/testInventoryAPI.py +++ b/product/ERP5/tests/testInventoryAPI.py @@ -185,10 +185,6 @@ class InventoryAPITestCase(ERP5TypeTestCase): 'erp5_trade', 'erp5_apparel', 'erp5_project', 'erp5_simulation_test') - def getRule(self, **kw): - return self.portal.portal_rules.searchFolder( - sort_on='version', sort_order='descending', **kw)[0].getObject() - # TODO: move this to a base class {{{ @reindex def _makeOrganisation(self, **kw): diff --git a/product/ERP5/tests/testMRP.py b/product/ERP5/tests/testMRP.py index 0b966039f7..02b37979bd 100644 --- a/product/ERP5/tests/testMRP.py +++ b/product/ERP5/tests/testMRP.py @@ -60,10 +60,6 @@ class TestMRPMixin(TestBPMMixin): if rule.getValidationState() == 'validated': rule.invalidate() - def getRule(self, **kw): - return self.portal.portal_rules.searchFolder( - sort_on='version', sort_order='descending', **kw)[0].getObject() - def _createDocument(self, portal_type, **kw): module = self.portal.getDefaultModule( portal_type=portal_type) diff --git a/product/ERP5Type/tests/ERP5TypeTestCase.py b/product/ERP5Type/tests/ERP5TypeTestCase.py index 648f056e30..d9749aa6b1 100644 --- a/product/ERP5Type/tests/ERP5TypeTestCase.py +++ b/product/ERP5Type/tests/ERP5TypeTestCase.py @@ -712,6 +712,10 @@ class ERP5TypeTestCase(ProcessingNodeTestCase, PortalTestCase): # reset aq_dynamic cache _aq_reset() + def getRule(self, **kw): + return self.portal.portal_rules.searchFolder( + sort_on='version', sort_order='descending', **kw)[0].getObject() + def validateRules(self): """ try to validate all rules in rule_tool. -- 2.30.9