From b374e3efedda5065aab51c15cdc0ab1730da45fc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Fri, 15 Jan 2010 15:07:39 +0000
Subject: [PATCH] - create the matrix in setup - a few more assertions

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

diff --git a/product/ERP5Type/tests/testXMLMatrix.py b/product/ERP5Type/tests/testXMLMatrix.py
index 5db94d4464..3040c54483 100644
--- a/product/ERP5Type/tests/testXMLMatrix.py
+++ b/product/ERP5Type/tests/testXMLMatrix.py
@@ -70,8 +70,8 @@ class TestXMLMatrix(ERP5TypeTestCase, LogInterceptor):
     newSecurityManager(None, user)
     portal = self.getPortal()
     module = portal.purchase_order_module
-    if '1' not in module.objectIds():
-      order = module.newContent(id='1', portal_type='Purchase Order')
+    order = module.newContent(portal_type='Purchase Order')
+    self.matrix = order.newContent(portal_type='Purchase Order Line')
     self._catch_log_errors(ignored_level=PROBLEM)
 
   portal_activities_backup = None
@@ -92,11 +92,7 @@ class TestXMLMatrix(ERP5TypeTestCase, LogInterceptor):
     """
     if not quiet:
       ZopeTestCase._print('\nTest Rename Cell Range ')
-    portal = self.getPortal()
-    module = portal.purchase_order_module
-    order = module._getOb('1')
-    if order.hasContent('1'): order.deleteContent('1')
-    matrix = order.newContent(id='1', portal_type='Purchase Order Line')
+    matrix = self.matrix
 
     cell_range = [['1', '2', '3'], ['a', 'b', 'c']]
     kwd = {'base_id' : 'quantity'}
@@ -203,7 +199,7 @@ class TestXMLMatrix(ERP5TypeTestCase, LogInterceptor):
     """
     Tests if set Cell range do well catalog and uncatalog
     """
-    portal = self.getPortal()
+    portal = self.portal
     module = portal.purchase_order_module
     if not active:
       self.portal_activities_backup = portal._getOb('portal_activities')
@@ -215,9 +211,7 @@ class TestXMLMatrix(ERP5TypeTestCase, LogInterceptor):
       self.tic()
     catalog = portal.portal_catalog
 
-    order = module._getOb('1')
-    if order.hasContent('1'): order.deleteContent('1')
-    matrix = order.newContent(id='1', portal_type='Purchase Order Line')
+    matrix = self.matrix
     url = matrix.getUrl()
 
     cell_range = [['1', '2', '3'], ['a', 'b', 'c']]
@@ -241,6 +235,14 @@ class TestXMLMatrix(ERP5TypeTestCase, LogInterceptor):
     get_transaction().commit()
     self.assertEqual(matrix.getCellRange(**kwd), cell_range)
     next_cell_id_list = map(lambda x: x.getId(),matrix.objectValues())
+    # the cells on coordinates 2b, 3b, 3b and 3c are kept
+    self.assertEquals(4, len(next_cell_id_list))
+    for coord in [['2', 'b'],
+                  ['2', 'c'],
+                  ['3', 'b'],
+                  ['3', 'c']]:
+      self.assertNotEqual(None, matrix.getCell(*coord, **kwd))
+
     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:
-- 
2.30.9