From b94cb0133ee1ad3523dd0c2aece4fc4c0c30c86a Mon Sep 17 00:00:00 2001
From: Julien Muchembled <jm@nexedi.com>
Date: Thu, 9 Sep 2010 07:46:27 +0000
Subject: [PATCH] Fix some errors in test(Legacy)ConversionInSimulation

git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/amount_generator@38210 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../Document/InvoiceTransactionSimulationRule.py     |  2 +-
 product/ERP5/tests/testConversionInSimulation.py     | 12 +++++++-----
 .../tests/testLegacyConversionInSimulation.py        |  9 +++++----
 3 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/product/ERP5/Document/InvoiceTransactionSimulationRule.py b/product/ERP5/Document/InvoiceTransactionSimulationRule.py
index 7136935189..9e8a2bcb7a 100644
--- a/product/ERP5/Document/InvoiceTransactionSimulationRule.py
+++ b/product/ERP5/Document/InvoiceTransactionSimulationRule.py
@@ -110,8 +110,8 @@ class InvoiceTransactionRuleMovementGenerator(MovementGeneratorMixin):
       invoice = invoice_line.getExplanationValue()
       resource = invoice.getProperty('resource',
                   invoice.getProperty('price_currency', None))
+    portal = input_movement.getPortalObject()
     if resource is None:
-      portal = input_movement.getPortalObject()
       # search the resource on parents simulation movement's deliveries
       simulation_movement = input_movement
       portal_simulation = portal.portal_simulation
diff --git a/product/ERP5/tests/testConversionInSimulation.py b/product/ERP5/tests/testConversionInSimulation.py
index 6b26933ece..c82c3d2f52 100644
--- a/product/ERP5/tests/testConversionInSimulation.py
+++ b/product/ERP5/tests/testConversionInSimulation.py
@@ -32,7 +32,6 @@ import transaction
 from DateTime import DateTime
 from zLOG import LOG
 from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
-from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
 from Testing import ZopeTestCase
 from Products.ERP5.tests.testAccounting import AccountingTestCase
 from AccessControl.SecurityManagement import newSecurityManager
@@ -51,8 +50,8 @@ def printAndLog(msg):
   ZopeTestCase._print('\n ' + msg)
   LOG('Testing... ', 0, msg)
 
-class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase):
-  
+class TestConversionInSimulation(AccountingTestCase):
+
   username = 'username'
   default_region = "europe/west/france"
   vat_gap = 'fr/pcg/4/44/445/4457/44571'
@@ -120,7 +119,8 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase):
       **kw)
 
   def afterSetUp(self):
-    ERP5TypeTestCase.login(self)
+    super(TestConversionInSimulation, self).afterSetUp()
+    super(TestConversionInSimulation, self).login()
     self.createCategories()
     self.createAndValidateAccounts()
     self.login()
@@ -140,7 +140,8 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase):
                   portal_type='Currency Exchange Line')])
     transaction.commit()
     self.tic()
- 
+    super(TestConversionInSimulation, self).beforeTearDown()
+
   def login(self,name=username, quiet=0, run=run_all_test):
     uf = self.getPortal().acl_users
     uf._doAddUser(self.username, '', ['Assignee', 'Assignor',
@@ -788,6 +789,7 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase):
                                 portal_type='Currency',
                                 title='euro')
     currency.setBaseUnitQuantity(0.01)
+    self.createBusinessProcess(currency)
     transaction.commit()
     self.tic()#execute transaction
     client = self.portal.organisation_module.newContent(
diff --git a/product/ERP5Legacy/tests/testLegacyConversionInSimulation.py b/product/ERP5Legacy/tests/testLegacyConversionInSimulation.py
index 27c319e97a..2a42d64434 100644
--- a/product/ERP5Legacy/tests/testLegacyConversionInSimulation.py
+++ b/product/ERP5Legacy/tests/testLegacyConversionInSimulation.py
@@ -32,7 +32,6 @@ import transaction
 from DateTime import DateTime
 from zLOG import LOG
 from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
-from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
 from Testing import ZopeTestCase
 from Products.ERP5.tests.testAccounting import AccountingTestCase
 from AccessControl.SecurityManagement import newSecurityManager
@@ -51,8 +50,8 @@ def printAndLog(msg):
   ZopeTestCase._print('\n ' + msg)
   LOG('Testing... ', 0, msg)
 
-class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase):
-  
+class TestConversionInSimulation(AccountingTestCase):
+
   username = 'username'
   default_region = "europe/west/france"
   vat_gap = 'fr/pcg/4/44/445/4457/44571'
@@ -128,6 +127,7 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase):
       **kw)
       
   def afterSetUp(self):
+    super(TestConversionInSimulation, self).afterSetUp()
     self.createCategories()
     self.validateRules()
     self.login()
@@ -147,7 +147,8 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase):
                   portal_type='Currency Exchange Line')])
     transaction.commit()
     self.tic()
- 
+    super(TestConversionInSimulation, self).beforeTearDown()
+
   def login(self,name=username, quiet=0, run=run_all_test):
     uf = self.getPortal().acl_users
     uf._doAddUser(self.username, '', ['Assignee', 'Assignor',
-- 
2.30.9