From 302765cc262d1d38e824e958c93f32390aff1f3c Mon Sep 17 00:00:00 2001
From: Sebastien Robin <seb@nexedi.com>
Date: Mon, 26 Apr 2004 10:08:24 +0000
Subject: [PATCH] first submission

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@729 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/CMFActivity/tests/__init__.py         |   5 +
 product/CMFActivity/tests/framework.py        | 112 +++++
 product/CMFActivity/tests/run_test_example.sh |  10 +
 product/CMFActivity/tests/runalltests.py      |  29 ++
 product/CMFActivity/tests/testCMFActivity.py  | 441 ++++++++++++++++++
 5 files changed, 597 insertions(+)
 create mode 100755 product/CMFActivity/tests/__init__.py
 create mode 100755 product/CMFActivity/tests/framework.py
 create mode 100755 product/CMFActivity/tests/run_test_example.sh
 create mode 100755 product/CMFActivity/tests/runalltests.py
 create mode 100755 product/CMFActivity/tests/testCMFActivity.py

diff --git a/product/CMFActivity/tests/__init__.py b/product/CMFActivity/tests/__init__.py
new file mode 100755
index 0000000000..4817854199
--- /dev/null
+++ b/product/CMFActivity/tests/__init__.py
@@ -0,0 +1,5 @@
+"""\
+Unit test package for CMFCategory
+
+To run all tests type 'python runalltests.py'
+"""
diff --git a/product/CMFActivity/tests/framework.py b/product/CMFActivity/tests/framework.py
new file mode 100755
index 0000000000..c36e5abb81
--- /dev/null
+++ b/product/CMFActivity/tests/framework.py
@@ -0,0 +1,112 @@
+##############################################################################
+#
+# ZopeTestCase 
+#
+# COPY THIS FILE TO YOUR 'tests' DIRECTORY.
+#
+# This version of framework.py will use the SOFTWARE_HOME
+# environment variable to locate Zope and the Testing package.
+#
+# If the tests are run in an INSTANCE_HOME installation of Zope,
+# Products.__path__ and sys.path with be adjusted to include the
+# instance's Products and lib/python directories respectively.
+#
+# If you explicitly set INSTANCE_HOME prior to running the tests,
+# auto-detection is disabled and the specified path will be used 
+# instead.
+#
+# If the 'tests' directory contains a custom_zodb.py file, INSTANCE_HOME
+# will be adjusted to use it.
+#
+# If you set the ZEO_INSTANCE_HOME environment variable a ZEO setup 
+# is assumed, and you can attach to a running ZEO server (via the 
+# instance's custom_zodb.py).
+#
+##############################################################################
+#
+# The following code should be at the top of every test module:
+#
+# import os, sys
+# if __name__ == '__main__':
+#     execfile(os.path.join(sys.path[0], 'framework.py'))
+#
+# ...and the following at the bottom:
+#
+# if __name__ == '__main__':
+#     framework()
+#
+##############################################################################
+
+__version__ = '0.2.1'
+
+# Save start state
+#
+__SOFTWARE_HOME = os.environ.get('SOFTWARE_HOME', '')
+__INSTANCE_HOME = os.environ.get('INSTANCE_HOME', '')
+
+if __SOFTWARE_HOME.endswith(os.sep):
+    __SOFTWARE_HOME = os.path.dirname(__SOFTWARE_HOME)
+
+if __INSTANCE_HOME.endswith(os.sep):
+    __INSTANCE_HOME = os.path.dirname(__INSTANCE_HOME)
+
+# Find and import the Testing package
+#
+if not sys.modules.has_key('Testing'):
+    p0 = sys.path[0]
+    if p0 and __name__ == '__main__':
+        os.chdir(p0)
+        p0 = ''
+    s = __SOFTWARE_HOME
+    p = d = s and s or os.getcwd()
+    while d:
+        if os.path.isdir(os.path.join(p, 'Testing')):
+            zope_home = os.path.dirname(os.path.dirname(p))
+	    # Do not add the parent directory into the path list.
+	    # Why did the author put it? -yo
+	    if 0:
+                sys.path[:1] = [p0, os.pardir, p, zope_home]
+	    else:
+                sys.path[:1] = [p0, p, zope_home]
+            break
+        p, d = s and ('','') or os.path.split(p)
+    else:
+        print 'Unable to locate Testing package.',
+        print 'You might need to set SOFTWARE_HOME.'
+        sys.exit(1)
+
+import Testing, unittest
+execfile(os.path.join(os.path.dirname(Testing.__file__), 'common.py'))
+
+# Include ZopeTestCase support
+#
+if 1:   # Create a new scope
+
+    p = os.path.join(os.path.dirname(Testing.__file__), 'ZopeTestCase')
+
+    if not os.path.isdir(p):
+        print 'Unable to locate ZopeTestCase package.',
+        print 'You might need to install ZopeTestCase.'
+        sys.exit(1)
+
+    ztc_common = 'ztc_common.py'
+    ztc_common_global = os.path.join(p, ztc_common) 
+
+    f = 0
+    if os.path.exists(ztc_common_global):
+        execfile(ztc_common_global)
+        f = 1
+    if os.path.exists(ztc_common):
+        execfile(ztc_common)
+        f = 1
+
+    if not f:
+        print 'Unable to locate %s.' % ztc_common
+        sys.exit(1)
+
+
+# Debug
+#
+print 'SOFTWARE_HOME: %s' % os.environ.get('SOFTWARE_HOME', 'Not set')
+print 'INSTANCE_HOME: %s' % os.environ.get('INSTANCE_HOME', 'Not set')
+
diff --git a/product/CMFActivity/tests/run_test_example.sh b/product/CMFActivity/tests/run_test_example.sh
new file mode 100755
index 0000000000..deb684687f
--- /dev/null
+++ b/product/CMFActivity/tests/run_test_example.sh
@@ -0,0 +1,10 @@
+export INSTANCE_HOME=/home/$USER/zope
+export SOFTWARE_HOME=/usr/lib/zope/lib/python/
+export COPY_OF_INSTANCE_HOME=$INSTANCE_HOME
+export COPY_OF_SOFTWARE_HOME=$SOFTWARE_HOME
+
+dir="`dirname $0`"
+if test -n "$dir"; then
+  cd $dir
+fi
+python runalltests.py
diff --git a/product/CMFActivity/tests/runalltests.py b/product/CMFActivity/tests/runalltests.py
new file mode 100755
index 0000000000..3a0d03daaf
--- /dev/null
+++ b/product/CMFActivity/tests/runalltests.py
@@ -0,0 +1,29 @@
+#
+# Runs all tests in the current directory
+#
+# Execute like:
+#   python runalltests.py
+#
+# Alternatively use the testrunner: 
+#   python /path/to/Zope/utilities/testrunner.py -qa
+#
+
+import os, sys
+if __name__ == '__main__':
+    execfile(os.path.join(sys.path[0], 'framework.py')) 
+
+import unittest
+TestRunner = unittest.TextTestRunner
+suite = unittest.TestSuite()
+
+tests = os.listdir(os.curdir)
+tests = [n[:-3] for n in tests if n.startswith('test') and n.endswith('.py')]
+
+for test in tests:
+    m = __import__(test)
+    if hasattr(m, 'test_suite'):
+        suite.addTest(m.test_suite())
+
+if __name__ == '__main__':
+    TestRunner().run(suite)
+
diff --git a/product/CMFActivity/tests/testCMFActivity.py b/product/CMFActivity/tests/testCMFActivity.py
new file mode 100755
index 0000000000..d1a0d6480b
--- /dev/null
+++ b/product/CMFActivity/tests/testCMFActivity.py
@@ -0,0 +1,441 @@
+##############################################################################
+#
+# Copyright (c) 2004 Nexedi SARL and Contributors. All Rights Reserved.
+#          Sebastien Robin <seb@nexedi.com>
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+##############################################################################
+
+
+
+#
+# Skeleton ZopeTestCase
+#
+
+from random import randint
+
+import os, sys
+if __name__ == '__main__':
+    execfile(os.path.join(sys.path[0], 'framework.py'))
+
+# Needed in order to have a log file inside the current folder
+os.environ['EVENT_LOG_FILE'] = os.path.join(os.getcwd(), 'zLOG.log')
+os.environ['EVENT_LOG_SEVERITY'] = '-300'
+
+from Testing import ZopeTestCase
+from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
+from AccessControl.SecurityManagement import newSecurityManager, noSecurityManager
+from DateTime import DateTime
+from Acquisition import aq_base, aq_inner
+from zLOG import LOG
+import time
+
+class TestCMFActivity(ERP5TypeTestCase):
+
+  run_all_test = 1
+  # Different variables used for this test
+  company_id = 'Nexedi'
+  title1 = 'title1'
+  title2 = 'title2'
+  destination_company_stock = 'site/Stock_MP/Gravelines'
+  destination_company_group = 'group/Coramy'
+  destination_company_id = 'Coramy'
+  component_id = 'brick'
+  sales_order_id = '1'
+  purchase_order_id = '1'
+  quantity = 10
+  base_price = 0.7832
+
+  def getBusinessTemplateList(self):
+    """
+      Return the list of business templates.
+
+      the business template crm give the following things :
+      modules:
+        - person
+        - organisation
+      base categories:
+        - region
+        - subordination
+      
+      /organisation
+    """
+    return ('erp5_crm',)
+
+  def getCategoriesTool(self):
+    return getattr(self.getPortal(), 'portal_categories', None)
+
+  def getRuleTool(self):
+    return getattr(self.getPortal(), 'portal_Rules', None)
+
+  def getPersonModule(self):
+    return getattr(self.getPortal(), 'person', None)
+
+  def getOrganisationModule(self):
+    return getattr(self.getPortal(), 'organisation', None)
+
+  #def populate(self, quiet=1, run=1):
+  def afterSetUp(self, quiet=1, run=1):
+    self.login()
+    portal = self.getPortal()
+    # Then add new components
+    if not(hasattr(portal,'organisation')):
+      portal.portal_types.constructContent(type_name='Organisation Module',
+                                         container=portal,
+                                         id='organisation')
+    organisation_module = self.getOrganisationModule()
+    if not(organisation_module.hasContent(self.company_id)):
+      o1 = organisation_module.newContent(id=self.company_id)
+
+  def login(self, quiet=0, run=run_all_test):
+    uf = self.getPortal().acl_users
+    uf._doAddUser('seb', '', ['Manager'], [])
+    user = uf.getUserById('seb').__of__(uf)
+    newSecurityManager(None, user)
+
+  def test_01_DeferedSetTitleSQLDict(self, quiet=0, run=run_all_test):
+    # Test if we can add a complete sales order
+    if not run: return
+    if not quiet:
+      message = '\nTest Defered Set Title SQLDict '
+      ZopeTestCase._print(message)
+      LOG('Testing... ',0,message)
+    portal = self.getPortal()
+    organisation =  portal.organisation._getOb(self.company_id)
+    organisation.setTitle(self.title1)
+    self.assertEquals(self.title1,organisation.getTitle())
+    organisation.activate(activity='SQLDict').setTitle(self.title2)
+    organisation.reindexObject()
+    # Needed so that the message are commited into the queue
+    get_transaction().commit()
+    self.assertEquals(self.title1,organisation.getTitle())
+    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)
+
+  def test_02_DeferedSetTitleSQLQueue(self, quiet=0, run=run_all_test):
+    # Test if we can add a complete sales order
+    if not run: return
+    if not quiet:
+      message = '\nTest Defered Set Title SQLQueue '
+      ZopeTestCase._print(message)
+      LOG('Testing... ',0,message)
+    portal = self.getPortal()
+    organisation =  portal.organisation._getOb(self.company_id)
+    organisation.setTitle(self.title1)
+    self.assertEquals(self.title1,organisation.getTitle())
+    organisation.activate(activity='SQLQueue').setTitle(self.title2)
+    # Needed so that the message are commited into the queue
+    get_transaction().commit()
+    self.assertEquals(self.title1,organisation.getTitle())
+    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)
+
+  def test_03_DeferedSetTitleRAMDict(self, quiet=0, run=run_all_test):
+    # Test if we can add a complete sales order
+    if not run: return
+    if not quiet:
+      message = '\nTest Defered Set Title RAMDict '
+      ZopeTestCase._print(message)
+      LOG('Testing... ',0,message)
+    portal = self.getPortal()
+    organisation =  portal.organisation._getOb(self.company_id)
+    organisation.setTitle(self.title1)
+    self.assertEquals(self.title1,organisation.getTitle())
+    organisation.activate(activity='RAMDict').setTitle(self.title2)
+    # Needed so that the message are commited into the queue
+    get_transaction().commit()
+    self.assertEquals(self.title1,organisation.getTitle())
+    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)
+
+  def test_04_DeferedSetTitleRAMQueue(self, quiet=0, run=run_all_test):
+    # Test if we can add a complete sales order
+    if not run: return
+    if not quiet:
+      message = '\nTest Defered Set Title RAMQueue '
+      ZopeTestCase._print(message)
+      LOG('Testing... ',0,message)
+    portal = self.getPortal()
+    organisation =  portal.organisation._getOb(self.company_id)
+    organisation.setTitle(self.title1)
+    self.assertEquals(self.title1,organisation.getTitle())
+    organisation.activate(activity='RAMQueue').setTitle(self.title2)
+    # Needed so that the message are commited into the queue
+    get_transaction().commit()
+    self.assertEquals(self.title1,organisation.getTitle())
+    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)
+
+  def test_05_InvokeAndCancelSQLDict(self, quiet=0, run=run_all_test):
+    # Test if we can add a complete sales order
+    if not run: return
+    if not quiet:
+      message = '\nTest Invoke And Cancel SQLDict '
+      ZopeTestCase._print(message)
+      LOG('Testing... ',0,message)
+    portal = self.getPortal()
+    organisation =  portal.organisation._getOb(self.company_id)
+    organisation.setTitle(self.title1)
+    self.assertEquals(self.title1,organisation.getTitle())
+    organisation.activate(activity='SQLDict').setTitle(self.title2)
+    # Needed so that the message are commited into the queue
+    get_transaction().commit()
+    message_list = portal.portal_activities.getMessageList()
+    self.assertEquals(len(message_list),1)
+    portal.portal_activities.manageCancel(organisation.getPhysicalPath(),'setTitle')
+    # Needed so that the message are removed from the queue
+    get_transaction().commit()
+    self.assertEquals(self.title1,organisation.getTitle())
+    message_list = portal.portal_activities.getMessageList()
+    self.assertEquals(len(message_list),0)
+    organisation.activate(activity='SQLDict').setTitle(self.title2)
+    # Needed so that the message are commited into the queue
+    get_transaction().commit()
+    message_list = portal.portal_activities.getMessageList()
+    self.assertEquals(len(message_list),1)
+    portal.portal_activities.manageInvoke(organisation.getPhysicalPath(),'setTitle')
+    # Needed so that the message are removed from the queue
+    get_transaction().commit()
+    self.assertEquals(self.title2,organisation.getTitle())
+    message_list = portal.portal_activities.getMessageList()
+    self.assertEquals(len(message_list),0)
+
+  def test_06_InvokeAndCancelSQLQueue(self, quiet=0, run=run_all_test):
+    # Test if we can add a complete sales order
+    if not run: return
+    if not quiet:
+      message = '\nTest Invoke And Cancel SQLQueue '
+      ZopeTestCase._print(message)
+      LOG('Testing... ',0,message)
+    portal = self.getPortal()
+    organisation =  portal.organisation._getOb(self.company_id)
+    organisation.setTitle(self.title1)
+    self.assertEquals(self.title1,organisation.getTitle())
+    organisation.activate(activity='SQLQueue').setTitle(self.title2)
+    # Needed so that the message are commited into the queue
+    get_transaction().commit()
+    message_list = portal.portal_activities.getMessageList()
+    self.assertEquals(len(message_list),1)
+    portal.portal_activities.manageCancel(organisation.getPhysicalPath(),'setTitle')
+    # Needed so that the message are removed from the queue
+    get_transaction().commit()
+    self.assertEquals(self.title1,organisation.getTitle())
+    message_list = portal.portal_activities.getMessageList()
+    self.assertEquals(len(message_list),0)
+    organisation.activate(activity='SQLQueue').setTitle(self.title2)
+    # Needed so that the message are commited into the queue
+    get_transaction().commit()
+    message_list = portal.portal_activities.getMessageList()
+    self.assertEquals(len(message_list),1)
+    portal.portal_activities.manageInvoke(organisation.getPhysicalPath(),'setTitle')
+    # Needed so that the message are removed from the queue
+    get_transaction().commit()
+    self.assertEquals(self.title2,organisation.getTitle())
+    message_list = portal.portal_activities.getMessageList()
+    self.assertEquals(len(message_list),0)
+
+  def test_07_InvokeAndCancelRAMQueue(self, quiet=0, run=run_all_test):
+    # Test if we can add a complete sales order
+    if not run: return
+    if not quiet:
+      message = '\nTest Invoke And Cancel RAMQueue '
+      ZopeTestCase._print(message)
+      LOG('Testing... ',0,message)
+    portal = self.getPortal()
+    organisation =  portal.organisation._getOb(self.company_id)
+    organisation.setTitle(self.title1)
+    self.assertEquals(self.title1,organisation.getTitle())
+    organisation.activate(activity='RAMQueue').setTitle(self.title2)
+    # Needed so that the message are commited into the queue
+    get_transaction().commit()
+    message_list = portal.portal_activities.getMessageList()
+    self.assertEquals(len(message_list),1)
+    portal.portal_activities.manageCancel(organisation.getPhysicalPath(),'setTitle')
+    # Needed so that the message are removed from the queue
+    get_transaction().commit()
+    self.assertEquals(self.title1,organisation.getTitle())
+    message_list = portal.portal_activities.getMessageList()
+    self.assertEquals(len(message_list),0)
+    organisation.activate(activity='RAMQueue').setTitle(self.title2)
+    # Needed so that the message are commited into the queue
+    get_transaction().commit()
+    message_list = portal.portal_activities.getMessageList()
+    self.assertEquals(len(message_list),1)
+    portal.portal_activities.manageInvoke(organisation.getPhysicalPath(),'setTitle')
+    # Needed so that the message are removed from the queue
+    get_transaction().commit()
+    self.assertEquals(self.title2,organisation.getTitle())
+    message_list = portal.portal_activities.getMessageList()
+    self.assertEquals(len(message_list),0)
+
+  def test_08_InvokeAndCancelRAMDict(self, quiet=0, run=run_all_test):
+    # Test if we can add a complete sales order
+    if not run: return
+    if not quiet:
+      message = '\nTest Invoke And Cancel RAMDict '
+      ZopeTestCase._print(message)
+      LOG('Testing... ',0,message)
+    portal = self.getPortal()
+    organisation =  portal.organisation._getOb(self.company_id)
+    organisation.setTitle(self.title1)
+    self.assertEquals(self.title1,organisation.getTitle())
+    organisation.activate(activity='RAMDict').setTitle(self.title2)
+    # Needed so that the message are commited into the queue
+    get_transaction().commit()
+    message_list = portal.portal_activities.getMessageList()
+    self.assertEquals(len(message_list),1)
+    portal.portal_activities.manageCancel(organisation.getPhysicalPath(),'setTitle')
+    # Needed so that the message are removed from the queue
+    get_transaction().commit()
+    self.assertEquals(self.title1,organisation.getTitle())
+    message_list = portal.portal_activities.getMessageList()
+    self.assertEquals(len(message_list),0)
+    organisation.activate(activity='RAMDict').setTitle(self.title2)
+    # Needed so that the message are commited into the queue
+    get_transaction().commit()
+    message_list = portal.portal_activities.getMessageList()
+    self.assertEquals(len(message_list),1)
+    portal.portal_activities.manageInvoke(organisation.getPhysicalPath(),'setTitle')
+    # Needed so that the message are removed from the queue
+    get_transaction().commit()
+    self.assertEquals(self.title2,organisation.getTitle())
+    message_list = portal.portal_activities.getMessageList()
+    self.assertEquals(len(message_list),0)
+
+  def test_09_CallOnceWithSQLQueue(self, quiet=0, run=run_all_test):
+    # Test if we call methods only once
+    if not run: return
+    if not quiet:
+      message = '\nCall Once With SQL Queue '
+      ZopeTestCase._print(message)
+      LOG('Testing... ',0,message)
+    portal = self.getPortal()
+    def setFoobar(self):
+      if hasattr(self,'foobar'):
+        self.foobar = self.foobar + 1
+      else:
+        self.foobar = 1
+    def getFoobar(self):
+      return (getattr(self,'foobar',0))
+    from Products.ERP5Type.Document.Organisation import Organisation
+    organisation =  portal.organisation._getOb(self.company_id)
+    Organisation.setFoobar = setFoobar
+    Organisation.getFoobar = getFoobar
+    organisation.foobar = 0
+    organisation.setTitle(self.title1)
+    self.assertEquals(0,organisation.getFoobar())
+    organisation.activate(activity='SQLQueue').setFoobar()
+    # Needed so that the message are commited into the queue
+    get_transaction().commit()
+    message_list = portal.portal_activities.getMessageList()
+    self.assertEquals(len(message_list),1)
+    portal.portal_activities.distribute()
+    portal.portal_activities.tic()
+    self.assertEquals(1,organisation.getFoobar())
+    message_list = portal.portal_activities.getMessageList()
+    self.assertEquals(len(message_list),0)
+    organisation.activate(activity='SQLQueue').setFoobar()
+    # Needed so that the message are commited into the queue
+    get_transaction().commit()
+    message_list = portal.portal_activities.getMessageList()
+    self.assertEquals(len(message_list),1)
+    portal.portal_activities.manageInvoke(organisation.getPhysicalPath(),'setFoobar')
+    # Needed so that the message are commited into the queue
+    get_transaction().commit()
+    message_list = portal.portal_activities.getMessageList()
+    self.assertEquals(len(message_list),0)
+    self.assertEquals(2,organisation.getFoobar())
+
+  def test_10_CallOnceWithRAMQueue(self, quiet=0, run=run_all_test):
+    # Test if we call methods only once
+    if not run: return
+    if not quiet:
+      message = '\nCall Once With RAM Queue '
+      ZopeTestCase._print(message)
+      LOG('Testing... ',0,message)
+    portal = self.getPortal()
+    def setFoobar(self):
+      if hasattr(self,'foobar'):
+        self.foobar = self.foobar + 1
+      else:
+        self.foobar = 1
+    def getFoobar(self):
+      return (getattr(self,'foobar',0))
+    from Products.ERP5Type.Document.Organisation import Organisation
+    organisation =  portal.organisation._getOb(self.company_id)
+    Organisation.setFoobar = setFoobar
+    Organisation.getFoobar = getFoobar
+    organisation.setTitle(self.title1)
+    organisation.foobar = 0
+    self.assertEquals(0,organisation.getFoobar())
+    organisation.activate(activity='RAMQueue').setFoobar()
+    # Needed so that the message are commited into the queue
+    get_transaction().commit()
+    message_list = portal.portal_activities.getMessageList()
+    self.assertEquals(len(message_list),1)
+    portal.portal_activities.distribute()
+    portal.portal_activities.tic()
+    self.assertEquals(1,organisation.getFoobar())
+    message_list = portal.portal_activities.getMessageList()
+    self.assertEquals(len(message_list),0)
+    organisation.activate(activity='RAMQueue').setFoobar()
+    # Needed so that the message are commited into the queue
+    get_transaction().commit()
+    message_list = portal.portal_activities.getMessageList()
+    self.assertEquals(len(message_list),1)
+    portal.portal_activities.manageInvoke(organisation.getPhysicalPath(),'setFoobar')
+    # Needed so that the message are commited into the queue
+    get_transaction().commit()
+    message_list = portal.portal_activities.getMessageList()
+    self.assertEquals(len(message_list),0)
+    self.assertEquals(2,organisation.getFoobar())
+
+
+
+
+
+
+
+
+
+if __name__ == '__main__':
+    framework()
+else:
+    import unittest
+    def test_suite():
+        suite = unittest.TestSuite()
+        suite.addTest(unittest.makeSuite(TestCMFActivity))
+        return suite
+
-- 
2.30.9