Commit c17ac276 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Update and fix various errors with regard to type classes.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39430 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9ddf6f4b
...@@ -40,11 +40,7 @@ from Products.CMFActivity.ActiveObject import INVOKE_ERROR_STATE,\ ...@@ -40,11 +40,7 @@ from Products.CMFActivity.ActiveObject import INVOKE_ERROR_STATE,\
from Products.CMFActivity.Activity.Queue import VALIDATION_ERROR_DELAY from Products.CMFActivity.Activity.Queue import VALIDATION_ERROR_DELAY
from Products.CMFActivity.Activity.SQLDict import SQLDict from Products.CMFActivity.Activity.SQLDict import SQLDict
from Products.CMFActivity.Errors import ActivityPendingError, ActivityFlushError from Products.CMFActivity.Errors import ActivityPendingError, ActivityFlushError
#from Products.ERP5Type.Document.Organisation import Organisation from erp5.portal_type import Organisation
# The above cannot be imported at top level because it doesn't exist until
# Products.ERP5 has been initialized. We set it up as global and populate it
# later:
Organisation = None
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from zLOG import LOG from zLOG import LOG
from ZODB.POSException import ConflictError from ZODB.POSException import ConflictError
...@@ -127,10 +123,6 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -127,10 +123,6 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
if not(organisation_module.hasContent(self.company_id)): if not(organisation_module.hasContent(self.company_id)):
o1 = organisation_module.newContent(id=self.company_id) o1 = organisation_module.newContent(id=self.company_id)
self.stepTic() self.stepTic()
# import it now that Products.ERP5 has been initialized
global Organisation
from Products.ERP5Type.Document.Organisation import Organisation as Org
Organisation = Org
def login(self, quiet=0, run=run_all_test): def login(self, quiet=0, run=run_all_test):
uf = self.getPortal().acl_users uf = self.getPortal().acl_users
...@@ -260,7 +252,6 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -260,7 +252,6 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
portal = self.getPortal() portal = self.getPortal()
def DeferredSetTitle(self,value): def DeferredSetTitle(self,value):
self.activate(activity=activity)._setTitle(value) self.activate(activity=activity)._setTitle(value)
from Products.ERP5Type.Document.Organisation import Organisation
Organisation.DeferredSetTitle = DeferredSetTitle Organisation.DeferredSetTitle = DeferredSetTitle
organisation = portal.organisation._getOb(self.company_id) organisation = portal.organisation._getOb(self.company_id)
organisation._setTitle(self.title1) organisation._setTitle(self.title1)
...@@ -283,7 +274,6 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -283,7 +274,6 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
self._setDescription(value) self._setDescription(value)
def DeferredSetTitle(self,value): def DeferredSetTitle(self,value):
self._setTitle(value) self._setTitle(value)
from Products.ERP5Type.Document.Organisation import Organisation
Organisation.DeferredSetTitle = DeferredSetTitle Organisation.DeferredSetTitle = DeferredSetTitle
Organisation.DeferredSetDescription = DeferredSetDescription Organisation.DeferredSetDescription = DeferredSetDescription
organisation = portal.organisation._getOb(self.company_id) organisation = portal.organisation._getOb(self.company_id)
...@@ -309,7 +299,6 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -309,7 +299,6 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
self.activate(activity=activity)._setTitle(value) self.activate(activity=activity)._setTitle(value)
def DeferredSetDescription(self,value): def DeferredSetDescription(self,value):
self.activate(activity=activity)._setDescription(value) self.activate(activity=activity)._setDescription(value)
from Products.ERP5Type.Document.Organisation import Organisation
Organisation.DeferredSetTitle = DeferredSetTitle Organisation.DeferredSetTitle = DeferredSetTitle
Organisation.DeferredSetDescription = DeferredSetDescription Organisation.DeferredSetDescription = DeferredSetDescription
organisation = portal.organisation._getOb(self.company_id) organisation = portal.organisation._getOb(self.company_id)
...@@ -340,7 +329,6 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -340,7 +329,6 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
if commit_sub: if commit_sub:
transaction.savepoint(optimistic=True) transaction.savepoint(optimistic=True)
self.activate(activity=second or activity,priority=4)._setDescription(value) self.activate(activity=second or activity,priority=4)._setDescription(value)
from Products.ERP5Type.Document.Organisation import Organisation
Organisation.DeferredSetTitle = DeferredSetTitle Organisation.DeferredSetTitle = DeferredSetTitle
Organisation.DeferredSetDescription = DeferredSetDescription Organisation.DeferredSetDescription = DeferredSetDescription
organisation = portal.organisation._getOb(self.company_id) organisation = portal.organisation._getOb(self.company_id)
...@@ -368,7 +356,6 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -368,7 +356,6 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
portal = self.getPortal() portal = self.getPortal()
def crashThisActivity(self): def crashThisActivity(self):
self.IWillCrach() self.IWillCrach()
from Products.ERP5Type.Document.Organisation import Organisation
organisation = portal.organisation._getOb(self.company_id) organisation = portal.organisation._getOb(self.company_id)
Organisation.crashThisActivity = crashThisActivity Organisation.crashThisActivity = crashThisActivity
organisation.activate(activity=activity).crashThisActivity() organisation.activate(activity=activity).crashThisActivity()
...@@ -440,7 +427,6 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -440,7 +427,6 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
active_process = self.portal_activities.newActiveProcess() active_process = self.portal_activities.newActiveProcess()
self.activate(active_process=active_process).getTitle() self.activate(active_process=active_process).getTitle()
return active_process return active_process
from Products.ERP5Type.Document.Organisation import Organisation
Organisation.Organisation_test = Organisation_test Organisation.Organisation_test = Organisation_test
active_process = portal.portal_activities.newActiveProcess() active_process = portal.portal_activities.newActiveProcess()
organisation.activate(activity=activity,active_process=active_process).Organisation_test() organisation.activate(activity=activity,active_process=active_process).Organisation_test()
...@@ -1892,7 +1878,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -1892,7 +1878,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
else: else:
obj.foobar = number obj.foobar = number
del object_list[:] del object_list[:]
from Products.ERP5Type.Document.Folder import Folder from Products.ERP5Type.Core.Folder import Folder
Folder.setFoobar = setFoobar Folder.setFoobar = setFoobar
def getFoobar(self): def getFoobar(self):
...@@ -3229,7 +3215,6 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -3229,7 +3215,6 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
delattr(Organisation, 'firstTest') delattr(Organisation, 'firstTest')
delattr(Organisation, 'secondTest') delattr(Organisation, 'secondTest')
@skip
def test_115_checkProcessShutdown(self, quiet=0, run=run_all_test): def test_115_checkProcessShutdown(self, quiet=0, run=run_all_test):
if not run: return if not run: return
if not quiet: if not quiet:
...@@ -3258,16 +3243,13 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -3258,16 +3243,13 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
organisation = portal.organisation_module.newContent(portal_type='Organisation') organisation = portal.organisation_module.newContent(portal_type='Organisation')
transaction.commit() transaction.commit()
self.tic() self.tic()
activity_lock = threading.Lock() activity_event = threading.Event()
activity_lock.acquire() rendez_vous_event = threading.Event()
rendez_vous_lock = threading.Lock()
rendez_vous_lock.acquire()
def waitingActivity(context): def waitingActivity(context):
# Inform test that we arrived at rendez-vous. # Inform test that we arrived at rendez-vous.
rendez_vous_lock.release() rendez_vous_event.set()
# When this lock is available, it means test has called process_shutdown. # When this event is available, it means test has called process_shutdown.
activity_lock.acquire() activity_event.wait()
activity_lock.release()
from Products.CMFActivity.Activity.Queue import Queue from Products.CMFActivity.Activity.Queue import Queue
original_queue_tic = Queue.tic original_queue_tic = Queue.tic
queue_tic_test_dict = {} queue_tic_test_dict = {}
...@@ -3313,16 +3295,12 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -3313,16 +3295,12 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
activity_thread.start() activity_thread.start()
# Wait at rendez-vous for activity to arrive. # Wait at rendez-vous for activity to arrive.
arrived = False rendez_vous_event.wait()
while (not arrived) and activity_thread.isAlive():
arrived = rendez_vous_lock.acquire(1)
if not arrived:
raise Exception, 'Something wrong happened in activity thread.'
# Initiate shutdown # Initiate shutdown
process_shutdown_thread.start() process_shutdown_thread.start()
try: try:
# Let waiting activity finish and wait for thread exit # Let waiting activity finish and wait for thread exit
activity_lock.release() activity_event.set()
activity_thread.join() activity_thread.join()
process_shutdown_thread.join() process_shutdown_thread.join()
# Check that there is still one activity pending # Check that there is still one activity pending
...@@ -3339,7 +3317,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -3339,7 +3317,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
from Products.CMFActivity.ActivityTool import cancelProcessShutdown from Products.CMFActivity.ActivityTool import cancelProcessShutdown
try: try:
cancelProcessShutdown() cancelProcessShutdown()
except: except StandardException:
# If something failed in process_shutdown, shutdown lock might not # If something failed in process_shutdown, shutdown lock might not
# be taken in CMFActivity, leading to a new esception here hiding # be taken in CMFActivity, leading to a new esception here hiding
# test error. # test error.
...@@ -3563,6 +3541,13 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -3563,6 +3541,13 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
""" """
portal = self.portal portal = self.portal
# Make a new Person object to make sure that the portal type
# is migrated to an instance of a portal type class, otherwise
# the portal type may generate an extra active object.
portal.person_module.newContent(portal_type='Person')
transaction.commit()
self.tic()
original_reindex_parameters = portal.getPlacelessDefaultReindexParameters() original_reindex_parameters = portal.getPlacelessDefaultReindexParameters()
if original_reindex_parameters is None: if original_reindex_parameters is None:
original_reindex_parameters = {} original_reindex_parameters = {}
......
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