[Erp5-report] r11384 - in /erp5/trunk/products/CMFActivity: Activity/ tests/

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Nov 20 14:57:35 CET 2006


Author: seb
Date: Mon Nov 20 14:57:30 2006
New Revision: 11384

URL: http://svn.erp5.org?rev=11384&view=rev
Log:
implemented countMessage for RAMDict and RAMQueue, also try with all activities that setId will raise error if some activities are waiting

Modified:
    erp5/trunk/products/CMFActivity/Activity/RAMDict.py
    erp5/trunk/products/CMFActivity/Activity/RAMQueue.py
    erp5/trunk/products/CMFActivity/tests/testCMFActivity.py

Modified: erp5/trunk/products/CMFActivity/Activity/RAMDict.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/Activity/RAMDict.py?rev=11384&r1=11383&r2=11384&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/Activity/RAMDict.py (original)
+++ erp5/trunk/products/CMFActivity/Activity/RAMDict.py Mon Nov 20 14:57:30 2006
@@ -93,6 +93,21 @@
           get_transaction().commit()
     return 1
 
+  def countMessage(self, activity_tool,path=None,method_id=None,**kw):
+    tool_path = activity_tool.getPhysicalPath()
+    count = 0
+    for (key,m) in self.getDict(tool_path).items():
+      add = 1
+      if path is not None:
+        object_path = '/'.join(m.object_path)
+        if object_path != path:
+          add = 0
+      if method_id is not None:
+        if m.method_id != method_id:
+          add = 0
+      count += add
+    return count
+
   def hasActivity(self, activity_tool, object, **kw):
     if object is not None:
       object_path = object.getPhysicalPath()

Modified: erp5/trunk/products/CMFActivity/Activity/RAMQueue.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/Activity/RAMQueue.py?rev=11384&r1=11383&r2=11384&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/Activity/RAMQueue.py (original)
+++ erp5/trunk/products/CMFActivity/Activity/RAMQueue.py Mon Nov 20 14:57:30 2006
@@ -80,6 +80,20 @@
         get_transaction().commit()
     return 1 # Go to sleep
 
+  def countMessage(self, activity_tool,path=None,method_id=None,**kw):
+    tool_path = activity_tool.getPhysicalPath()
+    count = 0
+    for m in self.getQueue(tool_path):
+      add = 1
+      if path is not None:
+        object_path = '/'.join(m.object_path)
+        if object_path != path:
+          add = 0
+      if method_id is not None:
+        if m.method_id != method_id:
+          add = 0
+      count += add
+    return count
 
   def hasActivity(self, activity_tool, object, **kw):
     if object is not None:

Modified: erp5/trunk/products/CMFActivity/tests/testCMFActivity.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/tests/testCMFActivity.py?rev=11384&r1=11383&r2=11384&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/tests/testCMFActivity.py (original)
+++ erp5/trunk/products/CMFActivity/tests/testCMFActivity.py Mon Nov 20 14:57:30 2006
@@ -379,8 +379,8 @@
 
   def DeferedSetTitleWithRenamedObject(self, activity):
     """
-    make sure that an activity is flushed before we rename
-    the object
+    make sure that it is impossible to rename an object
+    if some activities are still waiting for this object
     """
     portal = self.getPortal()
     organisation =  portal.organisation._getOb(self.company_id)
@@ -390,15 +390,9 @@
     # Needed so that the message are commited into the queue
     get_transaction().commit()
     self.assertEquals(self.title1,organisation.getTitle())
-    organisation.edit(id=self.company_id2)
-    get_transaction().commit()
-    portal.portal_activities.distribute()
-    portal.portal_activities.tic()
-    self.assertEquals(self.title2,organisation.getTitle())
-    message_list = portal.portal_activities.getMessageList()
-    self.assertEquals(len(message_list),0)
-    organisation.edit(id=self.company_id)
-    get_transaction().commit()
+    self.assertRaises(ValueError,organisation.edit,id=self.company_id2)
+    portal.portal_activities.distribute()
+    portal.portal_activities.tic()
 
   def TryActiveProcess(self, activity):
     """




More information about the Erp5-report mailing list