From cfceb4176bc739ba5602898e4fe5ab0f3f8c2fa3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Tue, 3 Apr 2007 07:51:52 +0000
Subject: [PATCH] unpack the content of testIngestion_docs.zip at runtime

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13873 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5OOo/tests/testIngestion.py | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/product/ERP5OOo/tests/testIngestion.py b/product/ERP5OOo/tests/testIngestion.py
index fd717ad572..9eccf170e4 100644
--- a/product/ERP5OOo/tests/testIngestion.py
+++ b/product/ERP5OOo/tests/testIngestion.py
@@ -85,7 +85,7 @@ class FileUploadTest(file):
     self.headers = {}
 
 def makeFilePath(name):
-  return os.getenv('INSTANCE_HOME') + '/../Products/ERP5OOo/tests/' + name
+  return os.getenv('INSTANCE_HOME') + '/../Products/ERP5OOo/tests/data/' + name
 
 def makeFileUpload(name):
   path = makeFilePath(name)
@@ -128,6 +128,26 @@ class TestIngestion(ERP5TypeTestCase):
     self.createCategories()
     self.createPreferences()
     self.createTools()
+    self.unpackData()
+  
+  def unpackData(self):
+    """
+      Unpack the content of testIngestion_docs.zip
+    """
+    join = os.path.join
+    base_path = join(os.getenv('INSTANCE_HOME'), '..', 'Products', 'ERP5OOo', 'tests')
+    zf = zipfile.ZipFile(join(base_path, 'testIngestion_docs.zip'))
+    data_dir = join(base_path, 'data')
+    if not os.path.isdir(data_dir):
+      os.mkdir(data_dir)
+    for name in zf.namelist():
+      fname = join(data_dir, name)
+      if not os.path.exists(fname):
+        try:
+          f = open(fname, 'w')
+          f.write(zf.read(name))
+        finally:
+          f.close()
 
   def createTools(self):
     """
-- 
2.30.9