Commit 76a4d92b authored by Nicolas Dumazet's avatar Nicolas Dumazet

move code copying a file from input/ to instancehome/import

to a generic method in ERP5TypeTestCase


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39492 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6e3b2741
......@@ -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(ProcessingNodeTestCase, PortalTestCase):
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.'''
......
......@@ -28,7 +28,6 @@
#
##############################################################################
import os, shutil
import unittest
import transaction
......@@ -46,22 +45,8 @@ class TestPortalTypeClass(ERP5TypeTestCase):
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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment