From 7195c1940f18d01e687042983343f996ce54b693 Mon Sep 17 00:00:00 2001 From: Sebastien Robin <seb@nexedi.com> Date: Fri, 4 May 2007 10:03:17 +0000 Subject: [PATCH] add test for banknotes with cash status mixed git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14350 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../testERP5BankingCashClassification.py | 134 +++++++++++++++--- 1 file changed, 118 insertions(+), 16 deletions(-) diff --git a/product/ERP5Banking/tests/testERP5BankingCashClassification.py b/product/ERP5Banking/tests/testERP5BankingCashClassification.py index 1698e0081f..3fb03468ef 100755 --- a/product/ERP5Banking/tests/testERP5BankingCashClassification.py +++ b/product/ERP5Banking/tests/testERP5BankingCashClassification.py @@ -101,8 +101,16 @@ class TestERP5BankingCashClassification(TestERP5BankingMixin, ERP5TypeTestCase): 'variation_value': ('emission_letter/not_defined', 'cash_status/to_sort') + self.variation_list, 'quantity': self.quantity_5000} + inventory_dict_line_4 = {'id' : 'inventory_line_4', + 'resource': self.billet_100, + 'variation_id': ('emission_letter', 'cash_status', 'variation'), + 'variation_value': ('emission_letter/not_defined', 'cash_status/to_sort') + self.variation_list, + 'quantity': self.quantity_100} + - line_list = [inventory_dict_line_1, inventory_dict_line_2, inventory_dict_line_3] + + line_list = [inventory_dict_line_1, inventory_dict_line_2, inventory_dict_line_3, + inventory_dict_line_4] self.encaisse_tri = self.paris.surface.salle_tri.encaisse_des_billets_recus_pour_ventilation.madrid self.encaisse_reserve = self.paris.caveau.reserve.encaisse_des_billets_et_monnaies self.encaisse_aux_externe = self.paris.caveau.auxiliaire.encaisse_des_externes @@ -153,6 +161,9 @@ class TestERP5BankingCashClassification(TestERP5BankingMixin, ERP5TypeTestCase): # check we have 5 banknotes of 10000 in encaisse_paris self.assertEqual(self.simulation_tool.getCurrentInventory(node=self.encaisse_tri.getRelativeUrl(), resource = self.billet_10000.getRelativeUrl()), 5.0) self.assertEqual(self.simulation_tool.getFutureInventory(node=self.encaisse_tri.getRelativeUrl(), resource = self.billet_10000.getRelativeUrl()), 5.0) + # check we have 10 banknotes of 100 in encaisse_paris + self.assertEqual(self.simulation_tool.getCurrentInventory(node=self.encaisse_tri.getRelativeUrl(), resource = self.billet_100.getRelativeUrl()), 10.0) + self.assertEqual(self.simulation_tool.getFutureInventory(node=self.encaisse_tri.getRelativeUrl(), resource = self.billet_100.getRelativeUrl()), 10.0) # check we have 12 coin of 200 in encaisse_paris self.assertEqual(self.simulation_tool.getCurrentInventory(node=self.encaisse_tri.getRelativeUrl(), resource = self.billet_200.getRelativeUrl()), 12.0) self.assertEqual(self.simulation_tool.getFutureInventory(node=self.encaisse_tri.getRelativeUrl(), resource = self.billet_200.getRelativeUrl()), 12.0) @@ -194,6 +205,14 @@ class TestERP5BankingCashClassification(TestERP5BankingMixin, ERP5TypeTestCase): self.assertEqual(self.simulation_tool.getCurrentInventory(node=self.encaisse_aux_bm.getRelativeUrl(), resource = self.billet_200.getRelativeUrl()), 0.0) self.assertEqual(self.simulation_tool.getFutureInventory(node=self.encaisse_aux_bm.getRelativeUrl(), resource = self.billet_200.getRelativeUrl()), 0.0) + # check we don't have coins of 100 + self.assertEqual(self.simulation_tool.getCurrentInventory(node=self.encaisse_reserve.getRelativeUrl(), resource = self.billet_100.getRelativeUrl()), 0.0) + self.assertEqual(self.simulation_tool.getFutureInventory(node=self.encaisse_reserve.getRelativeUrl(), resource = self.billet_100.getRelativeUrl()), 0.0) + self.assertEqual(self.simulation_tool.getCurrentInventory(node=self.encaisse_aux_externe.getRelativeUrl(), resource = self.billet_100.getRelativeUrl()), 0.0) + self.assertEqual(self.simulation_tool.getFutureInventory(node=self.encaisse_aux_externe.getRelativeUrl(), resource = self.billet_100.getRelativeUrl()), 0.0) + self.assertEqual(self.simulation_tool.getCurrentInventory(node=self.encaisse_aux_bm.getRelativeUrl(), resource = self.billet_100.getRelativeUrl()), 0.0) + self.assertEqual(self.simulation_tool.getFutureInventory(node=self.encaisse_aux_bm.getRelativeUrl(), resource = self.billet_100.getRelativeUrl()), 0.0) + # check for banknote of 5000 self.assertEqual(self.simulation_tool.getCurrentInventory(node=self.encaisse_reserve.getRelativeUrl(), resource = self.billet_5000.getRelativeUrl()), 0.0) self.assertEqual(self.simulation_tool.getFutureInventory(node=self.encaisse_reserve.getRelativeUrl(), resource = self.billet_5000.getRelativeUrl()), 0.0) @@ -234,7 +253,7 @@ class TestERP5BankingCashClassification(TestERP5BankingMixin, ERP5TypeTestCase): self.assertEqual(self.cash_sorting.getDestination(), None) - def stepCreateThreeValidIncomingLine(self, sequence=None, sequence_list=None, **kwd): + def stepCreateFourValidIncomingLine(self, sequence=None, sequence_list=None, **kwd): """ Create the cash sorting incoming line with banknotes of 10000 and check it has been well created """ @@ -359,17 +378,56 @@ class TestERP5BankingCashClassification(TestERP5BankingMixin, ERP5TypeTestCase): else: self.fail('Wrong cell created : %s' % cell.getId()) + self.addCashLineToDelivery(self.cash_sorting, 'valid_incoming_line_4', 'Incoming Cash Sorting Line', self.billet_100, + ('emission_letter', 'cash_status', 'variation'), ('emission_letter/not_defined', 'cash_status/to_sort') + self.variation_list, + self.quantity_100) + # execute tic + self.stepTic() + # check there is only one line created + self.assertEqual(len(self.cash_sorting.objectValues()), 4) + # get the cash sorting line + self.valid_incoming_line = getattr(self.cash_sorting, 'valid_incoming_line_4') + # check its portal type + self.assertEqual(self.valid_incoming_line.getPortalType(), 'Incoming Cash Sorting Line') + # check the resource is banknotes of 10000 + self.assertEqual(self.valid_incoming_line.getResourceValue(), self.billet_100) + # chek the value of the banknote + self.assertEqual(self.valid_incoming_line.getPrice(), 100.0) + # check the unit of banknote + self.assertEqual(self.valid_incoming_line.getQuantityUnit(), 'unit') + # check we have two delivery cells: (one for year 1992 and one for 2003) + self.assertEqual(len(self.valid_incoming_line.objectValues()), 2) + # now check for each variation (years 1992 and 2003) + for variation in self.variation_list: + # get the delivery cell + cell = self.valid_incoming_line.getCell('emission_letter/not_defined', variation, 'cash_status/to_sort') + # chek portal types + self.assertEqual(cell.getPortalType(), 'Cash Delivery Cell') + # check the banknote of the cell is banknote of 10000 + self.assertEqual(cell.getResourceValue(), self.billet_100) + # check the source vault is encaisse_paris + self.assertEqual(cell.getSourceValue(), self.encaisse_tri) + # check the destination vault is encaisse_aux_externe + self.assertEqual(cell.getDestinationValue(), None) + if cell.getId() == 'movement_0_0_0': + # check the quantity of banknote for year 1992 is 2 + self.assertEqual(cell.getQuantity(), 4.0) + elif cell.getId() == 'movement_0_1_0': + # check the quantity of banknote for year 2003 is 3 + self.assertEqual(cell.getQuantity(), 6.0) + else: + self.fail('Wrong cell created : %s' % cell.getId()) def stepCheckSubTotal(self, sequence=None, sequence_list=None, **kwd): """ Check the amount after the creation of cash sorting line 1 """ # Check number of lines - self.assertEqual(len(self.cash_sorting.objectValues()), 3) + self.assertEqual(len(self.cash_sorting.objectValues()), 4) # Check quantity of banknotes (2 for 1992 and 3 for 2003) - self.assertEqual(self.cash_sorting.getTotalQuantity(deliveryLineType="Incoming Cash Sorting Line"), 41.0) + self.assertEqual(self.cash_sorting.getTotalQuantity(deliveryLineType="Incoming Cash Sorting Line"), 51.0) # Check the total price - self.assertEqual(self.cash_sorting.getTotalPrice(deliveryLineType="Incoming Cash Sorting Line"), 10000 * 5.0 + 200 * 12.0 + 5000 * 24.0) + self.assertEqual(self.cash_sorting.getTotalPrice(deliveryLineType="Incoming Cash Sorting Line"), 10000 * 5.0 + 100 * 10.0 + 200 * 12.0 + 5000 * 24.0) def stepCreateValidOutgoingLineForInternalBanknote(self, sequence=None, sequence_list=None, **kwd): @@ -383,7 +441,7 @@ class TestERP5BankingCashClassification(TestERP5BankingMixin, ERP5TypeTestCase): # execute tic self.stepTic() # check the number of lines (line1 + line2) - self.assertEqual(len(self.cash_sorting.objectValues()), 4) + self.assertEqual(len(self.cash_sorting.objectValues()), 5) # get the second cash sorting line self.valid_outgoing_line = getattr(self.cash_sorting, 'valid_outgoing_line_1') # check portal types @@ -422,7 +480,7 @@ class TestERP5BankingCashClassification(TestERP5BankingMixin, ERP5TypeTestCase): # execute tic self.stepTic() # check the number of lines (line1 + line2) - self.assertEqual(len(self.cash_sorting.objectValues()), 5) + self.assertEqual(len(self.cash_sorting.objectValues()), 6) # get the second cash sorting line self.valid_outgoing_line = getattr(self.cash_sorting, 'valid_outgoing_line_2') # check portal types @@ -449,6 +507,43 @@ class TestERP5BankingCashClassification(TestERP5BankingMixin, ERP5TypeTestCase): else: self.fail('Wrong cell created : %s' % cell.getId()) + def stepCreateValidOutgoingLineForMixed(self, sequence=None, sequence_list=None, **kwd): + """ + Create the cash sorting outgoing line wiht banknotes of 200 and check it has been well created + """ + # create the line + self.addCashLineToDelivery(self.cash_sorting, 'valid_outgoing_line_4', 'Outgoing Cash Sorting Line', self.billet_100, + ('emission_letter', 'cash_status', 'variation'), ('emission_letter/not_defined', 'cash_status/mixed') + self.variation_list, + self.quantity_100) + # execute tic + self.stepTic() + # check the number of lines (line1 + line2) + self.assertEqual(len(self.cash_sorting.objectValues()), 8) + # get the second cash sorting line + self.valid_outgoing_line = getattr(self.cash_sorting, 'valid_outgoing_line_4') + # check portal types + self.assertEqual(self.valid_outgoing_line.getPortalType(), 'Outgoing Cash Sorting Line') + # check the resource is coin of 200 + self.assertEqual(self.valid_outgoing_line.getResourceValue(), self.billet_100) + # check the value of coin + self.assertEqual(self.valid_outgoing_line.getPrice(), 100.0) + # check the unit of coin + self.assertEqual(self.valid_outgoing_line.getQuantityUnit(), 'unit') + # check we have two delivery cells: (one for year 1992 and one for 2003) + self.assertEqual(len(self.valid_outgoing_line.objectValues()), 2) + for variation in self.variation_list: + # get the delivery cell + cell = self.valid_outgoing_line.getCell('emission_letter/not_defined', variation, 'cash_status/mixed') + # check the portal type + self.assertEqual(cell.getPortalType(), 'Outgoing Cash Sorting Cell') + if cell.getId() == 'movement_0_0_0': + # check the quantity for coin for year 1992 is 5 + self.assertEqual(cell.getQuantity(), 4.0) + elif cell.getId() == 'movement_0_1_0': + # check the quantity for coin for year 2003 is 7 + self.assertEqual(cell.getQuantity(), 6.0) + else: + self.fail('Wrong cell created : %s' % cell.getId()) def stepCreateValidOutgoingLineForInternalAndCancelledBanknote(self, sequence=None, sequence_list=None, **kwd): """ @@ -461,7 +556,7 @@ class TestERP5BankingCashClassification(TestERP5BankingMixin, ERP5TypeTestCase): # execute tic self.stepTic() # check the number of lines (line1 + line2) - self.assertEqual(len(self.cash_sorting.objectValues()), 6) + self.assertEqual(len(self.cash_sorting.objectValues()), 7) # get the second cash sorting line self.valid_outgoing_line = getattr(self.cash_sorting, 'valid_outgoing_line_3') # check portal types @@ -494,19 +589,19 @@ class TestERP5BankingCashClassification(TestERP5BankingMixin, ERP5TypeTestCase): Check the total after the creation of the two cash sorting lines """ # Check number of lines (line1 + line2) - self.assertEqual(len(self.cash_sorting.objectValues()), 6) + self.assertEqual(len(self.cash_sorting.objectValues()), 8) # Check quantity, banknotes : 2 for 1992 and 3 for 2003, coin : 5 for 1992 and 7 for 2003 - self.assertEqual(self.cash_sorting.getTotalQuantity(), (5.0 + 12.0 + 24.0) * 2.0) + self.assertEqual(self.cash_sorting.getTotalQuantity(), (5.0 + 10.0 + 12.0 + 24.0) * 2.0) # check the total price - self.assertEqual(self.cash_sorting.getTotalPrice(), (10000 * 5.0 + 200 * 12.0 + 5000 * 24.0) * 2.0) + self.assertEqual(self.cash_sorting.getTotalPrice(), (10000 * 5.0 + 100 * 10.0 + 200 * 12.0 + 5000 * 24.0) * 2.0) def stepOrderCashSorting(self, sequence=None, sequence_list=None, **kwd): """ Order the cash sorting and check it """ - # fix amount (10000 * 5.0 + 200 * 12.0 + 5000 * 24) - self.cash_sorting.setSourceTotalAssetPrice('172400.0') + # fix amount (10000 * 5.0 + 200 * 12.0 + 5000 * 24 + 100 * 10) + self.cash_sorting.setSourceTotalAssetPrice('173400.0') # do the Workflow action self.workflow_tool.doActionFor(self.cash_sorting, 'order_action', wf_id='cash_sorting_workflow') # execute tic @@ -609,7 +704,9 @@ class TestERP5BankingCashClassification(TestERP5BankingMixin, ERP5TypeTestCase): self.assertEqual(self.simulation_tool.getFutureInventory(node=self.encaisse_tri.getRelativeUrl(), resource = self.billet_200.getRelativeUrl()), 0.0) self.assertEqual(self.simulation_tool.getCurrentInventory(node=self.encaisse_tri.getRelativeUrl(), resource = self.billet_5000.getRelativeUrl()), 0.0) self.assertEqual(self.simulation_tool.getFutureInventory(node=self.encaisse_tri.getRelativeUrl(), resource = self.billet_5000.getRelativeUrl()), 0.0) - + # check we have 0 coin of 100 + self.assertEqual(self.simulation_tool.getCurrentInventory(node=self.encaisse_tri.getRelativeUrl(), resource = self.billet_100.getRelativeUrl()), 0.0) + self.assertEqual(self.simulation_tool.getFutureInventory(node=self.encaisse_tri.getRelativeUrl(), resource = self.billet_100.getRelativeUrl()), 0.0) def stepCheckDestinationCredit(self, sequence=None, sequence_list=None, **kwd): """ @@ -627,6 +724,9 @@ class TestERP5BankingCashClassification(TestERP5BankingMixin, ERP5TypeTestCase): # check we have 24 banknotes of 5000 self.assertEqual(self.simulation_tool.getCurrentInventory(node=self.encaisse_aux_bm.getRelativeUrl(), resource = self.billet_5000.getRelativeUrl()), 24.0) self.assertEqual(self.simulation_tool.getFutureInventory(node=self.encaisse_aux_bm.getRelativeUrl(), resource = self.billet_5000.getRelativeUrl()), 24.0) + # check we have 10 coins of 100 + self.assertEqual(self.simulation_tool.getCurrentInventory(node=self.encaisse_aux_externe.getRelativeUrl(), resource = self.billet_100.getRelativeUrl()), 10.0) + self.assertEqual(self.simulation_tool.getFutureInventory(node=self.encaisse_aux_externe.getRelativeUrl(), resource = self.billet_100.getRelativeUrl()), 10.0) ################################## @@ -642,10 +742,12 @@ class TestERP5BankingCashClassification(TestERP5BankingMixin, ERP5TypeTestCase): # define the sequence sequence_string = 'Tic CheckObjects Tic CheckInitialInventory CheckSource CheckDestination ' \ + 'CreateCashSorting ' \ - + 'CreateThreeValidIncomingLine CheckSubTotal ' \ + + 'CreateFourValidIncomingLine CheckSubTotal ' \ + 'CreateValidOutgoingLineForInternalBanknote ' \ + 'CreateValidOutgoingLineForExternalBanknote ' \ - + 'CreateValidOutgoingLineForInternalAndCancelledBanknote Tic CheckTotal ' \ + + 'CreateValidOutgoingLineForInternalAndCancelledBanknote ' \ + + 'CreateValidOutgoingLineForMixed ' \ + + 'Tic CheckTotal ' \ + 'CheckSource CheckDestination ' \ + 'OrderCashSorting Tic '\ + 'ConfirmCashSorting Tic ' \ -- 2.30.9