From a80ebf3b64dce807d84ab3993984c211f55b47db Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Wed, 27 Mar 2013 12:21:10 +0200 Subject: add pdf media type The new media type supports pdf and a subset of media recognized by libreoffice via unoconv. Every document added goes through: * conversion to pdf with unoconv if not already a pdf * creation of thumbnail and medium sized image, and pdfinfo generates some information (even for unoconv produces docs - should fix this) Poppler (pdftocairo, pdfinfo) is used. http://poppler.freedesktop.org/ A working but uglified pdf.js integration exists, which is enabled by setting pdf.pdf_js=true mediagoblin_local.ini (disabled in mediagoblin.ini) Adds one test to the test_submission test suite, and another separate test_pdf suite. The tests are only run if media_types.pdf.processing.check_prerequisites passes, so the test suite will not require any extra package. TODO: make test suite say 'skipped' in that case instead of just 'ok' Signed-off-by: Alon Levy --- mediagoblin/tests/test_submission.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'mediagoblin/tests/test_submission.py') diff --git a/mediagoblin/tests/test_submission.py b/mediagoblin/tests/test_submission.py index ac714252..462a1653 100644 --- a/mediagoblin/tests/test_submission.py +++ b/mediagoblin/tests/test_submission.py @@ -28,6 +28,7 @@ from mediagoblin import mg_globals from mediagoblin.db.models import MediaEntry from mediagoblin.tools import template from mediagoblin.media_types.image import MEDIA_MANAGER as img_MEDIA_MANAGER +from mediagoblin.media_types.pdf.processing import check_prerequisites as pdf_check_prerequisites def resource(filename): return resource_filename('mediagoblin.tests', 'test_submission/' + filename) @@ -39,6 +40,8 @@ EVIL_FILE = resource('evil') EVIL_JPG = resource('evil.jpg') EVIL_PNG = resource('evil.png') BIG_BLUE = resource('bigblue.png') +GOOD_PDF = resource('good.pdf') + from .test_exif import GPS_JPG GOOD_TAG_STRING = u'yin,yang' @@ -125,6 +128,16 @@ class TestSubmission: self._setup(test_app) self.check_normal_upload(u'Normal upload 2', GOOD_PNG) + def test_normal_pdf(self, test_app): + if not pdf_check_prerequisites(): + return + self._setup(test_app) + response, context = self.do_post({'title': u'Normal upload 3 (pdf)'}, + do_follow=True, + **self.upload_data(GOOD_PDF)) + self.check_url(response, '/u/{0}/'.format(self.test_user.username)) + assert 'mediagoblin/user_pages/user.html' in context + def check_media(self, request, find_data, count=None): media = MediaEntry.find(find_data) if count is not None: -- cgit v1.2.3