Commit 53a90b46 authored by Jérome Perrin's avatar Jérome Perrin

- remove unused imports

- remove quiet/run_all_test and test numbering
- rename test class, this is not a mixin


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26968 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d59f5082
...@@ -26,39 +26,17 @@ ...@@ -26,39 +26,17 @@
# #
############################################################################## ##############################################################################
import unittest import unittest
import os
import transaction import transaction
from DateTime import DateTime from DateTime import DateTime
from zLOG import LOG
from Products.CMFCore.utils import _checkPermission
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import reindex
from Testing import ZopeTestCase
from Products.ERP5Type.tests.Sequence import SequenceList
from Products.DCWorkflow.DCWorkflow import Unauthorized, ValidationFailed
from Products.ERP5.tests.testAccounting import AccountingTestCase from Products.ERP5.tests.testAccounting import AccountingTestCase
from Testing.ZopeTestCase.PortalTestCase import PortalTestCase
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import getSecurityManager
from Products.ERP5Form.Document.Preference import Priority
QUIET = False
run_all_test = True
def printAndLog(msg):
"""
A utility function to print a message
to the standard output and to the LOG
at the same time
"""
msg = str(msg)
ZopeTestCase._print('\n ' + msg)
LOG('Testing... ', 0, msg)
class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): class TestCurrencyExchangeLine(AccountingTestCase, ERP5TypeTestCase):
""" """
Mixin class for unit test of banking operations Test Currency exchange lines.
""" """
username = 'username' username = 'username'
def beforeTearDown(self): def beforeTearDown(self):
...@@ -77,7 +55,7 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): ...@@ -77,7 +55,7 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase):
transaction.commit() transaction.commit()
self.tic() self.tic()
def login(self,name=username, quiet=0, run=run_all_test): def login(self, name=username):
uf = self.getPortal().acl_users uf = self.getPortal().acl_users
uf._doAddUser(self.username, '', ['Assignee', 'Assignor', uf._doAddUser(self.username, '', ['Assignee', 'Assignor',
'Author','Manager'], []) 'Author','Manager'], [])
...@@ -97,12 +75,10 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): ...@@ -97,12 +75,10 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase):
'erp5_accounting_ui_test' 'erp5_accounting_ui_test'
) )
def test_01_CreateCurrencies(self, quiet=0, run=run_all_test): def test_CreateCurrencies(self):
""" """
Create currencies to be used for transactions Create currencies to be used for transactions
""" """
if not run: return
if not quiet: printAndLog('test_01_CreateCurrencies')
module = self.portal.currency_module module = self.portal.currency_module
currency1 = module.newContent(portal_type='Currency') currency1 = module.newContent(portal_type='Currency')
currency1.setTitle('Euro') currency1.setTitle('Euro')
...@@ -126,15 +102,11 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): ...@@ -126,15 +102,11 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase):
self.assertEquals(0, len(currency2.checkConsistency())) self.assertEquals(0, len(currency2.checkConsistency()))
def test_01_UseCurrencyExchangeLineForDestination(self, quiet=0, def test_UseCurrencyExchangeLineForDestination(self):
run=run_all_test):
""" """
Create a currency exchange line for a currency and then Create a currency exchange line for a currency and then
convert destination price using that currency exchange line convert destination price using that currency exchange line
""" """
if not run: return
if not quiet:
printAndLog('test_01_UseCurrencyExchangeLineForDestination')
portal = self.getPortal() portal = self.getPortal()
self.organisation_module = self.portal.organisation_module self.organisation_module = self.portal.organisation_module
self.organisation1 = self.organisation_module.my_organisation self.organisation1 = self.organisation_module.my_organisation
...@@ -181,17 +153,12 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): ...@@ -181,17 +153,12 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase):
round(655.957*line.getQuantity())) round(655.957*line.getQuantity()))
def test_01_CreateEmptyCurrencyExchangeLineForDestination( def test_CreateEmptyCurrencyExchangeLineForDestination(self):
self, quiet=0,run=run_all_test):
""" """
Create empty currency exchange lines for currencies, Create empty currency exchange lines for currencies,
and verify that only the one that matches the criteria will and verify that only the one that matches the criteria will
be selected for the conversion be selected for the conversion
""" """
if not run: return
if not quiet:
printAndLog(
'test_01_CreateEmptyCurrencyExchangeLineForDestination')
portal = self.getPortal() portal = self.getPortal()
self.organisation_module = self.portal.organisation_module self.organisation_module = self.portal.organisation_module
self.organisation1 = self.organisation_module.my_organisation self.organisation1 = self.organisation_module.my_organisation
...@@ -253,16 +220,12 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): ...@@ -253,16 +220,12 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase):
self.assertEquals(line.getDestinationTotalAssetPrice(), self.assertEquals(line.getDestinationTotalAssetPrice(),
round(655.957*line.getQuantity())) round(655.957*line.getQuantity()))
def test_01_UseCurrencyExchangeLineForSource(self, quiet=0, def test_UseCurrencyExchangeLineForSource(self):
run=run_all_test):
""" """
Create a currency exchange line for a currency and then Create a currency exchange line for a currency and then
convert convert
source price using that currency exchange line source price using that currency exchange line
""" """
if not run: return
if not quiet:
printAndLog('test_01_UseCurrencyExchangeLineForSource')
portal = self.getPortal() portal = self.getPortal()
self.organisation_module = self.portal.organisation_module self.organisation_module = self.portal.organisation_module
self.organisation1 = self.organisation_module.my_organisation self.organisation1 = self.organisation_module.my_organisation
...@@ -307,15 +270,11 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): ...@@ -307,15 +270,11 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase):
self.assertEquals(line.getSourceTotalAssetPrice(), self.assertEquals(line.getSourceTotalAssetPrice(),
round(655.957*line.getQuantity())) round(655.957*line.getQuantity()))
def test_01_NoCurrencyExchangeLineForResourceCurrency(self, quiet=0, def test_NoCurrencyExchangeLineForResourceCurrency(self):
run=run_all_test):
""" """
Test that the conversion is not done when there is no currency Test that the conversion is not done when there is no currency
exchange line defined for the date of the transaction exchange line defined for the date of the transaction
""" """
if not run: return
if not quiet:
printAndLog('test_01_NoCurrencyExchangeLineForResource')
portal = self.getPortal() portal = self.getPortal()
self.organisation_module = self.portal.organisation_module self.organisation_module = self.portal.organisation_module
self.organisation1 = self.organisation_module.my_organisation self.organisation1 = self.organisation_module.my_organisation
...@@ -347,8 +306,7 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): ...@@ -347,8 +306,7 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase):
self.assertEquals(line.getDestinationTotalAssetPrice(),None) self.assertEquals(line.getDestinationTotalAssetPrice(),None)
def test_01_DateOfCurrencyExchangeLineNotDateofTransaction(self, quiet=0, def test_DateOfCurrencyExchangeLineNotDateofTransaction(self):
run=run_all_test):
""" """
Test that the conversion is not done when there is the start date Test that the conversion is not done when there is the start date
and the end date of a currency exchange line don't correspond to and the end date of a currency exchange line don't correspond to
...@@ -356,10 +314,6 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): ...@@ -356,10 +314,6 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase):
falls into the validity period of the currency exchange line,the falls into the validity period of the currency exchange line,the
conversion is done conversion is done
""" """
if not run: return
if not quiet:
printAndLog(
'test_01_DateOfCurrencyExchangeLineNotDateofTransaction')
portal = self.getPortal() portal = self.getPortal()
self.organisation_module = self.portal.organisation_module self.organisation_module = self.portal.organisation_module
self.organisation1 = self.organisation_module.my_organisation self.organisation1 = self.organisation_module.my_organisation
...@@ -421,15 +375,11 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): ...@@ -421,15 +375,11 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase):
self.assertEquals(line.getDestinationTotalAssetPrice(), self.assertEquals(line.getDestinationTotalAssetPrice(),
round(655.957*line.getQuantity())) round(655.957*line.getQuantity()))
def test_01_CreateCELWithNoReferenceCurrency( def test_CreateCELWithNoReferenceCurrency(self):
self, quiet=0,run=run_all_test):
""" """
Create a currency exchange line with no reference currency Create a currency exchange line with no reference currency
and verify that the CEL won't apply for the currency and verify that the CEL won't apply for the currency
""" """
if not run: return
if not quiet:
printAndLog('test_01_CreateCELWithNoReferenceCurrency')
portal = self.getPortal() portal = self.getPortal()
self.organisation_module = self.portal.organisation_module self.organisation_module = self.portal.organisation_module
self.organisation1 = self.organisation_module.my_organisation self.organisation1 = self.organisation_module.my_organisation
...@@ -477,15 +427,11 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): ...@@ -477,15 +427,11 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase):
None) None)
def test_01_CreateCELWithNoBasePrice( def test_CreateCELWithNoBasePrice(self):
self, quiet=0,run=run_all_test):
""" """
Create two currency exchange lines with no base and Create two currency exchange lines with no base and
verify that only one of the CEL will apply for the currency verify that only one of the CEL will apply for the currency
""" """
if not run: return
if not quiet:
printAndLog('test_01_CreateCELWithNoBasePrice')
portal = self.getPortal() portal = self.getPortal()
self.organisation_module = self.portal.organisation_module self.organisation_module = self.portal.organisation_module
self.organisation1 = self.organisation_module.my_organisation self.organisation1 = self.organisation_module.my_organisation
...@@ -550,5 +496,5 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase): ...@@ -550,5 +496,5 @@ class TestERP5CurrencyMixin(AccountingTestCase,ERP5TypeTestCase):
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestERP5CurrencyMixin)) suite.addTest(unittest.makeSuite(TestCurrencyExchangeLine))
return suite return suite
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment