Commit a339b01c authored by Jérome Perrin's avatar Jérome Perrin

Set a region and validate sections firts, because accouting_workflow...

Set a region and validate sections firts, because accouting_workflow validation script now requires it. Add a new test for empty lines deletion.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6937 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ba39d406
...@@ -86,9 +86,16 @@ class TestAccounting(ERP5TypeTestCase): ...@@ -86,9 +86,16 @@ class TestAccounting(ERP5TypeTestCase):
start_date = DateTime(2004, 01, 01) start_date = DateTime(2004, 01, 01)
stop_date = DateTime(2004, 12, 31) stop_date = DateTime(2004, 12, 31)
default_region = 'europe/west/france'
def getTitle(self): def getTitle(self):
return "Accounting" return "Accounting"
def afterSetUp(self):
"""Prepare the test."""
self.createCategories()
self.login()
def login(self) : def login(self) :
"""sets the security manager""" """sets the security manager"""
uf = self.getPortal().acl_users uf = self.getPortal().acl_users
...@@ -99,17 +106,19 @@ class TestAccounting(ERP5TypeTestCase): ...@@ -99,17 +106,19 @@ class TestAccounting(ERP5TypeTestCase):
def createCategories(self): def createCategories(self):
"""Create the categories for our test. """ """Create the categories for our test. """
TestPackingListMixin.createCategories(self)
# create categories # create categories
for cat_string in self.getNeededCategoryList() : for cat_string in self.getNeededCategoryList():
base_cat = cat_string.split("/")[0] base_cat = cat_string.split("/")[0]
path = self.getPortal().portal_categories[base_cat] path = self.getPortal().portal_categories[base_cat]
for cat in cat_string.split("/")[1:] : for cat in cat_string.split("/")[1:]:
if not cat in path.objectIds() : if not cat in path.objectIds():
path = path.newContent( path = path.newContent(
portal_type = 'Category', portal_type='Category',
id = cat, id=cat,
immediate_reindex = 1 ) immediate_reindex=1)
else:
path = path[cat]
# check categories have been created # check categories have been created
for cat_string in self.getNeededCategoryList() : for cat_string in self.getNeededCategoryList() :
self.assertNotEquals(None, self.assertNotEquals(None,
...@@ -117,11 +126,12 @@ class TestAccounting(ERP5TypeTestCase): ...@@ -117,11 +126,12 @@ class TestAccounting(ERP5TypeTestCase):
cat_string) cat_string)
def getNeededCategoryList(self): def getNeededCategoryList(self):
"""return a list of categories that should be created.""" """Returns a list of categories that should be created."""
return ('group/client', 'group/vendor' ) return ('group/client', 'group/vendor',
'region/%s'%self.default_region, )
def getBusinessTemplateList(self): def getBusinessTemplateList(self):
""" """ """Returns list of BT to be installed."""
return ('erp5_base', 'erp5_pdm', 'erp5_trade', 'erp5_accounting',) return ('erp5_base', 'erp5_pdm', 'erp5_trade', 'erp5_accounting',)
def stepTic(self, **kw): def stepTic(self, **kw):
...@@ -138,6 +148,11 @@ class TestAccounting(ERP5TypeTestCase): ...@@ -138,6 +148,11 @@ class TestAccounting(ERP5TypeTestCase):
portal_type = self.organisation_portal_type, portal_type = self.organisation_portal_type,
group = "group/vendor", group = "group/vendor",
price_currency = "currency_module/EUR") price_currency = "currency_module/EUR")
# validate entities
for entity in (client, vendor):
entity.setRegion(self.default_region)
self.getWorkflowTool().doActionFor(entity, 'validate_action')
sequence.edit( client = client, sequence.edit( client = client,
vendor = vendor, vendor = vendor,
organisation = vendor ) organisation = vendor )
...@@ -978,6 +993,33 @@ class TestAccounting(ERP5TypeTestCase): ...@@ -978,6 +993,33 @@ class TestAccounting(ERP5TypeTestCase):
except ValidationFailed, err : except ValidationFailed, err :
self.assert_(0, "Validation failed : %s" % err.msg) self.assert_(0, "Validation failed : %s" % err.msg)
def stepValidateRemoveEmptyLines(self, sequence, sequence_list=None, **kw):
"""Check validating a transaction remove empty lines. """
transaction = sequence.get('transaction')
lines_count = len(transaction.getMovementList())
empty_lines_count = 0
for line in transaction.getMovementList():
if line.getSourceTotalAssetPrice() == \
line.getDestinationTotalAssetPrice() == 0:
empty_lines_count += 1
if empty_lines_count == 0:
transaction.newContent(
portal_type=self.accounting_transaction_line_portal_type)
self.getWorkflowTool().doActionFor(transaction, 'stop_action')
self.assertEquals(len(transaction.getMovementList()),
lines_count - empty_lines_count)
# we don't remove empty lines if there is only empty lines
transaction = self.getAccountingModule().newContent(
portal_type=self.accounting_transaction_portal_type,
created_by_builder=1)
for i in range(3):
transaction.newContent(
portal_type=self.accounting_transaction_line_portal_type)
lines_count = len(transaction.getMovementList())
transaction.AccountingTransaction_deleteEmptyLines(redirect=0)
self.assertEquals(len(transaction.getMovementList()), lines_count)
############################################################################ ############################################################################
## Test Methods ############################################################ ## Test Methods ############################################################
...@@ -1171,6 +1213,19 @@ class TestAccounting(ERP5TypeTestCase): ...@@ -1171,6 +1213,19 @@ class TestAccounting(ERP5TypeTestCase):
stepValidateNoPayment stepValidateNoPayment
""") """)
def test_AccountingTransactionValidationRemoveEmptyLines(self, quiet=0,
run=RUN_ALL_TESTS):
"""Transaction validation removes empty lines"""
if not run : return
self.playSequence("""
stepCreateEntities
stepCreateCurrencies
stepCreateAccounts
stepCreateValidAccountingTransaction
stepValidateRemoveEmptyLines
""")
if __name__ == '__main__': if __name__ == '__main__':
framework() framework()
else: else:
......
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