From cf3343f67e8daa1f9a6701517ab30fc87501bb57 Mon Sep 17 00:00:00 2001
From: Sebastien Robin <seb@nexedi.com>
Date: Tue, 20 Apr 2004 07:43:52 +0000
Subject: [PATCH] added test in order to test invoke and cancel on all
 activities

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@704 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/Coramy/tests/testCMFActivity.py | 199 +++++++++++++++++++++++-
 1 file changed, 192 insertions(+), 7 deletions(-)

diff --git a/product/Coramy/tests/testCMFActivity.py b/product/Coramy/tests/testCMFActivity.py
index cd3e0fc9cc..e22d1b2366 100755
--- a/product/Coramy/tests/testCMFActivity.py
+++ b/product/Coramy/tests/testCMFActivity.py
@@ -113,12 +113,13 @@ class TestCMFActivity(ERP5TypeTestCase):
     user = uf.getUserById('seb').__of__(uf)
     newSecurityManager(None, user)
 
-  def testDeferedSetTitleSQLDict(self, quiet=0, run=run_all_test):
+  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:
-      ZopeTestCase._print('\nTest Defered Set Title SQLDict')
-      LOG('Testing... ',0,'testDeferedSetTitleSQLDict')
+      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)
@@ -134,18 +135,18 @@ class TestCMFActivity(ERP5TypeTestCase):
     message_list = portal.portal_activities.getMessageList()
     self.assertEquals(len(message_list),0)
 
-  def testDeferedSetTitleSQLQueue(self, quiet=0, run=run_all_test):
+  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:
-      ZopeTestCase._print('\nTest Defered Set Title SQLQueue')
-      LOG('Testing... ',0,'testDeferedSetTitleSQLQueue')
+      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)
-    organisation.reindexObject()
     # Needed so that the message are commited into the queue
     get_transaction().commit()
     self.assertEquals(self.title1,organisation.getTitle())
@@ -155,6 +156,190 @@ class TestCMFActivity(ERP5TypeTestCase):
     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)
+
+
+
+
+
+
+
 
 
 if __name__ == '__main__':
-- 
2.30.9