[Erp5-report] r39579 jm - in /erp5/trunk/products/ERP5Type: patches/ tests/ tests/input/

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Oct 27 21:03:35 CEST 2010


Author: jm
Date: Wed Oct 27 21:03:34 2010
New Revision: 39579

URL: http://svn.erp5.org?rev=39579&view=rev
Log:
Unit tests: improve import of a single object from file

- new ERP5TypeTestCase.importObjectFromFile
- import file directly without copying first to an import folder
  (in particular, do not pollute existing 'import' folder)
- fix uid issue by calling manage_afterClone
- convert testDynamicClassGeneration data from ZEXP to XML

Added:
    erp5/trunk/products/ERP5Type/tests/input/non_migrated_person.xml
Removed:
    erp5/trunk/products/ERP5Type/tests/input/non_migrated_person.zexp
Modified:
    erp5/trunk/products/ERP5Type/patches/ObjectManager.py
    erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py
    erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py

Modified: erp5/trunk/products/ERP5Type/patches/ObjectManager.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/patches/ObjectManager.py?rev=39579&r1=39578&r2=39579&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/patches/ObjectManager.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/patches/ObjectManager.py [utf8] Wed Oct 27 21:03:34 2010
@@ -12,7 +12,7 @@
 #
 ##############################################################################
 
-# Import: add rename feature
+# Import: add rename feature and make _importObjectFromFile return the object
 from OFS.ObjectManager import ObjectManager, customImporters
 
 def ObjectManager_importObjectFromFile(self, filepath, verify=1, set_owner=1, id=None):
@@ -36,5 +36,6 @@ def ObjectManager_importObjectFromFile(s
     # that the object was imported into.
     ob=self._getOb(id)
     ob.manage_changeOwnershipType(explicit=0)
+    return ob
 
 ObjectManager._importObjectFromFile=ObjectManager_importObjectFromFile

Modified: erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py?rev=39579&r1=39578&r2=39579&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py [utf8] Wed Oct 27 21:03:34 2010
@@ -1020,27 +1020,14 @@ class ERP5TypeTestCase(ProcessingNodeTes
         transaction.commit()
       self.tic()
 
-    def copyInputFileToImportFolder(self, relative_path):
-      """
-      Copies a file located in $TESTFILEDIR/input/ to
-      import/ folder of test instance and returns the
-      full path.
-      If files already exists, overwrites it.
-      """
+    def importObjectFromFile(self, container, relative_path, **kw):
+      """Import an object from a file located in $TESTFILEDIR/input/"""
       test_path = os.path.dirname(__file__)
-
       source_path = os.path.join(test_path, 'input', relative_path)
-      self.assertTrue(os.path.exists(source_path))
-
-      import_path = os.path.join(instancehome, 'import')
-      if not os.path.exists(import_path):
-        if os.path.islink(import_path):
-          # broken symlink
-          os.unlink(import_path)
-        os.mkdir(import_path)
-
-      shutil.copy(source_path, import_path)
-      return import_path
+      assert os.path.exists(source_path)
+      obj = container._importObjectFromFile(source_path, **kw)
+      obj.manage_afterClone(obj)
+      return obj
 
     def publish(self, path, basic=None, env=None, extra=None,
                 request_method='GET', stdin=None, handle_errors=True):

Added: erp5/trunk/products/ERP5Type/tests/input/non_migrated_person.xml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/input/non_migrated_person.xml?rev=39579&view=auto
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/input/non_migrated_person.xml (added)
+++ erp5/trunk/products/ERP5Type/tests/input/non_migrated_person.xml [utf8] Wed Oct 27 21:03:34 2010
@@ -0,0 +1,88 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <global name="Person" module="Products.ERP5Type.Document.Person"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_Access_contents_information_Permission</string> </key>
+            <value>
+              <tuple>
+                <string>Assignee</string>
+                <string>Assignor</string>
+                <string>Associate</string>
+                <string>Auditor</string>
+                <string>Author</string>
+                <string>Manager</string>
+                <string>Owner</string>
+              </tuple>
+            </value>
+        </item>
+        <item>
+            <key> <string>_Add_portal_content_Permission</string> </key>
+            <value>
+              <tuple>
+                <string>Assignee</string>
+                <string>Assignor</string>
+                <string>Associate</string>
+                <string>Author</string>
+                <string>Manager</string>
+                <string>Owner</string>
+              </tuple>
+            </value>
+        </item>
+        <item>
+            <key> <string>_Modify_portal_content_Permission</string> </key>
+            <value>
+              <tuple>
+                <string>Assignee</string>
+                <string>Assignor</string>
+                <string>Associate</string>
+                <string>Author</string>
+                <string>Manager</string>
+                <string>Owner</string>
+              </tuple>
+            </value>
+        </item>
+        <item>
+            <key> <string>_View_Permission</string> </key>
+            <value>
+              <tuple>
+                <string>Assignee</string>
+                <string>Assignor</string>
+                <string>Associate</string>
+                <string>Auditor</string>
+                <string>Author</string>
+                <string>Manager</string>
+                <string>Owner</string>
+              </tuple>
+            </value>
+        </item>
+        <item>
+            <key> <string>description</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>first_name</string> </key>
+            <value> <string>non-migrated</string> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>non_migrated_person</string> </value>
+        </item>
+        <item>
+            <key> <string>last_name</string> </key>
+            <value> <string>Person</string> </value>
+        </item>
+        <item>
+            <key> <string>portal_type</string> </key>
+            <value> <string>Person</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>

Removed: erp5/trunk/products/ERP5Type/tests/input/non_migrated_person.zexp
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/input/non_migrated_person.zexp?rev=39578&view=auto
==============================================================================
Binary file - no diff available.

Modified: erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py?rev=39579&r1=39578&r2=39579&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py [utf8] Wed Oct 27 21:03:34 2010
@@ -44,13 +44,8 @@ class TestPortalTypeClass(ERP5TypeTestCa
     Import a .zexp containing a Person created with an old
     Products.ERP5Type.Document.Person.Person type
     """
-    file_name = 'non_migrated_person.zexp'
-
-    self.copyInputFileToImportFolder(file_name)
-
-    person_module = self.getPortal().person_module
-    person_module.manage_importObject(file_name)
-
+    person_module = self.portal.person_module
+    self.importObjectFromFile(person_module, 'non_migrated_person.xml')
     transaction.commit()
 
     non_migrated_person = person_module.non_migrated_person




More information about the Erp5-report mailing list