aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tests/test_pdf.py
blob: b4d1940a1a0931c9d97ad26d52980d3cc0ef7fc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# GNU MediaGoblin -- federated, autonomous media hosting
# Copyright (C) 2013 MediaGoblin contributors.  See AUTHORS.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import tempfile
import shutil
import os
import pytest

from mediagoblin.media_types.pdf.processing import (
    pdf_info, check_prerequisites, create_pdf_thumb)
from .resources import GOOD_PDF as GOOD


@pytest.mark.skipif("not check_prerequisites()")
def test_pdf():
    good_dict = {'pdf_version_major': 1, 'pdf_title': '',
        'pdf_page_size_width': 612, 'pdf_author': '',
        'pdf_keywords': '', 'pdf_pages': 10,
        'pdf_producer': 'dvips + GNU Ghostscript 7.05',
        'pdf_version_minor': 3,
        'pdf_creator': 'LaTeX with hyperref package',
        'pdf_page_size_height': 792}
    assert pdf_info(GOOD) == good_dict
    temp_dir = tempfile.mkdtemp()
    create_pdf_thumb(GOOD, os.path.join(temp_dir, 'good_256_256.png'), 256, 256)
    shutil.rmtree(temp_dir)