From a250eeeea85cfdde7c35433a136649dd48018c33 Mon Sep 17 00:00:00 2001
From: Yoshinori Okuji <yo@nexedi.com>
Date: Tue, 8 Mar 2005 12:50:38 +0000
Subject: [PATCH] Test XMLMatrix with portal_activities correctly. This
 miserably fails at the moment due to an unknown bug.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2662 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/tests/testXMLMatrix.py | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/product/ERP5Type/tests/testXMLMatrix.py b/product/ERP5Type/tests/testXMLMatrix.py
index 6e2cc72a2d..aed65385aa 100755
--- a/product/ERP5Type/tests/testXMLMatrix.py
+++ b/product/ERP5Type/tests/testXMLMatrix.py
@@ -43,6 +43,8 @@ from Products.ERP5.Document.DeliveryLine import DeliveryLine
 from Products.ERP5Type.Utils import cartesianProduct
 from AccessControl.SecurityManagement import newSecurityManager, noSecurityManager
 
+from zLOG import LOG
+
 class TestXMLMatrix(ERP5TypeTestCase):
 
   # Some helper methods
@@ -59,13 +61,15 @@ class TestXMLMatrix(ERP5TypeTestCase):
     return "XMLMatrix"
 
   def afterSetUp(self, quiet=1, run=1):
+    LOG('afterSetUp', 0, 'Called')
     uf = self.getPortal().acl_users
     uf._doAddUser('manager', '', ['Manager'], [])
     user = uf.getUserById('manager').__of__(uf)
     newSecurityManager(None, user)
     portal = self.getPortal()
     module = portal.purchase_order
-    order = module.newContent(id='1', portal_type='Purchase Order')
+    if '1' not in module.objectIds():
+      order = module.newContent(id='1', portal_type='Purchase Order')
 
   def test_01_RenameCellRange(self):
     ZopeTestCase._print('\nTest Rename Cell Range ')
@@ -192,7 +196,6 @@ class TestXMLMatrix(ERP5TypeTestCase):
     for place in cartesianProduct(cell_range):
       cell = matrix.newCell(*place, **kwd)
     self.tic()
-    matrix.recursiveImmediateReindexObject()
     initial_cell_id_list = map(lambda x: x.getId(),matrix.objectValues())
     for id in initial_cell_id_list:
       cell_path = url + '/' + id
@@ -202,6 +205,7 @@ class TestXMLMatrix(ERP5TypeTestCase):
     matrix.setCellRange(*cell_range, **kwd)
     self.assertEqual(matrix.getCellRange(**kwd), cell_range)
     next_cell_id_list = map(lambda x: x.getId(),matrix.objectValues())
+    LOG('checkSetCellRangeAndCatalog', 0, 'next_cell_id_list = %r, cell_range = %r' % (next_cell_id_list, cell_range))
     removed_id_list = filter(lambda x: x not in next_cell_id_list,initial_cell_id_list)
     self.tic()
     for id in next_cell_id_list:
@@ -233,13 +237,14 @@ class TestXMLMatrix(ERP5TypeTestCase):
       cell_path = url + '/' + id
       self.assertEquals(catalog.hasPath(cell_path),False)
 
-  def test_02_SetCellRangeAndCatalogWithoutActivities(self):
+  def test_02_SetCellRangeAndCatalogWithActivities(self):
+    ZopeTestCase._print('\nTest Set Cell Range And Catalog With Activities ')
+    self.checkSetCellRangeAndCatalog(active=1)
+
+  def test_03_SetCellRangeAndCatalogWithoutActivities(self):
     ZopeTestCase._print('\nTest Set Cell Range And Catalog Without Activities ')
     self.checkSetCellRangeAndCatalog(active=0)
 
-  def test_03_SetCellRangeAndCatalogWithActivities(self):
-    ZopeTestCase._print('\nTest Set Cell Range And Catalog With Activities ')
-    self.checkSetCellRangeAndCatalog(active=0)
 
 if __name__ == '__main__':
     framework()
-- 
2.30.9