[Erp5-report] r39430 yo - /erp5/trunk/products/CMFActivity/tests/testCMFActivity.py

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Oct 21 12:20:20 CEST 2010


Author: yo
Date: Thu Oct 21 12:20:16 2010
New Revision: 39430

URL: http://svn.erp5.org?rev=39430&view=rev
Log:
Update and fix various errors with regard to type classes.

Modified:
    erp5/trunk/products/CMFActivity/tests/testCMFActivity.py

Modified: erp5/trunk/products/CMFActivity/tests/testCMFActivity.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/tests/testCMFActivity.py?rev=39430&r1=39429&r2=39430&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/tests/testCMFActivity.py [utf8] (original)
+++ erp5/trunk/products/CMFActivity/tests/testCMFActivity.py [utf8] Thu Oct 21 12:20:16 2010
@@ -40,11 +40,7 @@ from Products.CMFActivity.ActiveObject i
 from Products.CMFActivity.Activity.Queue import VALIDATION_ERROR_DELAY
 from Products.CMFActivity.Activity.SQLDict import SQLDict
 from Products.CMFActivity.Errors import ActivityPendingError, ActivityFlushError
-#from Products.ERP5Type.Document.Organisation 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 erp5.portal_type import Organisation
 from AccessControl.SecurityManagement import newSecurityManager
 from zLOG import LOG
 from ZODB.POSException import ConflictError
@@ -127,10 +123,6 @@ class TestCMFActivity(ERP5TypeTestCase, 
     if not(organisation_module.hasContent(self.company_id)):
       o1 = organisation_module.newContent(id=self.company_id)
     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):
     uf = self.getPortal().acl_users
@@ -260,7 +252,6 @@ class TestCMFActivity(ERP5TypeTestCase, 
     portal = self.getPortal()
     def DeferredSetTitle(self,value):
       self.activate(activity=activity)._setTitle(value)
-    from Products.ERP5Type.Document.Organisation import Organisation
     Organisation.DeferredSetTitle = DeferredSetTitle
     organisation =  portal.organisation._getOb(self.company_id)
     organisation._setTitle(self.title1)
@@ -283,7 +274,6 @@ class TestCMFActivity(ERP5TypeTestCase, 
       self._setDescription(value)
     def DeferredSetTitle(self,value):
       self._setTitle(value)
-    from Products.ERP5Type.Document.Organisation import Organisation
     Organisation.DeferredSetTitle = DeferredSetTitle
     Organisation.DeferredSetDescription = DeferredSetDescription
     organisation =  portal.organisation._getOb(self.company_id)
@@ -309,7 +299,6 @@ class TestCMFActivity(ERP5TypeTestCase, 
       self.activate(activity=activity)._setTitle(value)
     def DeferredSetDescription(self,value):
       self.activate(activity=activity)._setDescription(value)
-    from Products.ERP5Type.Document.Organisation import Organisation
     Organisation.DeferredSetTitle = DeferredSetTitle
     Organisation.DeferredSetDescription = DeferredSetDescription
     organisation =  portal.organisation._getOb(self.company_id)
@@ -340,7 +329,6 @@ class TestCMFActivity(ERP5TypeTestCase, 
       if commit_sub:
         transaction.savepoint(optimistic=True)
       self.activate(activity=second or activity,priority=4)._setDescription(value)
-    from Products.ERP5Type.Document.Organisation import Organisation
     Organisation.DeferredSetTitle = DeferredSetTitle
     Organisation.DeferredSetDescription = DeferredSetDescription
     organisation =  portal.organisation._getOb(self.company_id)
@@ -368,7 +356,6 @@ class TestCMFActivity(ERP5TypeTestCase, 
     portal = self.getPortal()
     def crashThisActivity(self):
       self.IWillCrach()
-    from Products.ERP5Type.Document.Organisation import Organisation
     organisation =  portal.organisation._getOb(self.company_id)
     Organisation.crashThisActivity = crashThisActivity
     organisation.activate(activity=activity).crashThisActivity()
@@ -440,7 +427,6 @@ class TestCMFActivity(ERP5TypeTestCase, 
       active_process = self.portal_activities.newActiveProcess()
       self.activate(active_process=active_process).getTitle()
       return active_process
-    from Products.ERP5Type.Document.Organisation import Organisation
     Organisation.Organisation_test = Organisation_test
     active_process = portal.portal_activities.newActiveProcess()
     organisation.activate(activity=activity,active_process=active_process).Organisation_test()
@@ -1892,7 +1878,7 @@ class TestCMFActivity(ERP5TypeTestCase, 
         else:
           obj.foobar = number
       del object_list[:]
-    from Products.ERP5Type.Document.Folder import Folder
+    from Products.ERP5Type.Core.Folder import Folder
     Folder.setFoobar = setFoobar    
 
     def getFoobar(self):
@@ -3229,7 +3215,6 @@ class TestCMFActivity(ERP5TypeTestCase, 
       delattr(Organisation, 'firstTest')
       delattr(Organisation, 'secondTest')
 
-  @skip
   def test_115_checkProcessShutdown(self, quiet=0, run=run_all_test):
     if not run: return
     if not quiet:
@@ -3258,16 +3243,13 @@ class TestCMFActivity(ERP5TypeTestCase, 
     organisation = portal.organisation_module.newContent(portal_type='Organisation')
     transaction.commit()
     self.tic()
-    activity_lock = threading.Lock()
-    activity_lock.acquire()
-    rendez_vous_lock = threading.Lock()
-    rendez_vous_lock.acquire()
+    activity_event = threading.Event()
+    rendez_vous_event = threading.Event()
     def waitingActivity(context):
       # Inform test that we arrived at rendez-vous.
-      rendez_vous_lock.release()
-      # When this lock is available, it means test has called process_shutdown.
-      activity_lock.acquire()
-      activity_lock.release()
+      rendez_vous_event.set()
+      # When this event is available, it means test has called process_shutdown.
+      activity_event.wait()
     from Products.CMFActivity.Activity.Queue import Queue
     original_queue_tic = Queue.tic
     queue_tic_test_dict = {}
@@ -3313,16 +3295,12 @@ class TestCMFActivity(ERP5TypeTestCase, 
 
       activity_thread.start()
       # Wait at rendez-vous for activity to arrive.
-      arrived = False
-      while (not arrived) and activity_thread.isAlive():
-        arrived = rendez_vous_lock.acquire(1)
-      if not arrived:
-        raise Exception, 'Something wrong happened in activity thread.'
+      rendez_vous_event.wait()
       # Initiate shutdown
       process_shutdown_thread.start()
       try:
         # Let waiting activity finish and wait for thread exit
-        activity_lock.release()
+        activity_event.set()
         activity_thread.join()
         process_shutdown_thread.join()
         # Check that there is still one activity pending
@@ -3339,7 +3317,7 @@ class TestCMFActivity(ERP5TypeTestCase, 
         from Products.CMFActivity.ActivityTool import cancelProcessShutdown
         try:
           cancelProcessShutdown()
-        except:
+        except StandardException:
           # If something failed in process_shutdown, shutdown lock might not
           # be taken in CMFActivity, leading to a new esception here hiding
           # test error.
@@ -3563,6 +3541,13 @@ class TestCMFActivity(ERP5TypeTestCase, 
     """
     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()
     if original_reindex_parameters is None:
       original_reindex_parameters = {}




More information about the Erp5-report mailing list