From 51371fcf7765ef312c5ba1b9c8c1b227f3055d1f Mon Sep 17 00:00:00 2001
From: Gabriel Monnerat <gabriel@tiolive.com>
Date: Mon, 21 Feb 2011 14:05:25 +0000
Subject: [PATCH] load env-PATH in HandlerTestCase and pass it to PDFHandler as
 env

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@43524 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 cloudooo/handler/pdf/handler.py              | 2 --
 cloudooo/handler/pdf/tests/testPDFHandler.py | 7 +++++--
 cloudooo/handler/tests/handlerTestCase.py    | 1 +
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/cloudooo/handler/pdf/handler.py b/cloudooo/handler/pdf/handler.py
index 757c929..59977c8 100644
--- a/cloudooo/handler/pdf/handler.py
+++ b/cloudooo/handler/pdf/handler.py
@@ -48,7 +48,6 @@ class PDFHandler(object):
     """ Convert a pdf document """
     output_url = mktemp(suffix=".%s" % destination_format,
                         dir=self.document.directory_name)
-    # XXX - refactor to use the binary provided by erp5 buildout
     command = ["pdftotext", self.document.getUrl(), output_url]
     stdout, stderr = Popen(command,
                            stdout=PIPE,
@@ -63,7 +62,6 @@ class PDFHandler(object):
     """Returns a dictionary with all metadata of document.
     along with the metadata.
     """
-    # XXX - refactor to use the binary provided by erp5 buildout
     command = ["pdfinfo", self.document.getUrl()]
     stdout, stderr = Popen(command,
                            stdout=PIPE,
diff --git a/cloudooo/handler/pdf/tests/testPDFHandler.py b/cloudooo/handler/pdf/tests/testPDFHandler.py
index f5af50a..2efdadd 100644
--- a/cloudooo/handler/pdf/tests/testPDFHandler.py
+++ b/cloudooo/handler/pdf/tests/testPDFHandler.py
@@ -35,17 +35,20 @@ from types import DictType
 
 class TestPDFHandler(HandlerTestCase):
 
+  def afterSetUp(self):
+    self.kw = dict(env=dict(PATH=self.env_path))
+
   def testConvertPDFtoText(self):
     """Test conversion of pdf to txt"""
     pdf_document = open("data/test.pdf").read()
-    handler = PDFHandler(self.tmp_url, pdf_document, "pdf")
+    handler = PDFHandler(self.tmp_url, pdf_document, "pdf", **self.kw)
     txt_document = handler.convert("txt")
     self.assertTrue(txt_document.startswith("UNG Docs Architecture"))
 
   def testgetMetadata(self):
     """Test if the metadata are extracted correctly"""
     pdf_document = open("data/test.pdf").read()
-    handler = PDFHandler(self.tmp_url, pdf_document, "pdf")
+    handler = PDFHandler(self.tmp_url, pdf_document, "pdf", **self.kw)
     metadata = handler.getMetadata()
     self.assertEquals(type(metadata), DictType)
     self.assertNotEquals(metadata, {})
diff --git a/cloudooo/handler/tests/handlerTestCase.py b/cloudooo/handler/tests/handlerTestCase.py
index c7383d0..461370e 100644
--- a/cloudooo/handler/tests/handlerTestCase.py
+++ b/cloudooo/handler/tests/handlerTestCase.py
@@ -56,6 +56,7 @@ class HandlerTestCase(unittest.TestCase):
     self.openoffice_port = config.get("app:main", "openoffice_port")
     self.office_binary_path = config.get("app:main", "office_binary_path")
     self.python_path = sys.executable
+    self.env_path = config.get("app:main", "env-path")
     self.working_path = config.get("app:main", "working_path")
     self.tmp_url = path.join(self.working_path, "tmp")
     check_folder(self.working_path, self.tmp_url)
-- 
2.30.9