[Erp5-report] r20849 - /erp5/trunk/products/ERP5/tests/testAccounting.py

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Apr 30 09:48:53 CEST 2008


Author: jerome
Date: Wed Apr 30 09:48:52 2008
New Revision: 20849

URL: http://svn.erp5.org?rev=20849&view=rev
Log:
Don't assume that we'll have organisation_module/my_organisation and
portal_preferences/accounting_zuite_preference installed paths, this way we can
reuse AccountingTestCase without erp5_accounting_ui_test


Modified:
    erp5/trunk/products/ERP5/tests/testAccounting.py

Modified: erp5/trunk/products/ERP5/tests/testAccounting.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testAccounting.py?rev=20849&r1=20848&r2=20849&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testAccounting.py (original)
+++ erp5/trunk/products/ERP5/tests/testAccounting.py Wed Apr 30 09:48:52 2008
@@ -168,7 +168,8 @@
     self.organisation_module = self.portal.organisation_module
     self.person_module = self.portal.person_module
     self.currency_module = self.portal.currency_module
-    self.section = self.organisation_module.my_organisation
+    if not hasattr(self, 'section'):
+      self.section = getattr(self.organisation_module, 'my_organisation', None)
     
     # make sure documents are validated
     for module in (self.account_module, self.organisation_module,
@@ -177,12 +178,14 @@
         doc.validate()
 
     # and the preference enabled
-    pref = self.portal.portal_preferences.accounting_zuite_preference
-    pref.manage_addLocalRoles(self.username, ('Auditor', ))
-    # Make sure _aq_dynamic is called before calling the workflow method
-    # otherwise .enable might not been wrapped yet. This happen in --load
-    pref._aq_dynamic('hack')
-    pref.enable()
+    pref = self.portal.portal_preferences._getOb(
+                  'accounting_zuite_preference', None)
+    if pref is not None:
+      pref.manage_addLocalRoles(self.username, ('Auditor', ))
+      # Make sure _aq_dynamic is called before calling the workflow method
+      # otherwise .enable might not been wrapped yet. This happen in --load
+      pref._aq_dynamic('hack')
+      pref.enable()
     
     # and all this available to catalog
     get_transaction().commit()
@@ -201,8 +204,9 @@
     self.organisation_module.manage_delObjects([x for x in 
           self.accounting_module.objectIds() if x not in organisation_list])
     for organisation_id in organisation_list:
-      organisation = self.organisation_module._getOb(organisation_id)
-      organisation.manage_delObjects([x.getId() for x in
+      organisation = self.organisation_module._getOb(organisation_id, None)
+      if organisation is not None:
+        organisation.manage_delObjects([x.getId() for x in
                 organisation.objectValues(
                   portal_type=('Accounting Period', 'Bank Account'))])
     self.person_module.manage_delObjects([x for x in 




More information about the Erp5-report mailing list