Commit 51371fcf authored by Gabriel Monnerat's avatar Gabriel Monnerat

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
parent 03030aac
......@@ -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,
......
......@@ -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, {})
......
......@@ -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)
......
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