From 7145fb63615cc3b26024ad9ef0ba2d58427e2064 Mon Sep 17 00:00:00 2001
From: Guillaume Michon <guillaume@nexedi.com>
Date: Wed, 21 Sep 2005 13:04:07 +0000
Subject: [PATCH] Now test the following behavior when edit() does not change
 values : - If edit_workflow is associated, reindexation only in activities -
 Else, no reindexation at all For Setters : reindexation in all cases, in
 activities

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3817 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/tests/testBase.py | 88 ++++++++++++++++++++++++++++++++++
 1 file changed, 88 insertions(+)

diff --git a/product/ERP5/tests/testBase.py b/product/ERP5/tests/testBase.py
index 8ebd5fe30f..06d9b7834c 100755
--- a/product/ERP5/tests/testBase.py
+++ b/product/ERP5/tests/testBase.py
@@ -127,6 +127,14 @@ class TestBase(ERP5TypeTestCase):
         ['Organisation'], ('validation_workflow', 'edit_workflow'))
     _aq_reset()
 
+  def stepAssociateWorkflowsExcludingEdit(self, sequence=None, sequence_list=None, **kw):
+    """
+      Associate workflow to the portal type
+    """
+    self.getWorkflowTool().setChainForPortalTypes(
+        ['Organisation'], ('validation_workflow',))
+    _aq_reset()
+
   def stepCreateObject(self, sequence=None, sequence_list=None, **kw):
     """
       Create a object which will be tested.
@@ -195,6 +203,16 @@ class TestBase(ERP5TypeTestCase):
     message_list = portal.portal_activities.getMessageList()
     self.assertEquals(len(message_list), 0)
 
+  def stepMakeImmediateReindexObjectCrashing(self, sequence=None, sequence_list=None, **kw):
+    """
+      Overwrite immediateReindexObject() with a crashing method
+    """
+    def crashingMethod(self):
+      self.ImmediateReindexObjectIsCalled()
+    from Products.ERP5Type.Document.Organisation import Organisation
+    Organisation.immediateReindexObject = crashingMethod
+    Organisation.recursiveImmediateReindexObject = crashingMethod
+
   def test_01_areActivitiesWellLaunchedByPropertyEdit(self, quiet=0, 
                                                       run=run_all_test):
     """
@@ -209,12 +227,14 @@ class TestBase(ERP5TypeTestCase):
               CreateObject \
               Tic \
               CheckTitleValue \
+              MakeImmediateReindexObjectCrashing \
               SetDifferentTitleValueWithEdit \
               CheckIfActivitiesAreCreated \
               CheckTitleValue \
               Tic \
               CheckIfMessageQueueIsEmpty \
               SetSameTitleValueWithEdit \
+              CheckTitleValue \
               CheckIfMessageQueueIsEmpty \
               SetDifferentTitleValueWithEdit \
               CheckIfActivitiesAreCreated \
@@ -229,12 +249,16 @@ class TestBase(ERP5TypeTestCase):
               CreateObject \
               Tic \
               CheckTitleValue \
+              MakeImmediateReindexObjectCrashing \
               SetDifferentTitleValueWithEdit \
               CheckIfActivitiesAreCreated \
               CheckTitleValue \
               Tic \
               CheckIfMessageQueueIsEmpty \
               SetSameTitleValueWithEdit \
+              CheckIfActivitiesAreCreated \
+              CheckTitleValue \
+              Tic \
               CheckIfMessageQueueIsEmpty \
               SetDifferentTitleValueWithEdit \
               CheckIfActivitiesAreCreated \
@@ -243,6 +267,28 @@ class TestBase(ERP5TypeTestCase):
               CheckIfMessageQueueIsEmpty \
               '
     sequence_list.addSequenceString(sequence_string)
+    # Test with workflows associated to the portal type, excluding edit_workflow
+    sequence_string = '\
+              AssociateWorkflowsExcludingEdit \
+              CreateObject \
+              Tic \
+              CheckTitleValue \
+              MakeImmediateReindexObjectCrashing \
+              SetDifferentTitleValueWithEdit \
+              CheckIfActivitiesAreCreated \
+              CheckTitleValue \
+              Tic \
+              CheckIfMessageQueueIsEmpty \
+              SetSameTitleValueWithEdit \
+              CheckIfMessageQueueIsEmpty \
+              CheckTitleValue \
+              SetDifferentTitleValueWithEdit \
+              CheckIfActivitiesAreCreated \
+              CheckTitleValue \
+              Tic \
+              CheckIfMessageQueueIsEmpty \
+              '
+    sequence_list.addSequenceString(sequence_string)
     sequence_list.play(self)
 
   def stepCheckGroupValue(self, sequence=None, sequence_list=None, **kw):
@@ -296,6 +342,7 @@ class TestBase(ERP5TypeTestCase):
               CreateObject \
               Tic \
               CheckGroupValue \
+              MakeImmediateReindexObjectCrashing \
               SetDifferentGroupValueWithEdit \
               CheckIfActivitiesAreCreated \
               CheckGroupValue \
@@ -316,6 +363,31 @@ class TestBase(ERP5TypeTestCase):
               CreateObject \
               Tic \
               CheckGroupValue \
+              MakeImmediateReindexObjectCrashing \
+              SetDifferentGroupValueWithEdit \
+              CheckIfActivitiesAreCreated \
+              CheckGroupValue \
+              Tic \
+              CheckIfMessageQueueIsEmpty \
+              SetSameGroupValueWithEdit \
+              CheckIfActivitiesAreCreated \
+              CheckGroupValue \
+              Tic \
+              CheckIfMessageQueueIsEmpty \
+              SetDifferentGroupValueWithEdit \
+              CheckIfActivitiesAreCreated \
+              CheckGroupValue \
+              Tic \
+              CheckIfMessageQueueIsEmpty \
+              '
+    sequence_list.addSequenceString(sequence_string)
+    # Test with workflows associated to the portal type, excluding edit_workflow
+    sequence_string = '\
+              AssociateWorkflowsExcludingEdit \
+              CreateObject \
+              Tic \
+              CheckGroupValue \
+              MakeImmediateReindexObjectCrashing \
               SetDifferentGroupValueWithEdit \
               CheckIfActivitiesAreCreated \
               CheckGroupValue \
@@ -367,12 +439,16 @@ class TestBase(ERP5TypeTestCase):
               CreateObject \
               Tic \
               CheckTitleValue \
+              MakeImmediateReindexObjectCrashing \
               SetDifferentTitleValueWithSetter \
               CheckIfActivitiesAreCreated \
               CheckTitleValue \
               Tic \
               CheckIfMessageQueueIsEmpty \
               SetSameTitleValueWithSetter \
+              CheckIfActivitiesAreCreated \
+              CheckTitleValue \
+              Tic \
               CheckIfMessageQueueIsEmpty \
               SetDifferentTitleValueWithSetter \
               CheckIfActivitiesAreCreated \
@@ -387,12 +463,16 @@ class TestBase(ERP5TypeTestCase):
               CreateObject \
               Tic \
               CheckTitleValue \
+              MakeImmediateReindexObjectCrashing \
               SetDifferentTitleValueWithSetter \
               CheckIfActivitiesAreCreated \
               CheckTitleValue \
               Tic \
               CheckIfMessageQueueIsEmpty \
               SetSameTitleValueWithSetter \
+              CheckIfActivitiesAreCreated \
+              CheckTitleValue \
+              Tic \
               CheckIfMessageQueueIsEmpty \
               SetDifferentTitleValueWithSetter \
               CheckIfActivitiesAreCreated \
@@ -445,12 +525,16 @@ class TestBase(ERP5TypeTestCase):
               CreateObject \
               Tic \
               CheckGroupValue \
+              MakeImmediateReindexObjectCrashing \
               SetDifferentGroupValueWithSetter \
               CheckIfActivitiesAreCreated \
               CheckGroupValue \
               Tic \
               CheckIfMessageQueueIsEmpty \
               SetSameGroupValueWithSetter \
+              CheckIfActivitiesAreCreated \
+              CheckGroupValue \
+              Tic \
               CheckIfMessageQueueIsEmpty \
               SetDifferentGroupValueWithSetter \
               CheckIfActivitiesAreCreated \
@@ -465,12 +549,16 @@ class TestBase(ERP5TypeTestCase):
               CreateObject \
               Tic \
               CheckGroupValue \
+              MakeImmediateReindexObjectCrashing \
               SetDifferentGroupValueWithSetter \
               CheckIfActivitiesAreCreated \
               CheckGroupValue \
               Tic \
               CheckIfMessageQueueIsEmpty \
               SetSameGroupValueWithSetter \
+              CheckIfActivitiesAreCreated \
+              CheckGroupValue \
+              Tic \
               CheckIfMessageQueueIsEmpty \
               SetDifferentGroupValueWithSetter \
               CheckIfActivitiesAreCreated \
-- 
2.30.9