diff options
author | Alon Levy <alon@pobox.com> | 2013-03-27 12:21:10 +0200 |
---|---|---|
committer | Alon Levy <alon@pobox.com> | 2013-04-15 09:51:21 +0300 |
commit | a80ebf3b64dce807d84ab3993984c211f55b47db (patch) | |
tree | 2e8eaebf18414ee511c0dc476a2be8d78253e46f /mediagoblin/tests/test_submission.py | |
parent | 3cadb4a6cd1d5cfdef8712d00e4594345a15b4a7 (diff) | |
download | mediagoblin-a80ebf3b64dce807d84ab3993984c211f55b47db.tar.lz mediagoblin-a80ebf3b64dce807d84ab3993984c211f55b47db.tar.xz mediagoblin-a80ebf3b64dce807d84ab3993984c211f55b47db.zip |
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 <alon@pobox.com>
Diffstat (limited to 'mediagoblin/tests/test_submission.py')
-rw-r--r-- | mediagoblin/tests/test_submission.py | 13 |
1 files changed, 13 insertions, 0 deletions
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: |