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

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Dec 12 17:47:53 CET 2006


Author: jerome
Date: Tue Dec 12 17:47:51 2006
New Revision: 11700

URL: http://svn.erp5.org?rev=11700&view=rev
Log:
added utility method to allow Accounting Transaction deletion
create enties with a title to ease debugging
add a beforeTearDown method to do some cleanup


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=11700&r1=11699&r2=11700&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testAccounting.py (original)
+++ erp5/trunk/products/ERP5/tests/testAccounting.py Tue Dec 12 17:47:51 2006
@@ -43,12 +43,31 @@
 from AccessControl.SecurityManagement import newSecurityManager
 from zLOG import LOG
 from Products.ERP5Type.tests.Sequence import Sequence, SequenceList
+from Products.ERP5.Document.Delivery import Delivery
 from DateTime import DateTime
 
 SOURCE = 'source'
 DESTINATION = 'destination'
 RUN_ALL_TESTS = 1
 QUIET = 1
+
+
+def manage_beforeDelete(self, item, container):
+  Delivery.manage_beforeDelete(self, item, container)
+
+def allowAccountingTransactionDeletion():
+  from Products.ERP5.Document.AccountingTransaction \
+      import AccountingTransaction
+  old_manage_beforeDelete = AccountingTransaction.manage_beforeDelete 
+  AccountingTransaction.manage_beforeDelete = manage_beforeDelete
+  try:
+    from Products.ERP5Type.Document.AccountingTransaction \
+        import AccountingTransaction
+    AccountingTransaction.manage_beforeDelete = manage_beforeDelete
+  except ImportError:
+    # ERP5Type version of this class is only available when ERP5Type document
+    # registry has been initialized.
+    pass
 
 class TestAccounting(ERP5TypeTestCase):
   """Test Accounting. """
@@ -111,6 +130,17 @@
     self.workflow_tool.doActionFor(self.pref, 'enable_action')
 
     self.login()
+
+  def beforeTearDown(self):
+    """Cleanup for next test.
+    All tests uses the same accounts and same entities, so we just cleanup
+    accounting module and simulation. """
+    get_transaction().abort()
+    allowAccountingTransactionDeletion()
+    for folder in (self.accounting_module, self.portal.portal_simulation):
+      folder.manage_delObjects([i for i in folder.objectIds()])
+    get_transaction().commit()
+    self.tic()
 
   def login(self) :
     """sets the security manager"""
@@ -157,14 +187,17 @@
   def createEntities(self):
     """Create entities. """
     self.client = self.getOrganisationModule().newContent(
+        title = 'Client',
         portal_type = self.organisation_portal_type,
         group = "client",
         price_currency = "currency_module/USD")
     self.vendor = self.getOrganisationModule().newContent(
+        title = 'Vendor',
         portal_type = self.organisation_portal_type,
         group = "vendor/sub1",
         price_currency = "currency_module/EUR")
     self.other_vendor = self.getOrganisationModule().newContent(
+        title = 'Other Vendor',
         portal_type = self.organisation_portal_type,
         group = "vendor/sub2",
         price_currency = "currency_module/EUR")




More information about the Erp5-report mailing list