Commit 48b290eb authored by Sebastien Robin's avatar Sebastien Robin

improvement of 3 unit tests, some cases where missing

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@8105 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 938f6751
......@@ -105,7 +105,7 @@ class TestERP5BankingCounterRendering(TestERP5BankingMixin, ERP5TypeTestCase):
, 'erp5_accounting'
, 'erp5_banking_core' # erp5_banking_core contains all generic methods for banking
, 'erp5_banking_inventory'
, 'erp5_banking_cash'
, 'erp5_banking_cash' # erp5_banking_cash contains all method for counter rendering
)
def getCounterRenderingModule(self):
......@@ -137,13 +137,13 @@ class TestERP5BankingCounterRendering(TestERP5BankingMixin, ERP5TypeTestCase):
inventory_dict_line_1 = {'id' : 'inventory_line_1',
'resource': self.billet_10000,
'variation_id': ('emission_letter', 'cash_status', 'variation'),
'variation_value': ('emission_letter/p', 'cash_status/valid') + self.variation_list,
'variation_value': ('emission_letter/p', 'cash_status/not_defined') + self.variation_list,
'quantity': self.quantity_10000}
inventory_dict_line_2 = {'id' : 'inventory_line_2',
'resource': self.piece_200,
'variation_id': ('emission_letter', 'cash_status', 'variation'),
'variation_value': ('emission_letter/p', 'cash_status/valid') + self.variation_list,
'variation_value': ('emission_letter/p', 'cash_status/not_defined') + self.variation_list,
'quantity': self.quantity_200}
line_list = [inventory_dict_line_1, inventory_dict_line_2]
......@@ -231,7 +231,7 @@ class TestERP5BankingCounterRendering(TestERP5BankingMixin, ERP5TypeTestCase):
"""
# create the counter rendering line
self.addCashLineToDelivery(self.counter_rendering, 'valid_line_1', 'Cash Delivery Line', self.billet_10000,
('emission_letter', 'cash_status', 'variation'), ('emission_letter/p', 'cash_status/valid') + self.variation_list,
('emission_letter', 'cash_status', 'variation'), ('emission_letter/p', 'cash_status/not_defined') + self.variation_list,
self.quantity_10000)
# execute tic
self.stepTic()
......@@ -252,7 +252,7 @@ class TestERP5BankingCounterRendering(TestERP5BankingMixin, ERP5TypeTestCase):
# now check for each variation (years 1992 and 2003)
for variation in self.variation_list:
# get the delivery cell
cell = self.valid_line_1.getCell('emission_letter/p', variation, 'cash_status/valid')
cell = self.valid_line_1.getCell('emission_letter/p', variation, 'cash_status/not_defined')
# chek portal types
self.assertEqual(cell.getPortalType(), 'Cash Delivery Cell')
# check the banknote of the cell is banknote of 10000
......@@ -289,7 +289,7 @@ class TestERP5BankingCounterRendering(TestERP5BankingMixin, ERP5TypeTestCase):
"""
# create the line
self.addCashLineToDelivery(self.counter_rendering, 'valid_line_2', 'Cash Delivery Line', self.piece_200,
('emission_letter', 'cash_status', 'variation'), ('emission_letter/p', 'cash_status/valid') + self.variation_list,
('emission_letter', 'cash_status', 'variation'), ('emission_letter/p', 'cash_status/not_defined') + self.variation_list,
self.quantity_200)
# execute tic
self.stepTic()
......@@ -309,7 +309,7 @@ class TestERP5BankingCounterRendering(TestERP5BankingMixin, ERP5TypeTestCase):
self.assertEqual(len(self.valid_line_2.objectValues()), 2)
for variation in self.variation_list:
# get the delivery cell
cell = self.valid_line_2.getCell('emission_letter/p', variation, 'cash_status/valid')
cell = self.valid_line_2.getCell('emission_letter/p', variation, 'cash_status/not_defined')
# check the portal type
self.assertEqual(cell.getPortalType(), 'Cash Delivery Cell')
if cell.getId() == 'movement_0_0_0':
......@@ -330,7 +330,7 @@ class TestERP5BankingCounterRendering(TestERP5BankingMixin, ERP5TypeTestCase):
# create a line in which quanity of banknotes of 5000 is higher that quantity available at source
# here create a line with 24 (11+13) banknotes of 500 although the vault usual_cash has no banknote of 5000
self.addCashLineToDelivery(self.counter_rendering, 'invalid_line', 'Cash Delivery Line', self.billet_5000,
('emission_letter', 'cash_status', 'variation'), ('emission_letter/p', 'cash_status/valid') + self.variation_list,
('emission_letter', 'cash_status', 'variation'), ('emission_letter/p', 'cash_status/not_defined') + self.variation_list,
self.quantity_5000)
# execute tic
self.stepTic()
......@@ -452,6 +452,11 @@ class TestERP5BankingCounterRendering(TestERP5BankingMixin, ERP5TypeTestCase):
# check len of len workflow history is 6
self.assertEqual(len(workflow_history), 6)
def stepCheckBaobabDestination(self, sequence=None, sequence_list=None, **kwd):
"""
Check destination vault equal site/testsite/paris/surface/caisse_courante/encaisse_des_billets_et_monnaies
"""
self.assertEqual(self.counter_rendering.getBaobabDestination(), 'site/testsite/paris/surface/caisse_courante/encaisse_des_billets_et_monnaies')
def stepCheckSourceDebit(self, sequence=None, sequence_list=None, **kwd):
"""
......@@ -490,6 +495,7 @@ class TestERP5BankingCounterRendering(TestERP5BankingMixin, ERP5TypeTestCase):
# define the sequence
sequence_string = 'Tic CheckObjects Tic CheckInitialInventory CheckSource CheckDestination ' \
+ 'CreateCounterRendering ' \
+ 'Tic CheckBaobabDestination ' \
+ 'CreateValidLine1 CheckSubTotal ' \
+ 'CreateValidLine2 CheckTotal ' \
+ 'CheckSource CheckDestination ' \
......
......@@ -105,7 +105,7 @@ class TestERP5BankingMonetaryRecall(TestERP5BankingMixin, ERP5TypeTestCase):
, 'erp5_accounting'
, 'erp5_banking_core' # erp5_banking_core contains all generic methods for banking
, 'erp5_banking_inventory'
, 'erp5_banking_cash'
, 'erp5_banking_cash' # erp5_banking_cash contains all method for monetary recall
)
def getMonetaryRecallModule(self):
......@@ -236,7 +236,7 @@ class TestERP5BankingMonetaryRecall(TestERP5BankingMixin, ERP5TypeTestCase):
Create the monetary recall line 1 with banknotes of 10000 and check it has been well created
"""
# create the monetary recall line
self.addCashLineToDelivery(self.monetary_recall, 'valid_line_1', 'Cash Delivery Line', self.billet_10000,
self.addCashLineToDelivery(self.monetary_recall, 'valid_line_1', 'Monetary Recall Line', self.billet_10000,
('emission_letter', 'cash_status', 'variation'), ('emission_letter/p', 'cash_status/cancelled') + self.variation_list,
self.quantity_10000)
# execute tic
......@@ -246,7 +246,7 @@ class TestERP5BankingMonetaryRecall(TestERP5BankingMixin, ERP5TypeTestCase):
# get the monetary recall line
self.valid_line_1 = getattr(self.monetary_recall, 'valid_line_1')
# check its portal type
self.assertEqual(self.valid_line_1.getPortalType(), 'Cash Delivery Line')
self.assertEqual(self.valid_line_1.getPortalType(), 'Monetary Recall Line')
# check the resource is banknotes of 10000
self.assertEqual(self.valid_line_1.getResourceValue(), self.billet_10000)
# chek the value of the banknote
......@@ -260,7 +260,7 @@ class TestERP5BankingMonetaryRecall(TestERP5BankingMixin, ERP5TypeTestCase):
# get the delivery cell
cell = self.valid_line_1.getCell('emission_letter/p', variation, 'cash_status/cancelled')
# chek portal types
self.assertEqual(cell.getPortalType(), 'Cash Delivery Cell')
self.assertEqual(cell.getPortalType(), 'Monetary Recall Cell')
# check the banknote of the cell is banknote of 10000
self.assertEqual(cell.getResourceValue(), self.billet_10000)
# check the source vault is cash
......@@ -294,7 +294,7 @@ class TestERP5BankingMonetaryRecall(TestERP5BankingMixin, ERP5TypeTestCase):
Create the monetary recall line 2 wiht coins of 200 and check it has been well created
"""
# create the line
self.addCashLineToDelivery(self.monetary_recall, 'valid_line_2', 'Cash Delivery Line', self.piece_200,
self.addCashLineToDelivery(self.monetary_recall, 'valid_line_2', 'Monetary Recall Line', self.piece_200,
('emission_letter', 'cash_status', 'variation'), ('emission_letter/p', 'cash_status/cancelled') + self.variation_list,
self.quantity_200)
# execute tic
......@@ -304,7 +304,7 @@ class TestERP5BankingMonetaryRecall(TestERP5BankingMixin, ERP5TypeTestCase):
# get the second monetary recall line
self.valid_line_2 = getattr(self.monetary_recall, 'valid_line_2')
# check portal types
self.assertEqual(self.valid_line_2.getPortalType(), 'Cash Delivery Line')
self.assertEqual(self.valid_line_2.getPortalType(), 'Monetary Recall Line')
# check the resource is coin of 200
self.assertEqual(self.valid_line_2.getResourceValue(), self.piece_200)
# check the value of coin
......@@ -317,7 +317,7 @@ class TestERP5BankingMonetaryRecall(TestERP5BankingMixin, ERP5TypeTestCase):
# get the delivery cell
cell = self.valid_line_2.getCell('emission_letter/p', variation, 'cash_status/cancelled')
# check the portal type
self.assertEqual(cell.getPortalType(), 'Cash Delivery Cell')
self.assertEqual(cell.getPortalType(), 'Monetary Recall Cell')
if cell.getId() == 'movement_0_0_0':
# check the quantity for coin for year 1992 is 5
self.assertEqual(cell.getQuantity(), 5.0)
......@@ -335,7 +335,7 @@ class TestERP5BankingMonetaryRecall(TestERP5BankingMixin, ERP5TypeTestCase):
"""
# create a line in which quanity of banknotes of 5000 is higher that quantity available at source
# here create a line with 24 (11+13) banknotes of 500 although the vault cash has no banknote of 5000
self.addCashLineToDelivery(self.monetary_recall, 'invalid_line', 'Cash Delivery Line', self.billet_5000,
self.addCashLineToDelivery(self.monetary_recall, 'invalid_line', 'Monetary Recall Line', self.billet_5000,
('emission_letter', 'cash_status', 'variation'), ('emission_letter/p', 'cash_status/cancelled') + self.variation_list,
self.quantity_5000)
# execute tic
......@@ -369,6 +369,7 @@ class TestERP5BankingMonetaryRecall(TestERP5BankingMixin, ERP5TypeTestCase):
self.assertEqual(len(workflow_history), 2)
# check we get an "Insufficient balance" message in the workflow history because of the invalid line
msg = workflow_history[-1]['error_message']
#import pdb;pdb.set_trace()
self.assertEqual('Insufficient Balance.', "%s" %(msg,))
......@@ -484,6 +485,18 @@ class TestERP5BankingMonetaryRecall(TestERP5BankingMixin, ERP5TypeTestCase):
self.assertEqual(self.simulation_tool.getFutureInventory(node=self.counter.getRelativeUrl(), resource = self.piece_200.getRelativeUrl()), 12.0)
def stepCheckCashDeliveryLine(self, sequence=None, sequence_list=None):
"""
Check the cash delivery line
"""
variation = 'variation/2003'
# get the delivery cell
cell = self.valid_line_1.getCell('emission_letter/p', variation, 'cash_status/cancelled')
# check the destination variation text is redefine on destination
#import pdb;pdb.set_trace()
self.assertEqual(cell.getBaobabDestinationVariationText(), 'cash_status/retired\nemission_letter/p\nvariation/2003')
##################################
## Tests
##################################
......@@ -507,7 +520,7 @@ class TestERP5BankingMonetaryRecall(TestERP5BankingMixin, ERP5TypeTestCase):
+ 'CheckSourceDebitPlanned CheckDestinationCreditPlanned ' \
+ 'CheckSourceDebitPlanned CheckDestinationCreditPlanned ' \
+ 'DeliverMonetaryRecall ' \
+ 'CheckSourceDebit CheckDestinationCredit '
+ 'CheckSourceDebit CheckDestinationCredit CheckCashDeliveryLine '
sequence_list.addSequenceString(sequence_string)
# play the sequence
sequence_list.play(self)
......
......@@ -36,7 +36,6 @@ from Products.ERP5Type.tests.Sequence import SequenceList
from Products.DCWorkflow.DCWorkflow import Unauthorized, ValidationFailed
from Testing.ZopeTestCase.PortalTestCase import PortalTestCase
from Products.ERP5Banking.tests.TestERP5BankingMixin import TestERP5BankingMixin
from zLOG import LOG
# Needed in order to have a log file inside the current folder
os.environ['EVENT_LOG_FILE'] = os.path.join(os.getcwd(), 'zLOG.log')
......@@ -106,7 +105,7 @@ class TestERP5BankingMoneyDepositRendering(TestERP5BankingMixin, ERP5TypeTestCas
, 'erp5_accounting'
, 'erp5_banking_core' # erp5_banking_core contains all generic methods for banking
, 'erp5_banking_inventory'
, 'erp5_banking_cash'
, 'erp5_banking_cash' # erp5_banking_cash contains all method for money deposit rendering
)
def getMoneyDepositRenderingModule(self):
......@@ -138,13 +137,13 @@ class TestERP5BankingMoneyDepositRendering(TestERP5BankingMixin, ERP5TypeTestCas
inventory_dict_line_1 = {'id' : 'inventory_line_1',
'resource': self.billet_10000,
'variation_id': ('emission_letter', 'cash_status', 'variation'),
'variation_value': ('emission_letter/p', 'cash_status/valid') + self.variation_list,
'variation_value': ('emission_letter/p', 'cash_status/not_defined') + self.variation_list,
'quantity': self.quantity_10000}
inventory_dict_line_2 = {'id' : 'inventory_line_2',
'resource': self.piece_200,
'variation_id': ('emission_letter', 'cash_status', 'variation'),
'variation_value': ('emission_letter/p', 'cash_status/valid') + self.variation_list,
'variation_value': ('emission_letter/p', 'cash_status/not_defined') + self.variation_list,
'quantity': self.quantity_200}
line_list = [inventory_dict_line_1, inventory_dict_line_2]
......@@ -204,13 +203,18 @@ class TestERP5BankingMoneyDepositRendering(TestERP5BankingMixin, ERP5TypeTestCas
self.assertEqual(self.simulation_tool.getFutureInventory(node=self.auxiliaire.getRelativeUrl(), resource = self.piece_200.getRelativeUrl()), 0.0)
def stepCheckBaobabDestination(self, sequence=None, sequence_list=None, **kwd):
"""
Check destination vault equal site/testsite/paris/caveau/auxiliaire/encaisse_des_billets_et_monnaies
"""
self.assertEqual(self.money_deposit_rendering.getBaobabDestination(), 'site/testsite/paris/caveau/auxiliaire/encaisse_des_billets_et_monnaies')
def stepCreateMoneyDepositRendering(self, sequence=None, sequence_list=None, **kwd):
"""
Create a money deposit rendering document and check it
"""
# Money deposit rendering has auxiliaire for source, gros_versement for destination, and a price cooreponding to the sum of banknote of 10000 abd coin of 200 ( (2+3) * 1000 + (5+7) * 200 )
LOG('money_deposit_rendering_module.showDict()',0,self.money_deposit_rendering_module.showDict())
self.money_deposit_rendering = self.money_deposit_rendering_module.newContent(id='money_deposit_rendering_1', portal_type='Money Deposit Rendering', source_value=self.gros_versement, source_total_asset_price=52400.0)
# execute tic
self.stepTic()
......@@ -233,7 +237,7 @@ class TestERP5BankingMoneyDepositRendering(TestERP5BankingMixin, ERP5TypeTestCas
"""
# create the money deposit rendering line
self.addCashLineToDelivery(self.money_deposit_rendering, 'valid_line_1', 'Cash Delivery Line', self.billet_10000,
('emission_letter', 'cash_status', 'variation'), ('emission_letter/p', 'cash_status/valid') + self.variation_list,
('emission_letter', 'cash_status', 'variation'), ('emission_letter/p', 'cash_status/not_defined') + self.variation_list,
self.quantity_10000)
# execute tic
self.stepTic()
......@@ -254,7 +258,7 @@ class TestERP5BankingMoneyDepositRendering(TestERP5BankingMixin, ERP5TypeTestCas
# now check for each variation (years 1992 and 2003)
for variation in self.variation_list:
# get the delivery cell
cell = self.valid_line_1.getCell('emission_letter/p', variation, 'cash_status/valid')
cell = self.valid_line_1.getCell('emission_letter/p', variation, 'cash_status/not_defined')
# chek portal types
self.assertEqual(cell.getPortalType(), 'Cash Delivery Cell')
# check the banknote of the cell is banknote of 10000
......@@ -291,7 +295,7 @@ class TestERP5BankingMoneyDepositRendering(TestERP5BankingMixin, ERP5TypeTestCas
"""
# create the line
self.addCashLineToDelivery(self.money_deposit_rendering, 'valid_line_2', 'Cash Delivery Line', self.piece_200,
('emission_letter', 'cash_status', 'variation'), ('emission_letter/p', 'cash_status/valid') + self.variation_list,
('emission_letter', 'cash_status', 'variation'), ('emission_letter/p', 'cash_status/not_defined') + self.variation_list,
self.quantity_200)
# execute tic
self.stepTic()
......@@ -311,7 +315,7 @@ class TestERP5BankingMoneyDepositRendering(TestERP5BankingMixin, ERP5TypeTestCas
self.assertEqual(len(self.valid_line_2.objectValues()), 2)
for variation in self.variation_list:
# get the delivery cell
cell = self.valid_line_2.getCell('emission_letter/p', variation, 'cash_status/valid')
cell = self.valid_line_2.getCell('emission_letter/p', variation, 'cash_status/not_defined')
# check the portal type
self.assertEqual(cell.getPortalType(), 'Cash Delivery Cell')
if cell.getId() == 'movement_0_0_0':
......@@ -332,7 +336,7 @@ class TestERP5BankingMoneyDepositRendering(TestERP5BankingMixin, ERP5TypeTestCas
# create a line in which quanity of banknotes of 5000 is higher that quantity available at source
# here create a line with 24 (11+13) banknotes of 500 although the vault auxiliaire has no banknote of 5000
self.addCashLineToDelivery(self.money_deposit_rendering, 'invalid_line', 'Cash Delivery Line', self.billet_5000,
('emission_letter', 'cash_status', 'variation'), ('emission_letter/p', 'cash_status/valid') + self.variation_list,
('emission_letter', 'cash_status', 'variation'), ('emission_letter/p', 'cash_status/not_defined') + self.variation_list,
self.quantity_5000)
# execute tic
self.stepTic()
......@@ -536,6 +540,7 @@ class TestERP5BankingMoneyDepositRendering(TestERP5BankingMixin, ERP5TypeTestCas
# define the sequence
sequence_string = 'Tic CheckObjects Tic CheckInitialInventory CheckSource CheckDestination ' \
+ 'CreateMoneyDepositRendering ' \
+ 'Tic CheckBaobabDestination ' \
+ 'CreateValidLine1 CheckSubTotal ' \
+ 'CreateValidLine2 CheckTotal ' \
+ 'CheckSource CheckDestination ' \
......
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