Commit dd0a5652 authored by Aurel's avatar Aurel

rewrite way to generate currency in unit test in order to use the

interaction worklfow defined


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24718 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d2d5c4ec
...@@ -311,45 +311,34 @@ class TestERP5BankingMixin: ...@@ -311,45 +311,34 @@ class TestERP5BankingMixin:
self.tic() self.tic()
def createCurrency(self, id='EUR', title='Euro'): def createCurrency(self, currency_list=(('EUR', 'Euro', 1/650., 'USD'), ('USD', 'Dollar', 650., 'EUR'))):
# create the currency document for euro inside the currency module # create the currency document for euro inside the currency module
currency = self.getCurrencyModule().newContent(id=id, title=title, reference=id) #currency_list = (('EUR', 'Euro', 1/650., 'USD'), ('USD', 'Dollar', 650., 'EUR'))
exchange_line = None # first create currency
if id=='USD': for currency_id, title, base_price, price_currency in currency_list:
# Create an exchange line currency = self.getCurrencyModule().newContent(id=currency_id, title=title, reference=currency_id)
# second, create exchange lines
for currency_id, title, base_price, price_currency in currency_list:
currency = self.getCurrencyModule()[currency_id]
exchange_line = None
exchange_line = currency.newContent(portal_type='Currency Exchange Line', exchange_line = currency.newContent(portal_type='Currency Exchange Line',
start_date='01/01/1900',stop_date='01/01/2900', start_date='01/01/1900',stop_date='01/01/2900',
price_currency='currency_module/EUR', base_price=base_price,
base_price=652,
currency_exchange_type_list=['currency_exchange_type/sale', currency_exchange_type_list=['currency_exchange_type/sale',
'currency_exchange_type/purchase', 'currency_exchange_type/purchase',
'currency_exchange_type/transfer'], 'currency_exchange_type/transfer'],
) )
exchange_line.setPriceCurrencyValue(self.getCurrencyModule()[currency_id])
cell_list = exchange_line.objectValues() cell_list = exchange_line.objectValues()
self.assertEquals(len(cell_list),3) self.assertEquals(len(cell_list),3)
for cell in cell_list: for cell in cell_list:
cell.setBasePrice(650.0) cell.setBasePrice(base_price)
elif id == "EUR":
# Create an exchange line
exchange_line = currency.newContent(portal_type='Currency Exchange Line',
start_date='01/01/1900',stop_date='01/01/2900',
price_currency='currency_module/USD',
base_price=1./652,
currency_exchange_type_list=['currency_exchange_type/sale',
'currency_exchange_type/purchase',
'currency_exchange_type/transfer'],
)
cell_list = exchange_line.objectValues()
self.assertEquals(len(cell_list),3)
for cell in cell_list:
cell.setBasePrice(1./650.0)
if exchange_line is not None:
exchange_line.confirm() exchange_line.confirm()
exchange_line.validate() exchange_line.validate()
return currency
def createBanknotesAndCoins(self): def createBanknotesAndCoins(self):
""" """
...@@ -444,7 +433,8 @@ class TestERP5BankingMixin: ...@@ -444,7 +433,8 @@ class TestERP5BankingMixin:
# get the currency cash module # get the currency cash module
self.currency_cash_module = self.getCurrencyCashModule() self.currency_cash_module = self.getCurrencyCashModule()
# Create Resources Document (Banknotes & Coins) # Create Resources Document (Banknotes & Coins)
self.currency_1 = self.createCurrency() self.createCurrency()
self.currency_1 = self.currency_module['EUR']
# create document for banknote of 10000 euros from years 1992 and 2003 # create document for banknote of 10000 euros from years 1992 and 2003
self.billet_10000 = self.currency_cash_module.newContent(id='billet_10000', self.billet_10000 = self.currency_cash_module.newContent(id='billet_10000',
portal_type='Banknote', base_price=10000, portal_type='Banknote', base_price=10000,
...@@ -476,7 +466,7 @@ class TestERP5BankingMixin: ...@@ -476,7 +466,7 @@ class TestERP5BankingMixin:
price_currency_value=self.currency_1, variation_list=('1992', '2003'), price_currency_value=self.currency_1, variation_list=('1992', '2003'),
quantity_unit_value=self.unit) quantity_unit_value=self.unit)
# Create Resources Document (Banknotes & Coins) in USD # Create Resources Document (Banknotes & Coins) in USD
self.currency_2 = self.createCurrency(id='USD',title='USD') self.currency_2 = self.currency_module['USD']
# create document for banknote of 100 USD # create document for banknote of 100 USD
self.usd_billet_100 = self.currency_cash_module.newContent(id='usd_billet_100', self.usd_billet_100 = self.currency_cash_module.newContent(id='usd_billet_100',
portal_type='Banknote', base_price=100, portal_type='Banknote', base_price=100,
......
...@@ -79,7 +79,8 @@ class TestERP5BankingInventory(TestERP5BankingMixin, ERP5TypeTestCase): ...@@ -79,7 +79,8 @@ class TestERP5BankingInventory(TestERP5BankingMixin, ERP5TypeTestCase):
self.inventory_module = self.getBankAccountInventoryModule() self.inventory_module = self.getBankAccountInventoryModule()
self.createManagerAndLogin() self.createManagerAndLogin()
self.createFunctionGroupSiteCategory(no_site=1) self.createFunctionGroupSiteCategory(no_site=1)
self.currency_1 = self.createCurrency() self.createCurrency()
self.currency_1 = self.currency_module['EUR']
# Create a person and a bank account to test # Create a person and a bank account to test
self.person_1 = self.createPerson(id='person_1', self.person_1 = self.createPerson(id='person_1',
first_name='toto', first_name='toto',
......
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