From 16dbf2c338f2229dc9529628505bf7e2711f1bcb Mon Sep 17 00:00:00 2001 From: Ivan Tyagov <ivan@nexedi.com> Date: Mon, 25 Feb 2013 16:09:59 +0200 Subject: [PATCH] If original format is matched or format is empty string return original content of PDF document. Adjust test accordingly and fix bad test. --- product/ERP5/Document/PDFDocument.py | 3 ++- product/ERP5OOo/tests/testDms.py | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/product/ERP5/Document/PDFDocument.py b/product/ERP5/Document/PDFDocument.py index bbb52c748a..adbadd5b26 100644 --- a/product/ERP5/Document/PDFDocument.py +++ b/product/ERP5/Document/PDFDocument.py @@ -95,7 +95,8 @@ class PDFDocument(Image): data = self._convertToDJVU() self.setConversion(data, mime=mime, format='djvu') return (mime, data) - elif format is None: + elif format in ('', None,) or format=='pdf': + # return original content return self.getContentType(), self.getData() else: if kw.get('frame', None) is None: diff --git a/product/ERP5OOo/tests/testDms.py b/product/ERP5OOo/tests/testDms.py index 19a615f2d3..7f834c9f85 100644 --- a/product/ERP5OOo/tests/testDms.py +++ b/product/ERP5OOo/tests/testDms.py @@ -2201,9 +2201,13 @@ return 1 self.assertTrue('Content-Length: %s\r\n' %getFileSize('TEST-en-003.odp') in response.info().headers) response = getURL(pdf_document.absolute_url(), **{'format':''}) - self.assertTrue('Content-Type: application/octet-stream\r\n' in response.info().headers) + self.assertTrue('Content-Type: application/pdf\r\n' in response.info().headers) self.assertTrue('Content-Disposition: attachment; filename="TEST-en-002.pdf"\r\n' in response.info().headers) + response = getURL(pdf_document.absolute_url(), **{'format':'pdf'}) + self.assertTrue('Content-Type: application/pdf\r\n' in response.info().headers) + self.assertTrue('Content-Disposition: attachment; filename="TEST-en-002.pdf"\r\n' in response.info().headers) + response = getURL(web_page_document.absolute_url(), **{'format':''}) self.assertTrue('Content-Type: text/html; charset=utf-8\r\n' in response.info().headers) -- 2.30.9