Commit e686b823 authored by Nicolas Delaby's avatar Nicolas Delaby

Update unit test against new workflow policy

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16953 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3c6b3500
...@@ -193,11 +193,9 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -193,11 +193,9 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
#obj.assignRoleToSecurityGroup(user_name = user_id) #obj.assignRoleToSecurityGroup(user_name = user_id)
def afterSetUp(self): def afterSetUp(self):
LOG('testImmobilisationMixin',0,'In AfterSetUp')
portal = self.getPortal() portal = self.getPortal()
self.createManagerAndLogin() self.createManagerAndLogin()
# remove all message in the message_table because # remove all message in the message_table because
# the previous test might have failed # the previous test might have failed
message_list = portal.portal_activities.getMessageList() message_list = portal.portal_activities.getMessageList()
...@@ -241,7 +239,6 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -241,7 +239,6 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
""" """
Delete all Objects in PL & M Module Delete all Objects in PL & M Module
""" """
LOG('testImmobilisationMixin',0,'In beforeTearDown')
self.logout() self.logout()
self.login('manager') self.login('manager')
...@@ -271,6 +268,7 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -271,6 +268,7 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
""" """
# Create group categories # Create group categories
category_tool = self.getCategoryTool() category_tool = self.getCategoryTool()
if len(category_tool.group.objectIds()) == 0:
self.createCategoryTree(category_tool.group, self.createCategoryTree(category_tool.group,
[ [
("group A","GA", ("group A","GA",
...@@ -322,7 +320,7 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -322,7 +320,7 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
def createCurrency(self): def createCurrency(self):
currency_module = self.getCurrencyModule() currency_module = self.getCurrencyModule()
if len(currency_module.contentValues())==0: if len(currency_module.contentValues()) == 0:
currency_module.newContent(id="EUR", portal_type='Currency') currency_module.newContent(id="EUR", portal_type='Currency')
currency_module.newContent(id="FCFA", portal_type='Currency') currency_module.newContent(id="FCFA", portal_type='Currency')
...@@ -331,7 +329,7 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -331,7 +329,7 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
Create some organisations relating to the group tree Create some organisations relating to the group tree
""" """
organisation_module = self.getOrganisationModule() organisation_module = self.getOrganisationModule()
if len(organisation_module.contentValues())==0: if len(organisation_module.contentValues()) == 0:
organisation_list= ( organisation_list= (
("A", "A", "group A", "group/group A"), ("A", "A", "group A", "group/group A"),
("Aa", "Aa", "group A", "group/group A/group Aa"), ("Aa", "Aa", "group A", "group/group A/group Aa"),
...@@ -460,7 +458,6 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -460,7 +458,6 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
self.tic() self.tic()
self.workflow_tool.doActionFor(pl, 'set_ready_action', wf_id='packing_list_workflow') self.workflow_tool.doActionFor(pl, 'set_ready_action', wf_id='packing_list_workflow')
self.workflow_tool.doActionFor(pl, 'start_action', wf_id='packing_list_workflow') self.workflow_tool.doActionFor(pl, 'start_action', wf_id='packing_list_workflow')
#import pdb; pdb.set_trace()
get_transaction().commit() get_transaction().commit()
self.tic() self.tic()
self.workflow_tool.doActionFor(pl, 'stop_action', wf_id='packing_list_workflow') self.workflow_tool.doActionFor(pl, 'stop_action', wf_id='packing_list_workflow')
...@@ -489,14 +486,13 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -489,14 +486,13 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
resource_value=resource_value, **parameter_dict) resource_value=resource_value, **parameter_dict)
get_transaction().commit() get_transaction().commit()
self.tic() self.tic()
pl.edit() #pl.calculateImmobilisationValidity()
def stepEditPackingList(self, sequence=None, sequence_list=None, **kw): def stepEditPackingList(self, sequence=None, sequence_list=None, **kw):
pl = sequence.get('packing_list') pl = sequence.get('packing_list')
if pl is None: pl = sequence.get('packing_list_list', [])[-1] if pl is None: pl = sequence.get('packing_list_list', [])[-1]
pl.edit() pl.edit()
def stepCreateComplexPackingListStructure(self, sequence=None, sequence_list=None, **kw): def stepCreateComplexPackingListStructure(self, sequence=None, sequence_list=None, **kw):
""" """
Create a complex structure of PL and items Create a complex structure of PL and items
...@@ -744,7 +740,6 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -744,7 +740,6 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence) self.stepDeliverPackingList(sequence=sequence)
def stepCreatePackingListsForSimpleItemImmobilisation(self, sequence=None, sequence_list=None, **kw): def stepCreatePackingListsForSimpleItemImmobilisation(self, sequence=None, sequence_list=None, **kw):
""" """
Create a list of packing lists describing a continuous period list : Create a list of packing lists describing a continuous period list :
...@@ -805,7 +800,6 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -805,7 +800,6 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence) self.stepDeliverPackingList(sequence=sequence)
def stepCreatePackingListsForSimulationTest(self, sequence=None, sequence_list=None, **kw): def stepCreatePackingListsForSimulationTest(self, sequence=None, sequence_list=None, **kw):
""" """
Create a list of packing lists describing a continuous period list : Create a list of packing lists describing a continuous period list :
...@@ -846,7 +840,6 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -846,7 +840,6 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence) self.stepDeliverPackingList(sequence=sequence)
def stepCreatePackingListsForNoChangeMethodSimulationTest(self, sequence=None, sequence_list=None, **kw): def stepCreatePackingListsForNoChangeMethodSimulationTest(self, sequence=None, sequence_list=None, **kw):
""" """
Create a list of packing lists describing a continuous period list : Create a list of packing lists describing a continuous period list :
...@@ -883,7 +876,6 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -883,7 +876,6 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence) self.stepDeliverPackingList(sequence=sequence)
def stepChangeCurrentPackingListDestinationSectionForOwnerChange(self, sequence=None, sequence_list=None, **kw): def stepChangeCurrentPackingListDestinationSectionForOwnerChange(self, sequence=None, sequence_list=None, **kw):
""" """
Change the destination section of the packing list in order to make a owner change, Change the destination section of the packing list in order to make a owner change,
...@@ -893,7 +885,6 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -893,7 +885,6 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
pl.edit(destination_section_value = self.getOrganisationModule()['Ab1']) pl.edit(destination_section_value = self.getOrganisationModule()['Ab1'])
pl.contentValues()[0].edit(**self.account_dict) pl.contentValues()[0].edit(**self.account_dict)
def stepChangeCurrentPackingListDestinationSectionForActualOwnerChange(self, sequence=None, sequence_list=None, **kw): def stepChangeCurrentPackingListDestinationSectionForActualOwnerChange(self, sequence=None, sequence_list=None, **kw):
""" """
Change the destination section of the packing list in order to make the actual owner (i.e. group) change Change the destination section of the packing list in order to make the actual owner (i.e. group) change
...@@ -933,6 +924,8 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -933,6 +924,8 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence) self.stepDeliverPackingList(sequence=sequence)
get_transaction().commit()
self.tic()
for property in ('amortisation_start_price','amortisation_duration','immobilisation_vat', for property in ('amortisation_start_price','amortisation_duration','immobilisation_vat',
'extra_cost_price','disposal_price'): 'extra_cost_price','disposal_price'):
del parameter_dict[property] del parameter_dict[property]
...@@ -945,25 +938,32 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -945,25 +938,32 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence) self.stepDeliverPackingList(sequence=sequence)
get_transaction().commit()
self.tic()
parameter_dict.update(self.monthly_dict) parameter_dict.update(self.monthly_dict)
sequence.edit(datetime = DateTime('2002/04/16'), sequence.edit(datetime = DateTime('2002/04/16'),
parameter_dict = parameter_dict) parameter_dict = parameter_dict)
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence) self.stepDeliverPackingList(sequence=sequence)
get_transaction().commit()
self.tic()
sequence.edit(datetime = DateTime('2002/05/16'), sequence.edit(datetime = DateTime('2002/05/16'),
parameter_dict = parameter_dict, parameter_dict = parameter_dict,
destination_section = self.getOrganisationModule()["Ab1"]) destination_section = self.getOrganisationModule()["Ab1"])
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence) self.stepDeliverPackingList(sequence=sequence)
get_transaction().commit()
self.tic()
sequence.edit(datetime = DateTime('2002/06/16'), sequence.edit(datetime = DateTime('2002/06/16'),
parameter_dict = parameter_dict, parameter_dict = parameter_dict,
destination_section = self.getOrganisationModule()["Ba"]) destination_section = self.getOrganisationModule()["Ba"])
self.stepCreatePackingList(sequence=sequence) self.stepCreatePackingList(sequence=sequence)
self.stepAggregateItems(sequence=sequence) self.stepAggregateItems(sequence=sequence)
self.stepDeliverPackingList(sequence=sequence) self.stepDeliverPackingList(sequence=sequence)
get_transaction().commit()
self.tic()
def stepBuildAccounting(self, sequence=None, sequence_list=None, **kw): def stepBuildAccounting(self, sequence=None, sequence_list=None, **kw):
""" """
...@@ -977,7 +977,6 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -977,7 +977,6 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
""" """
if build_parameter_dict is None: if build_parameter_dict is None:
build_parameter_dict = sequence.get('build_parameter_dict',{}) build_parameter_dict = sequence.get('build_parameter_dict',{})
LOG('build_parameter_dict for PartialBuildAccounting', 0, build_parameter_dict)
self.getPortal().AccountingTransactionModule_activateBuildAmortisationTransaction(**build_parameter_dict) self.getPortal().AccountingTransactionModule_activateBuildAmortisationTransaction(**build_parameter_dict)
def stepAdoptPrevision(self,sequence=None, sequence_list=None, **kw): def stepAdoptPrevision(self,sequence=None, sequence_list=None, **kw):
...@@ -987,9 +986,10 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -987,9 +986,10 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
for transaction in self.getAccountingModule().contentValues(): for transaction in self.getAccountingModule().contentValues():
if hasattr(transaction, 'adoptPrevision'): if hasattr(transaction, 'adoptPrevision'):
transaction.adoptPrevision() transaction.adoptPrevision()
LOG('Launched adoptPrevision() for transaction', 0, transaction.getRelativeUrl()) #LOG('Launched adoptPrevision() for transaction', 0, transaction.getRelativeUrl())
else: else:
LOG('Cannot launch adoptPrevision() for transaction', 0, transaction.getRelativeUrl()) pass
#LOG('Cannot launch adoptPrevision() for transaction', 0, transaction.getRelativeUrl())
def stepAcceptDecision(self, sequence=None, sequence_list=None, **kw): def stepAcceptDecision(self, sequence=None, sequence_list=None, **kw):
""" """
...@@ -1001,9 +1001,10 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -1001,9 +1001,10 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
self.getPortal().portal_workflow.doActionFor(transaction, self.getPortal().portal_workflow.doActionFor(transaction,
'accept_decision_action', 'accept_decision_action',
'amortisation_transaction_causality_workflow') 'amortisation_transaction_causality_workflow')
LOG('Launched acceptDecision() for transaction', 0, transaction.getRelativeUrl()) #LOG('Launched acceptDecision() for transaction', 0, transaction.getRelativeUrl())
except: except:
LOG('Cannot launch acceptDecision() for transaction', 0, transaction.getRelativeUrl()) pass
#LOG('Cannot launch acceptDecision() for transaction', 0, transaction.getRelativeUrl())
def stepChangeAccountingPrice(self, sequence=None, sequence_list=None, **kw): def stepChangeAccountingPrice(self, sequence=None, sequence_list=None, **kw):
""" """
...@@ -1026,10 +1027,8 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -1026,10 +1027,8 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
for item in self.getItemModule().contentValues(): for item in self.getItemModule().contentValues():
applied_rule_list = item.getCausalityRelatedValueList() applied_rule_list = item.getCausalityRelatedValueList()
for applied_rule in applied_rule_list: for applied_rule in applied_rule_list:
LOG('testing if applied rule is empty for item', 0, item)
self.assertEquals(len(applied_rule.contentValues()), 0) self.assertEquals(len(applied_rule.contentValues()), 0)
def stepTestLinearAmortisationImmobilisationPeriods(self, sequence=None, sequence_list=None, **kw): def stepTestLinearAmortisationImmobilisationPeriods(self, sequence=None, sequence_list=None, **kw):
""" """
Test calculated immobilisation periods Test calculated immobilisation periods
...@@ -1148,14 +1147,12 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -1148,14 +1147,12 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
] ]
self._testImmobilisationPeriods(c_period_list, e_period_list) self._testImmobilisationPeriods(c_period_list, e_period_list)
def _testImmobilisationPeriods(self,c_period_list,e_period_list): def _testImmobilisationPeriods(self,c_period_list,e_period_list):
#LOG('c_period_list :', 0, c_period_list) #LOG('c_period_list :', 0, c_period_list)
e_period_cursor = 0 e_period_cursor = 0
for c_period in c_period_list: for c_period in c_period_list:
#LOG('c_period :', 0, c_period) #LOG('c_period :', 0, c_period)
if e_period_cursor >= len(e_period_list): if e_period_cursor >= len(e_period_list):
LOG('More calculated periods than expected !', 0, '')
self.assertEquals(len(c_period_list), len(e_period_list)) self.assertEquals(len(c_period_list), len(e_period_list))
e_period = e_period_list[e_period_cursor] e_period = e_period_list[e_period_cursor]
#LOG('e_period :', 0, e_period) #LOG('e_period :', 0, e_period)
...@@ -1177,7 +1174,6 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -1177,7 +1174,6 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
else: else:
self.assertEquals(c_value,e_value) self.assertEquals(c_value,e_value)
if e_period_cursor != len(e_period_list): if e_period_cursor != len(e_period_list):
LOG('More expected periods than calculated !', 0, '')
self.assertEquals(len(c_period_list), len(e_period_list)) self.assertEquals(len(c_period_list), len(e_period_list))
...@@ -1365,6 +1361,10 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -1365,6 +1361,10 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
'2003/01/01', 1666.67, 'amortisation_account', None, 'A', None)) '2003/01/01', 1666.67, 'amortisation_account', None, 'A', None))
e_simulation_movement_list.append(self._createExpectedMovement( e_simulation_movement_list.append(self._createExpectedMovement(
'2003/01/01', -1666.67, 'depreciation_account', None, 'A', None)) '2003/01/01', -1666.67, 'depreciation_account', None, 'A', None))
#e_simulation_movement_list.append(self._createExpectedMovement(
#'2004/01/01', 1666.67, 'amortisation_account', None, 'A', None))
#e_simulation_movement_list.append(self._createExpectedMovement(
#'2004/01/01', -1666.67, 'depreciation_account', None, 'A', None))
e_simulation_movement_list.append(self._createExpectedMovement( e_simulation_movement_list.append(self._createExpectedMovement(
'2004/01/01', 833.33, 'amortisation_account', None, 'A', None)) '2004/01/01', 833.33, 'amortisation_account', None, 'A', None))
e_simulation_movement_list.append(self._createExpectedMovement( e_simulation_movement_list.append(self._createExpectedMovement(
...@@ -1381,7 +1381,6 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -1381,7 +1381,6 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
'2006/01/01', 1666.67, 'amortisation_account', None, 'A', None)) '2006/01/01', 1666.67, 'amortisation_account', None, 'A', None))
e_simulation_movement_list.append(self._createExpectedMovement( e_simulation_movement_list.append(self._createExpectedMovement(
'2006/01/01', -1666.67, 'depreciation_account', None, 'A', None)) '2006/01/01', -1666.67, 'depreciation_account', None, 'A', None))
applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule') applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule')
#LOG('Check number of applied rules for item', 0, item.getRelativeUrl()) #LOG('Check number of applied rules for item', 0, item.getRelativeUrl())
self.assertEquals(len(applied_rule_list),1) self.assertEquals(len(applied_rule_list),1)
...@@ -1457,17 +1456,25 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -1457,17 +1456,25 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
'2003/01/01', 1481.48, 'amortisation_account', None, 'A', None)) '2003/01/01', 1481.48, 'amortisation_account', None, 'A', None))
e_simulation_movement_list.append(self._createExpectedMovement( e_simulation_movement_list.append(self._createExpectedMovement(
'2003/01/01', -1481.48, 'depreciation_account', None, 'A', None)) '2003/01/01', -1481.48, 'depreciation_account', None, 'A', None))
#e_simulation_movement_list.append(self._createExpectedMovement(
#'2004/01/01', 987.65, 'amortisation_account', None, 'A', None))
#e_simulation_movement_list.append(self._createExpectedMovement(
#'2004/01/01', -987.65, 'depreciation_account', None, 'A', None))
e_simulation_movement_list.append(self._createExpectedMovement( e_simulation_movement_list.append(self._createExpectedMovement(
'2004/01/01', 493.83, 'amortisation_account', None, 'A', None)) '2004/01/01', 493.83, 'amortisation_account', None, 'A', None))
e_simulation_movement_list.append(self._createExpectedMovement( e_simulation_movement_list.append(self._createExpectedMovement(
'2004/01/01', -493.83, 'depreciation_account', None, 'A', None)) '2004/01/01', -493.83, 'depreciation_account', None, 'A', None))
# Unimmobilisation #Unimmobilisation
e_simulation_movement_list.append(self._createExpectedMovement( e_simulation_movement_list.append(self._createExpectedMovement(
'2003/07/01', -7530.86, 'amortisation_account', None, 'A', None)) '2003/07/01', -7530.86, 'amortisation_account', None, 'A', None))
#e_simulation_movement_list.append(self._createExpectedMovement(
#'2003/07/01', -8024.67, 'amortisation_account', None, 'A', None))
e_simulation_movement_list.append(self._createExpectedMovement( e_simulation_movement_list.append(self._createExpectedMovement(
'2003/07/01', 10000, 'immobilisation_account', None, 'A', None)) '2003/07/01', 10000, 'immobilisation_account', None, 'A', None))
e_simulation_movement_list.append(self._createExpectedMovement( e_simulation_movement_list.append(self._createExpectedMovement(
'2003/07/01', -2469.14, 'output_account', None, 'A', None)) '2003/07/01', -2469.14, 'output_account', None, 'A', None))
#e_simulation_movement_list.append(self._createExpectedMovement(
#'2003/07/01', -1975.33, 'output_account', None, 'A', None))
# New immobilisation # New immobilisation
e_simulation_movement_list.append(self._createExpectedMovement( e_simulation_movement_list.append(self._createExpectedMovement(
'2003/07/01', 12000, 'input_account', None, 'A', None)) '2003/07/01', 12000, 'input_account', None, 'A', None))
...@@ -1672,7 +1679,6 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -1672,7 +1679,6 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
'2003/01/01', 3333.33, 'amortisation_account', None, 'Ba', None)) '2003/01/01', 3333.33, 'amortisation_account', None, 'Ba', None))
e_simulation_movement_list.append(self._createExpectedMovement( e_simulation_movement_list.append(self._createExpectedMovement(
'2003/01/01', -3333.33, 'depreciation_account', None, 'Ba', None)) '2003/01/01', -3333.33, 'depreciation_account', None, 'Ba', None))
applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule') applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule')
#LOG('Check number of applied rules for item', 0, item.getRelativeUrl()) #LOG('Check number of applied rules for item', 0, item.getRelativeUrl())
self.assertEquals(len(applied_rule_list),1) self.assertEquals(len(applied_rule_list),1)
...@@ -1680,7 +1686,6 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -1680,7 +1686,6 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
c_simulation_movement_list = applied_rule.contentValues() c_simulation_movement_list = applied_rule.contentValues()
self._testSimulationBuild(c_simulation_movement_list, e_simulation_movement_list) self._testSimulationBuild(c_simulation_movement_list, e_simulation_movement_list)
def stepTestSimulationBuildForUncontinuousMethodWithoutOwnerChange(self, sequence=None, sequence_list=None, **kw): def stepTestSimulationBuildForUncontinuousMethodWithoutOwnerChange(self, sequence=None, sequence_list=None, **kw):
""" """
Test built simulation for a uncontinuous degressive amortisation method without owner change Test built simulation for a uncontinuous degressive amortisation method without owner change
...@@ -2107,16 +2112,15 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -2107,16 +2112,15 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
def _testSimulationBuild(self, c_simulation_movement_list, e_simulation_movement_list): def _testSimulationBuild(self, c_simulation_movement_list, e_simulation_movement_list):
for c_movement in c_simulation_movement_list: for c_movement in c_simulation_movement_list:
LOG('c_movement %s :' % c_movement, 0, #LOG('c_movement %s :' % c_movement, 0,
'date=%s\n, source=%s\n, source_section=%s\n, destination=%s\n, destination_section=%s\n, quantity=%s\n, resource=%s\n, profit_quantity=%s\n' % ( #'date=%s\n, source=%s\n, source_section=%s\n, destination=%s\n, destination_section=%s\n, quantity=%s\n, resource=%s\n, profit_quantity=%s\n' % (
(c_movement.getStopDate(), c_movement.getSource(), c_movement.getSourceSection(), #(c_movement.getStopDate(), c_movement.getSource(), c_movement.getSourceSection(),
c_movement.getDestination(), c_movement.getDestinationSection(), c_movement.getQuantity(), #c_movement.getDestination(), c_movement.getDestinationSection(), c_movement.getQuantity(),
c_movement.getResource(), c_movement.getProfitQuantity()) #c_movement.getResource(), c_movement.getProfitQuantity())
) #)
) #)
e_found_movement = None e_found_movement = None
e_cursor = 0 e_cursor = 0
LOG('len e_simulation_movement_list start',0,len(e_simulation_movement_list))
while e_cursor < len(e_simulation_movement_list) and e_found_movement is None: while e_cursor < len(e_simulation_movement_list) and e_found_movement is None:
e_movement = e_simulation_movement_list[e_cursor] e_movement = e_simulation_movement_list[e_cursor]
wrong_movement = 0 wrong_movement = 0
...@@ -2139,19 +2143,18 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -2139,19 +2143,18 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
wrong_movement = (round(c_value,2) != round(e_value,2)) wrong_movement = (round(c_value,2) != round(e_value,2))
else: else:
wrong_movement = (c_value != e_value) wrong_movement = (c_value != e_value)
key_cursor += 1 if wrong_movement:
LOG('_testSimulationBuild',0,'key:%s, c_value:%s e_value:%s ' % (key, c_value,e_value)) LOG('_testSimulationBuild',0,'key:%s, c_value:%s e_value:%s ' % (key, c_value,e_value))
key_cursor += 1
if not wrong_movement: if not wrong_movement:
e_found_movement = e_movement e_found_movement = e_movement
e_cursor += 1 e_cursor += 1
#LOG('_testSimulationBuild',0,'wrong movement %s' % wrong_movement) #LOG('_testSimulationBuild',0,'wrong movement %s' % wrong_movement)
if e_found_movement is None: if e_found_movement is None:
LOG('No expected movement found for this calculated one !',0,c_movement.getRelativeUrl()) self.fail('No expected movement found for %s' % (c_movement.getRelativeUrl()))
LOG('len e_simulation_movement_list after fail',0,len(e_simulation_movement_list))
self.failUnless(e_found_movement is not None)
e_simulation_movement_list.remove(e_found_movement) e_simulation_movement_list.remove(e_found_movement)
if len(e_simulation_movement_list) > 0: if len(e_simulation_movement_list) > 0:
LOG('More expected movements than calculated ! Remaining expected ones are', 0, e_simulation_movement_list) #LOG('More expected movements than calculated ! Remaining expected ones are', 0, e_simulation_movement_list)
self.assertEquals(len(e_simulation_movement_list),0) self.assertEquals(len(e_simulation_movement_list),0)
def _buildExpectedTransaction(self, date, source_section, destination_section, causality_state, causality_list=[]): def _buildExpectedTransaction(self, date, source_section, destination_section, causality_state, causality_list=[]):
...@@ -2871,7 +2874,7 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -2871,7 +2874,7 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
# No more correction movement # No more correction movement
applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule') applied_rule_list = item.getCausalityRelatedValueList(portal_type='Applied Rule')
LOG('Check number of applied rules for item', 0, item.getRelativeUrl()) #LOG('Check number of applied rules for item', 0, item.getRelativeUrl())
self.assertEquals(len(applied_rule_list),1) self.assertEquals(len(applied_rule_list),1)
applied_rule = applied_rule_list[0] applied_rule = applied_rule_list[0]
c_simulation_movement_list = applied_rule.contentValues() c_simulation_movement_list = applied_rule.contentValues()
...@@ -2934,13 +2937,13 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -2934,13 +2937,13 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
#self.assertEquals(len(c_transaction_list),len(e_transaction_list)) #self.assertEquals(len(c_transaction_list),len(e_transaction_list))
e_removed_list = [] e_removed_list = []
for c_transaction in c_transaction_list: for c_transaction in c_transaction_list:
LOG('c_transaction %s :' % c_transaction, 0, #LOG('c_transaction %s :' % c_transaction, 0,
'date=%s\n, source_section=%s\n, destination_section=%s\n, resource=%s\n, state=%s\n, causality_list=%s\n' % ( #'date=%s\n, source_section=%s\n, destination_section=%s\n, resource=%s\n, state=%s\n, causality_list=%s\n' % (
(c_transaction.getStopDate(), c_transaction.getSourceSection(), #(c_transaction.getStopDate(), c_transaction.getSourceSection(),
c_transaction.getDestinationSection(), c_transaction.getResource(), c_transaction.getCausalityState(), #c_transaction.getDestinationSection(), c_transaction.getResource(), c_transaction.getCausalityState(),
c_transaction.getCausalityList()) #c_transaction.getCausalityList())
) #)
) #)
e_found_transaction = None e_found_transaction = None
e_cursor = 0 e_cursor = 0
while e_cursor < len(e_transaction_list) and e_found_transaction is None: while e_cursor < len(e_transaction_list) and e_found_transaction is None:
...@@ -2979,22 +2982,20 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -2979,22 +2982,20 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
#LOG('wrong_transaction',0,wrong_transaction) #LOG('wrong_transaction',0,wrong_transaction)
if not wrong_transaction: if not wrong_transaction:
e_found_transaction = e_transaction e_found_transaction = e_transaction
else:
LOG('',0,'key:%s\ncalculated:%s\n expected:%s' % (key,c_value,e_value))
e_cursor += 1 e_cursor += 1
if e_found_transaction is None: if e_found_transaction is None:
LOG('No expected transaction found for this calculated one !',0,'') #LOG('No expected transaction found for this calculated one !',0,'')
self.failUnless(e_found_transaction is not None) self.failUnless(e_found_transaction is not None)
#e_transaction_list.remove(e_transaction) #e_transaction_list.remove(e_transaction)
e_removed_list.append(e_transaction_list.pop(e_transaction_list.index(e_transaction))) e_removed_list.append(e_transaction_list.pop(e_transaction_list.index(e_transaction)))
e_line_list = e_transaction['line_list'] e_line_list = e_transaction['line_list']
c_line_list = c_transaction.contentValues() c_line_list = c_transaction.contentValues()
for c_line in c_line_list: for c_line in c_line_list:
LOG('c_line %s :' % c_line, 0, #LOG('c_line %s :' % c_line, 0,
'source=%s\n,destination=%s\n,quantity=%s\n' % ( #'source=%s\n,destination=%s\n,quantity=%s\n' % (
(c_line.getSource(),c_line.getDestination(),c_line.getQuantity()) #(c_line.getSource(),c_line.getDestination(),c_line.getQuantity())
) #)
) #)
e_found_line = None e_found_line = None
e_line_cursor = 0 e_line_cursor = 0
while e_line_cursor < len(e_line_list) and e_found_line is None: while e_line_cursor < len(e_line_list) and e_found_line is None:
...@@ -3021,19 +3022,14 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase): ...@@ -3021,19 +3022,14 @@ class TestImmobilisationMixin(TestOrderMixin, ERP5TypeTestCase):
key_cursor += 1 key_cursor += 1
if not wrong_line: if not wrong_line:
e_found_line = e_line e_found_line = e_line
else:
LOG('',0,'key:%s\ncalculated:%s\n expected:%s' % (key,c_value,e_value))
e_line_cursor += 1 e_line_cursor += 1
if e_found_line is None: if e_found_line is None:
LOG('No expected line found for this calculated one !',0,'')
self.failUnless(e_found_line is not None) self.failUnless(e_found_line is not None)
e_line_list.remove(e_found_line) e_line_list.remove(e_found_line)
if len(e_line_list) > 0: if len(e_line_list) > 0:
LOG('More expected lines than calculated ! Remaining expected ones are', 0, e_line_list)
self.assertEquals(len(e_line_list),0) self.assertEquals(len(e_line_list),0)
if len(e_transaction_list) > 0: if len(e_transaction_list) > 0:
LOG('More expected transaction than calculated ! Remaining expected ones are', 0, e_transaction_list)
self.assertEquals(len(e_transaction_list),0) self.assertEquals(len(e_transaction_list),0)
class TestImmobilisation(TestImmobilisationMixin): class TestImmobilisation(TestImmobilisationMixin):
...@@ -3043,7 +3039,7 @@ class TestImmobilisation(TestImmobilisationMixin): ...@@ -3043,7 +3039,7 @@ class TestImmobilisation(TestImmobilisationMixin):
def stepSetTest01SequenceData(self, sequence=None, sequence_list=None, **kw): def stepSetTest01SequenceData(self, sequence=None, sequence_list=None, **kw):
sequence.edit(destination_section = self.getOrganisationModule()["A"], sequence.edit(destination_section = self.getOrganisationModule()["A"],
datetime = self.datetime, datetime = self.datetime,
item_list_list = [[ self.getItemModule()['item1'] ]] item_list_list = [[self.getItemModule()['item1']]]
) )
def test_01_singlePackingListImmobilisationStateChange(self, quiet=0, run=run_all_test): def test_01_singlePackingListImmobilisationStateChange(self, quiet=0, run=run_all_test):
...@@ -3060,7 +3056,7 @@ class TestImmobilisation(TestImmobilisationMixin): ...@@ -3060,7 +3056,7 @@ class TestImmobilisation(TestImmobilisationMixin):
Tic \ Tic \
TestPackingListValidImmobilisationState \ TestPackingListValidImmobilisationState \
AggregateItems \ AggregateItems \
TestPackingListCalculatingImmobilisationState \ TestPackingListValidImmobilisationState \
Tic \ Tic \
TestPackingListValidImmobilisationState \ TestPackingListValidImmobilisationState \
' '
...@@ -3212,7 +3208,7 @@ class TestImmobilisation(TestImmobilisationMixin): ...@@ -3212,7 +3208,7 @@ class TestImmobilisation(TestImmobilisationMixin):
UseFirstPackingList \ UseFirstPackingList \
TestPackingListInvalidImmobilisationState \ TestPackingListInvalidImmobilisationState \
UseThirdPackingList \ UseThirdPackingList \
TestPackingListCalculatingImmobilisationState \ TestPackingListInvalidImmobilisationState \
UseFourthPackingList \ UseFourthPackingList \
TestPackingListCalculatingImmobilisationState \ TestPackingListCalculatingImmobilisationState \
Tic \ Tic \
...@@ -3313,7 +3309,6 @@ class TestImmobilisation(TestImmobilisationMixin): ...@@ -3313,7 +3309,6 @@ class TestImmobilisation(TestImmobilisationMixin):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
def stepSetTest09SequenceData(self, sequence=None, sequence_list=None, **kw): def stepSetTest09SequenceData(self, sequence=None, sequence_list=None, **kw):
sequence.edit(item = self.getItemModule()['item10'], sequence.edit(item = self.getItemModule()['item10'],
amortisation_method = self.linear_method) amortisation_method = self.linear_method)
...@@ -3334,7 +3329,6 @@ class TestImmobilisation(TestImmobilisationMixin): ...@@ -3334,7 +3329,6 @@ class TestImmobilisation(TestImmobilisationMixin):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
def stepSetTest10SequenceData(self, sequence=None, sequence_list=None, **kw): def stepSetTest10SequenceData(self, sequence=None, sequence_list=None, **kw):
sequence.edit(item = self.getItemModule()['item11'], sequence.edit(item = self.getItemModule()['item11'],
amortisation_method = self.degressive_method, amortisation_method = self.degressive_method,
...@@ -3355,7 +3349,6 @@ class TestImmobilisation(TestImmobilisationMixin): ...@@ -3355,7 +3349,6 @@ class TestImmobilisation(TestImmobilisationMixin):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
def stepSetTest11SequenceData(self, sequence=None, sequence_list=None, **kw): def stepSetTest11SequenceData(self, sequence=None, sequence_list=None, **kw):
sequence.edit(item = self.getItemModule()['item12'], sequence.edit(item = self.getItemModule()['item12'],
amortisation_method = self.uncontinuous_degressive_method, amortisation_method = self.uncontinuous_degressive_method,
...@@ -3398,7 +3391,6 @@ class TestImmobilisation(TestImmobilisationMixin): ...@@ -3398,7 +3391,6 @@ class TestImmobilisation(TestImmobilisationMixin):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
def stepSetTest13SequenceData(self, sequence=None, sequence_list=None, **kw): def stepSetTest13SequenceData(self, sequence=None, sequence_list=None, **kw):
sequence.edit(item = self.getItemModule()['item14'], sequence.edit(item = self.getItemModule()['item14'],
amortisation_method = self.no_amortisation_method, amortisation_method = self.no_amortisation_method,
...@@ -3625,8 +3617,8 @@ class TestImmobilisation(TestImmobilisationMixin): ...@@ -3625,8 +3617,8 @@ class TestImmobilisation(TestImmobilisationMixin):
self.tic() self.tic()
# Now we can check several Accounting methods # Now we can check several Accounting methods
account = self.getPortal().account_module.account3 account = self.getPortal().account_module.account3
self.assertEquals(20000,account.AccountModule_getTotalSourceDebit(brain=account)) self.assertEquals(10000.0,account.AccountModule_getTotalSourceDebit(brain=account))
self.assertEquals(20000,account.AccountModule_getTotalSourceCredit(brain=account)) self.assertEquals(10000.0,account.AccountModule_getTotalSourceCredit(brain=account))
preference.edit(preferred_accounting_transaction_section_category=\ preference.edit(preferred_accounting_transaction_section_category=\
'group/group B') 'group/group B')
get_transaction().commit() get_transaction().commit()
...@@ -3635,8 +3627,8 @@ class TestImmobilisation(TestImmobilisationMixin): ...@@ -3635,8 +3627,8 @@ class TestImmobilisation(TestImmobilisationMixin):
preference_tool.getPreferredAccountingTransactionSectionCategory()) preference_tool.getPreferredAccountingTransactionSectionCategory())
# Make sure to not use the cache # Make sure to not use the cache
self.portal.REQUEST['ERP5Accounting_getParams'] = None self.portal.REQUEST['ERP5Accounting_getParams'] = None
self.assertEquals(10000,account.AccountModule_getTotalSourceDebit(brain=account)) self.assertEquals(5000.0,account.AccountModule_getTotalSourceDebit(brain=account))
self.assertEquals(0,account.AccountModule_getTotalSourceCredit(brain=account)) self.assertEquals(0.0,account.AccountModule_getTotalSourceCredit(brain=account))
def test_19_TestAccountingBuildingAndDivergence(self, quiet=0, run=run_all_test): def test_19_TestAccountingBuildingAndDivergence(self, quiet=0, run=run_all_test):
if not run: return if not run: return
......
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