[Erp5-report] r7511 - in /erp5/trunk/products/ERP5: Document/ tests/

nobody at svn.erp5.org nobody at svn.erp5.org
Sun May 28 15:51:23 CEST 2006


Author: jerome
Date: Sun May 28 15:51:17 2006
New Revision: 7511

URL: http://svn.erp5.org?rev=7511&view=rev
Log:
do not iterrate on obj.objectIds() while deleting objects from obj when
removing subobjects in build, otherwise subcategories are included in
base categories.


Modified:
    erp5/trunk/products/ERP5/Document/BusinessTemplate.py
    erp5/trunk/products/ERP5/tests/testBusinessTemplate.py

Modified: erp5/trunk/products/ERP5/Document/BusinessTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/BusinessTemplate.py?rev=7511&r1=7510&r2=7511&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BusinessTemplate.py (original)
+++ erp5/trunk/products/ERP5/Document/BusinessTemplate.py Sun May 28 15:51:17 2006
@@ -431,7 +431,7 @@
         groups = deepcopy(obj.groups)
       if id_list:
         self.build_sub_objects(context, id_list, relative_url)
-        for id_ in id_list:
+        for id_ in list(id_list):
           obj._delObject(id_)
       if hasattr(aq_base(obj), 'groups'):
         obj.groups = groups
@@ -452,7 +452,7 @@
         groups = deepcopy(obj.groups)
       if len(id_list) > 0:
         self.build_sub_objects(context, id_list, relative_url)
-        for id_ in id_list:
+        for id_ in list(id_list):
           obj._delObject(id_)
       if hasattr(aq_base(obj), 'groups'):
         obj.groups = groups
@@ -759,7 +759,7 @@
         if len(id_list) > 0:
           if include_subobjects:
             self.build_sub_objects(context, id_list, relative_url)
-          for id_ in id_list:
+          for id_ in list(id_list):
             obj._delObject(id_)
         if hasattr(aq_base(obj), 'groups'):
           obj.groups = groups
@@ -781,7 +781,7 @@
       id_list = obj.objectIds()
       if id_list:
         self.build_sub_objects(context, id_list, relative_url)
-        for id_ in id_list:
+        for id_ in list(id_list):
           obj._delObject(id_)
       self._objects[relative_url] = obj
       obj.wl_clearLocks()
@@ -797,10 +797,10 @@
       id_list = obj.objectIds()
       if len(id_list) > 0 and include_sub_categories:
         self.build_sub_objects(context, id_list, relative_url)
-        for id_ in id_list:
+        for id_ in list(id_list):
           obj._delObject(id_)
       else:
-        for id_ in id_list:
+        for id_ in list(id_list):
           obj._delObject(id_)
       self._objects[relative_url] = obj
       obj.wl_clearLocks()

Modified: erp5/trunk/products/ERP5/tests/testBusinessTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testBusinessTemplate.py?rev=7511&r1=7510&r2=7511&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testBusinessTemplate.py (original)
+++ erp5/trunk/products/ERP5/tests/testBusinessTemplate.py Sun May 28 15:51:17 2006
@@ -1496,7 +1496,19 @@
     Check presence of trash tool
     """
     self.failUnless(self.getSimulationTool() is not None)
-          
+  
+  def stepCheckSubobjectsNotIncluded(self, sequence=None,
+                                     sequence_list=None, **kw):
+    """Check subobjects are not included in the base category.
+    """
+    base_category_id = sequence.get('bc_id')
+    bt = sequence.get('current_bt')
+    # XXX maybe too low level
+    base_category_obj = bt._category_item._objects.get(
+        'portal_categories/%s' % base_category_id)
+    self.failUnless(base_category_obj is not None)
+    self.assertEquals(len(base_category_obj.objectIds()), 0)
+
   # tests
   def test_01_checkNewSite(self, quiet=0, run=run_all_test):
     if not run: return
@@ -2640,7 +2652,31 @@
                        RemoveBusinessTemplate \
                        '
     sequence_list.addSequenceString(sequence_string)
-    sequence_list.play(self)      
+    sequence_list.play(self)
+  
+  
+  def test_21_CategoryIncludeSubobjects(self, quiet=0, run=run_all_test):
+    if not run: return
+    if not quiet:
+      message = 'Test Category includes subobjects'
+      ZopeTestCase._print('\n%s ' % message)
+      LOG('Testing... ', 0, message)
+    sequence_list = SequenceList()
+    sequence_string = '\
+                       CreateBaseCategory \
+                       CreateCategories \
+                       CreateSubCategories \
+                       CreateNewBusinessTemplate \
+                       UseExportBusinessTemplate \
+                       AddBaseCategoryToBusinessTemplate \
+                       BuildBusinessTemplate \
+                       CheckBuiltBuildingState \
+                       CheckNotInstalledInstallationState \
+                       CheckSubobjectsNotIncluded \
+                       '
+    sequence_list.addSequenceString(sequence_string)
+    sequence_list.play(self)
+
 
 if __name__ == '__main__':
   framework()




More information about the Erp5-report mailing list