Commit c560771f authored by Julien Muchembled's avatar Julien Muchembled

Fix unit tests of ERP5 Product so that they don't call unsupported workflow...

Fix unit tests of ERP5 Product so that they don't call unsupported workflow methods. Transitions of the following workflows were not considered:
* amortisation_transaction_causality_workflow
* event_workflow
* processing_status_workflow
* publication_workflow

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27822 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3f6e0b81
......@@ -177,17 +177,16 @@ class AccountingTestCase(ERP5TypeTestCase):
for module in (self.account_module, self.organisation_module,
self.person_module):
for doc in module.objectValues():
doc.validate()
if doc.getValidationState() != 'validated':
doc.validate()
# and the preference enabled
pref = self.portal.portal_preferences._getOb(
'accounting_zuite_preference', None)
if pref is not None:
pref.manage_addLocalRoles(self.username, ('Auditor', ))
# Make sure _aq_dynamic is called before calling the workflow method
# otherwise .enable might not been wrapped yet. This happen in --load
pref._aq_dynamic('hack')
pref.enable()
if pref.getPreferenceState() != 'enabled':
pref.enable()
self.validateRules()
......
......@@ -204,6 +204,10 @@ class TestAccountingRules(TestAccountingRulesMixin, ERP5TypeTestCase):
"""
invoice_transaction_rule = getattr(self.getRuleTool(),
'default_invoice_transaction_rule')
if invoice_transaction_rule.getValidationState() == 'validated':
invoice_transaction_rule.invalidate()
transaction.commit()
# delete anything inside the rule first
# clear the message queue, so that it does not contains unexistant paths
self.tic()
......
......@@ -76,7 +76,6 @@ class TestBPMMixin(ERP5TypeTestCase):
invoicing_resource_use_category_list = ['discount', 'tax']
def setUpOnce(self):
self.portal = self.getPortalObject()
self.validateRules()
def createCategoriesInCategory(self, category, category_id_list):
......
......@@ -621,7 +621,8 @@ class TestCRMMailSend(ERP5TypeTestCase):
default_pref.setPreferredOoodocServerPortNumber(conversion_server_host[1])
default_pref.setPreferredDocumentFileNameRegularExpression(FILE_NAME_REGULAR_EXPRESSION)
default_pref.setPreferredDocumentReferenceRegularExpression(REFERENCE_REGULAR_EXPRESSION)
default_pref.enable()
if default_pref.getPreferenceState() == 'disabled':
default_pref.enable()
# add a dummy mailhost not to send real messages
if 'MailHost' in self.portal.objectIds():
......@@ -947,6 +948,7 @@ class TestCRMMailSend(ERP5TypeTestCase):
aggregate=document_zip.getRelativeUrl(),
text_content='This is an advertisement mail.')
event.pdb()
mail_text = event.send(download=True)
# Check mail text.
......
......@@ -205,8 +205,9 @@ class TestConversionInSimulation(AccountingTestCase,ERP5TypeTestCase):
portal.portal_workflow.doActionFor(account, 'validate_action')
invoice_rule = portal.portal_rules.default_invoice_transaction_rule
invoice_rule.deleteContent([x.getId()
for x in invoice_rule.objectValues()])
if invoice_rule.getValidationState() == 'validated':
invoice_rule.invalidate()
invoice_rule.deleteContent(list(invoice_rule.objectIds()))
transaction.commit()
self.tic()
region_predicate = invoice_rule.newContent(portal_type = 'Predicate')
......
......@@ -184,35 +184,30 @@ class CrmTestCase(ERP5ReportTestCase):
reference='Person_1',
title='Person_1',
id='Person_1')
user.validate()
if not self.person_module.has_key('Person_2'):
user = self.portal.person_module.newContent(
portal_type='Person',
reference='Person_2',
title='Person_2',
id='Person_2')
user.validate()
if not self.person_module.has_key('Person_3'):
user = self.portal.person_module.newContent(
portal_type='Person',
reference='Person_3',
title='Person_3',
id='Person_3')
user.validate()
if not self.organisation_module.has_key('Organisation_1'):
org = self.portal.organisation_module.newContent(
portal_type='Organisation',
reference='Organisation_1',
title='Organisation_1',
id='Organisation_1')
org.validate()
if not self.organisation_module.has_key('Organisation_2'):
org = self.portal.organisation_module.newContent(
portal_type='Organisation',
reference='Organisation_2',
title='Organisation_2',
id='Organisation_2')
org.validate()
if not self.organisation_module.has_key('My_organisation'):
org = self.portal.organisation_module.newContent(
portal_type='Organisation',
......@@ -220,8 +215,7 @@ class CrmTestCase(ERP5ReportTestCase):
title='My_organisation',
group_value=self.portal_categories['group'].demo_group,
id='My_organisation')
org.validate()
# make sure documents are validated
for module in (self.organisation_module,
self.person_module):
......@@ -237,22 +231,15 @@ class CrmTestCase(ERP5ReportTestCase):
"""Remove all documents.
"""
transaction.abort()
self.campaign_module.manage_delObjects(
list(self.campaign_module.objectIds()))
self.meeting_module.manage_delObjects(
list(self.meeting_module.objectIds()))
self.sale_opportunity_module.manage_delObjects(
list(self.sale_opportunity_module.objectIds()))
self.support_request_module.manage_delObjects(
list(self.support_request_module.objectIds()))
self.organisation_module.manage_delObjects(
list(self.campaign_module.objectIds()))
self.person_module.manage_delObjects(
list(self.person_module.objectIds()))
for module in (self.campaign_module,
self.meeting_module,
self.sale_opportunity_module,
self.support_request_module,
self.organisation_module,
self.person_module,
self.event_module):
module.manage_delObjects(list(module.objectIds()))
self.portal_categories['group'].manage_delObjects((['demo_group',]))
self.event_module.manage_delObjects(
list(self.event_module.objectIds()))
transaction.commit()
self.tic()
......
......@@ -211,9 +211,9 @@ class TestBudget(ERP5TypeTestCase):
portal_type='Account',
financial_section='actif/actif_immobilise/immobilisations_financieres')
# Open accounts
for account in account_module.objectValues(portal_type='Account'):
account.validate()
# Open accounts
for account in account_module.objectValues(portal_type='Account'):
account.validate()
# Create some accounting transactions
self.accounting_transaction1 = accounting_module.newContent(
......
......@@ -30,6 +30,7 @@
import unittest
import transaction
from Testing import ZopeTestCase
from zExceptions import Unauthorized
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.Sequence import SequenceList
from DateTime import DateTime
......@@ -423,9 +424,6 @@ class TestImmobilisationMixin(ERP5TypeTestCase):
def stepTic(self, sequence=None, sequence_list=None, **kw):
self.tic()
def stepPdb(self, sequence=None, sequence_list=None, **kw):
import pdb;pdb.set_trace()
def stepCreatePackingList(self, sequence=None, sequence_list=None, **kw):
property_dict = {}
for property in ('source_section','destination_section','datetime','destination'):
......@@ -992,8 +990,9 @@ class TestImmobilisationMixin(ERP5TypeTestCase):
"""
Launch adopt_prevision() on each Amortisation Transaction
"""
isTransitionPossible = self.portal.portal_workflow.isTransitionPossible
for transaction in self.getAccountingModule().contentValues():
if hasattr(transaction, 'adoptPrevision'):
if isTransitionPossible(transaction, 'adopt_prevision'):
transaction.adoptPrevision()
#LOG('Launched adoptPrevision() for transaction', 0, transaction.getRelativeUrl())
else:
......@@ -1011,7 +1010,7 @@ class TestImmobilisationMixin(ERP5TypeTestCase):
'accept_decision_action',
'amortisation_transaction_causality_workflow')
#LOG('Launched acceptDecision() for transaction', 0, transaction.getRelativeUrl())
except:
except Unauthorized:
pass
#LOG('Cannot launch acceptDecision() for transaction', 0, transaction.getRelativeUrl())
......
......@@ -172,8 +172,9 @@ class TestInvoiceMixin(TestPackingListMixin,
portal.portal_workflow.doActionFor(account, 'validate_action')
invoice_rule = portal.portal_rules.default_invoice_transaction_rule
invoice_rule.deleteContent([x.getId()
for x in invoice_rule.objectValues()])
if invoice_rule.getValidationState() == 'validated':
invoice_rule.invalidate()
invoice_rule.deleteContent(list(invoice_rule.objectIds()))
transaction.commit()
self.tic()
region_predicate = invoice_rule.newContent(portal_type = 'Predicate')
......
......@@ -47,9 +47,6 @@ class TestMRPMixin(TestBPMMixin):
order_portal_type = 'Production Order'
order_line_portal_type = 'Production Order Line'
def setUpOnce(self):
self.portal = self.getPortalObject()
def invalidateRules(self):
"""
do reversely of validateRules
......@@ -57,7 +54,8 @@ class TestMRPMixin(TestBPMMixin):
rule_tool = self.getRuleTool()
for rule in rule_tool.contentValues(
portal_type=rule_tool.getPortalRuleTypeList()):
rule.invalidate()
if rule.getValidationState() == 'validated':
rule.invalidate()
def _createDocument(self, portal_type, **kw):
module = self.portal.getDefaultModule(
......
......@@ -175,37 +175,28 @@ class ResourceVariationTestCase(ERP5TypeTestCase):
reference='A2',id='a2')
#create resource variation preferences
if not self.portal_preferences.hasContent('test_site_preference'):
preference = getattr(self.portal_preferences, 'test_site_preference', None)
if preference is None:
preference = self.portal_preferences.newContent(portal_type='Preference',
title='Default Site Preference',
id='test_site_preference')
preference.enable()
value='individual_aspect'
self.portal_preferences['test_site_preference'
].setPreferredProductIndividualVariationBaseCategory(value)
self.portal_preferences['test_site_preference'
].setPreferredServiceIndividualVariationBaseCategory(value)
self.portal_preferences['test_site_preference'
].setPreferredComponentIndividualVariationBaseCategory(value)
preference.setPreferredProductIndividualVariationBaseCategory(value)
preference.setPreferredServiceIndividualVariationBaseCategory(value)
preference.setPreferredComponentIndividualVariationBaseCategory(value)
value=('required_size',)
self.portal_preferences['test_site_preference'
].setPreferredProductVariationBaseCategoryList(value)
self.portal_preferences['test_site_preference'
].setPreferredServiceVariationBaseCategoryList(value)
self.portal_preferences['test_site_preference'
].setPreferredComponentVariationBaseCategoryList(value)
preference.setPreferredProductVariationBaseCategoryList(value)
preference.setPreferredServiceVariationBaseCategoryList(value)
preference.setPreferredComponentVariationBaseCategoryList(value)
value=('option_colour',)
self.portal_preferences['test_site_preference'
].setPreferredProductOptionalVariationBaseCategory(value)
self.portal_preferences['test_site_preference'
].setPreferredServiceOptionalVariationBaseCategory(value)
self.portal_preferences['test_site_preference'
].setPreferredComponentOptionalVariationBaseCategory(value)
self.portal_preferences['test_site_preference'].enable()
preference.setPreferredProductOptionalVariationBaseCategory(value)
preference.setPreferredServiceOptionalVariationBaseCategory(value)
preference.setPreferredComponentOptionalVariationBaseCategory(value)
# all this available to catalog
#adding to base categories of resources
......
......@@ -41,7 +41,6 @@ class TestRuleMixin(TestOrderMixin):
"""
def afterSetUp(self):
self.test_data = []
# delete rules
self.getRuleTool().manage_delObjects(
ids=list(list(self.getRuleTool().objectIds())))
......@@ -52,14 +51,15 @@ class TestRuleMixin(TestOrderMixin):
delivery_rule = self.getRuleTool().newContent(portal_type="Delivery Rule",
id='default_delivery_rule',
reference='default_delivery_rule', version='1')
# at least one default_delivery_rule should be validated here to
# confirm Sale Packing List in afterSetUp()
delivery_rule.validate()
# create packing list if necessary
pl_module = self.getPortal().getDefaultModule(
self.packing_list_portal_type)
if pl_module.objectCount() == 0:
# at least one default_delivery_rule should be validated here to
# confirm Sale Packing List
delivery_rule.validate()
self.pl = self.createPackingList()
delivery_rule.invalidate()
else:
self.pl = self.getPortal().getDefaultModule(
self.packing_list_portal_type).objectValues()[0]
......@@ -72,10 +72,8 @@ class TestRuleMixin(TestOrderMixin):
def beforeTearDown(self):
for container, id in self.test_data:
container.manage_delObjects(ids=[id])
self.getSimulationTool().manage_delObjects(
ids=list(self.getSimulationTool().objectIds()))
for module in self.getRuleTool(), self.getSimulationTool():
module.manage_delObjects(list(module.objectIds()))
transaction.commit()
self.tic()
......@@ -189,26 +187,6 @@ class TestRule(TestRuleMixin, ERP5TypeTestCase) :
validation_state="validated")[0][0], 0)
self.assertEquals(len(self.getRuleTool().searchRuleList(self.pl)), 0)
def test_05_ValidatedRule(self, quiet=quiet, run=run_all_test):
"""
test that when a rule is validated, it will apply
"""
if not run: return
skin_folder = self.getPortal().portal_skins.custom
skin = createZODBPythonScript(skin_folder, 'good_script', 'rule',
'return True')
delivery_rule = self.getRuleTool().searchFolder(
reference='default_delivery_rule')[0]
delivery_rule.setTestMethodId('good_script')
delivery_rule.validate()
transaction.commit()
self.tic()
self.assertEquals(self.getRuleTool().countFolder(
validation_state="validated")[0][0], 1)
self.assertEquals(len(self.getRuleTool().searchRuleList(self.pl)), 1)
def test_06_WrongDateRange(self, quiet=quiet, run=run_all_test):
"""
test that when a rule is validated but does not have correct date range,
......
......@@ -1627,10 +1627,7 @@ class TestTaxLineInvoiceSimulation(AccountingBuildTestCase):
invoice_simulation_movement.getPriceCurrencyValue())
self.assertEquals(self.resource,
invoice_simulation_movement.getResourceValue())
invoice.start()
self.assertEquals('started', invoice.getSimulationState())
transaction.commit()
self.tic()
accounting_line_list = invoice.getMovementList(
portal_type=('Sale Invoice Transaction Line',
'Purchase Invoice Transaction Line'))
......
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