Commit 3e7e5827 authored by Sebastien Robin's avatar Sebastien Robin

implemented countMessage for RAMDict and RAMQueue, also try with all...

implemented countMessage for RAMDict and RAMQueue, also try with all activities that setId will raise error if some activities are waiting

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11384 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f321d637
......@@ -93,6 +93,21 @@ class RAMDict(Queue):
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()
......
......@@ -80,6 +80,20 @@ class RAMQueue(Queue):
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:
......
......@@ -379,8 +379,8 @@ class TestCMFActivity(ERP5TypeTestCase):
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 @@ class TestCMFActivity(ERP5TypeTestCase):
# 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()
self.assertRaises(ValueError,organisation.edit,id=self.company_id2)
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()
def TryActiveProcess(self, activity):
"""
......
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