Commit f6fb64ec authored by Julien Muchembled's avatar Julien Muchembled

Clean up testAccounting and also run it with legacy simulation

git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/amount_generator@38152 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ad1097ce
......@@ -160,22 +160,14 @@ class AccountingTestCase(ERP5TypeTestCase):
user = uf.getUserById(self.username).__of__(uf)
newSecurityManager(None, user)
def setUp(self):
"""Setup the fixture.
"""
ERP5TypeTestCase.setUp(self)
if os.environ.get('erp5_save_data_fs'):
return
self.portal = self.getPortal()
def afterSetUp(self):
self.account_module = self.portal.account_module
self.accounting_module = self.portal.accounting_module
self.organisation_module = self.portal.organisation_module
self.person_module = self.portal.person_module
self.currency_module = self.portal.currency_module
if not hasattr(self, 'section'):
self.section = getattr(self.organisation_module, 'my_organisation', None)
if not hasattr(self, 'main_section'):
self.main_section = getattr(self.organisation_module, 'main_organisation', None)
self.section = getattr(self.organisation_module, 'my_organisation', None)
self.main_section = getattr(self.organisation_module, 'main_organisation', None)
# make sure documents are validated
for module in (self.account_module, self.organisation_module,
......@@ -200,14 +192,11 @@ class AccountingTestCase(ERP5TypeTestCase):
transaction.commit()
self.tic()
def tearDown(self):
def beforeTearDown(self):
"""Remove all documents, except the default ones.
"""
if os.environ.get('erp5_save_data_fs'):
return
self.login('ERP5TypeTestCase')
transaction.abort()
self.login()
self.accounting_module.manage_delObjects(
list(self.accounting_module.objectIds()))
organisation_list = ('my_organisation', 'main_organisation',
......@@ -234,8 +223,6 @@ class AccountingTestCase(ERP5TypeTestCase):
self.portal.portal_simulation.objectIds()))
transaction.commit()
self.tic()
ERP5TypeTestCase.tearDown(self)
def getBusinessTemplateList(self):
"""Returns list of BT to be installed."""
......@@ -243,8 +230,9 @@ class AccountingTestCase(ERP5TypeTestCase):
# a dependancy of erp5_accounting_ui_test, because it's used to test
# standalone accounting and only installs erp5_accounting_ui_test to have
# some default content created.
return ('erp5_base', 'erp5_pdm', 'erp5_trade', 'erp5_accounting',
'erp5_project', 'erp5_accounting_ui_test', 'erp5_ods_style')
return ('erp5_base', 'erp5_pdm', 'erp5_simulation', 'erp5_trade',
'erp5_accounting', 'erp5_project', 'erp5_accounting_ui_test',
'erp5_ods_style')
class TestAccounts(AccountingTestCase):
......@@ -290,6 +278,7 @@ class TestTransactionValidation(AccountingTestCase):
2006, and an open one for 2007.
"""
def afterSetUp(self):
super(TestTransactionValidation, self).afterSetUp()
self.organisation_module = self.portal.organisation_module
self.main_section = self.organisation_module.main_organisation
......@@ -3095,10 +3084,9 @@ class TestAccountingWithSequences(ERP5TypeTestCase):
def getTitle(self):
return "Accounting"
def afterSetUp(self):
"""Prepare the test."""
self.portal = self.getPortal()
self.workflow_tool = self.portal.portal_workflow
self.organisation_module = self.portal.organisation_module
self.account_module = self.portal.account_module
......@@ -3116,7 +3104,6 @@ class TestAccountingWithSequences(ERP5TypeTestCase):
priority=Priority.USER )
self.workflow_tool.doActionFor(self.pref, 'enable_action')
def beforeTearDown(self):
"""Cleanup for next test.
"""
......
# -*- coding: utf-8 -*-
##############################################################################
# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
from Products.ERP5.tests.testAccounting import *
def Legacy_getBusinessTemplateList(cls):
getBusinessTemplateList = cls.getBusinessTemplateList
def Legacy_getBusinessTemplateList(self):
bt_list = []
for bt in getBusinessTemplateList(self):
bt_list.append(bt)
if bt == 'erp5_simulation':
bt_list.append(bt + '_legacy')
elif bt in ('erp5_accounting', 'erp5_trade', 'erp5_project'):
bt_list.append(bt + '_simulation_legacy')
return tuple(bt_list)
cls.getBusinessTemplateList = Legacy_getBusinessTemplateList
Legacy_getBusinessTemplateList(AccountingTestCase)
Legacy_getBusinessTemplateList(TestAccountingWithSequences)
......@@ -22,7 +22,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
......
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