[Erp5-report] r39492 nicolas.dumazet - /erp5/trunk/products/ERP5Type/tests/
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Oct 25 10:58:51 CEST 2010
Author: nicolas.dumazet
Date: Mon Oct 25 10:58:42 2010
New Revision: 39492
URL: http://svn.erp5.org?rev=39492&view=rev
Log:
move code copying a file from input/ to instancehome/import
to a generic method in ERP5TypeTestCase
Modified:
erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py
erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py
Modified: erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py?rev=39492&r1=39491&r2=39492&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py [utf8] Mon Oct 25 10:58:42 2010
@@ -15,6 +15,7 @@ import os
import random
import re
import socket
+import shutil
import sys
import time
import traceback
@@ -1016,6 +1017,28 @@ 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.
+ """
+ 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
+
def publish(self, path, basic=None, env=None, extra=None,
request_method='GET', stdin=None, handle_errors=True):
'''Publishes the object at 'path' returning a response object.'''
Modified: erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py?rev=39492&r1=39491&r2=39492&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/testDynamicClassGeneration.py [utf8] Mon Oct 25 10:58:42 2010
@@ -28,7 +28,6 @@
#
##############################################################################
-import os, shutil
import unittest
import transaction
@@ -46,22 +45,8 @@ class TestPortalTypeClass(ERP5TypeTestCa
Products.ERP5Type.Document.Person.Person type
"""
file_name = 'non_migrated_person.zexp'
- import Products.ERP5Type.tests as test_module
- test_path = test_module.__path__
- if isinstance(test_path, list):
- test_path = test_path[0]
-
- zexp_path = os.path.join(test_path, 'input', file_name)
- self.assertTrue(os.path.exists(zexp_path))
-
- import_path = os.path.join(os.environ['INSTANCE_HOME'], '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(zexp_path, import_path)
+ self.copyInputFileToImportFolder(file_name)
person_module = self.getPortal().person_module
person_module.manage_importObject(file_name)
More information about the Erp5-report
mailing list