# Path: mfr/extensions/pdf/settings.py
# EXPORT_TYPE = config.get('EXPORT_TYPE', 'pdf')
# EXPORT_MAXIMUM_SIZE = config.get('EXPORT_MAXIMUM_SIZE', '1200x1200')
# ENABLE_HYPOTHESIS = config.get_bool('ENABLE_HYPOTHESIS', True)
# EXPORT_SUPPORTED = config.get('EXPORT_SUPPORTED', '.tiff .tif').split(' ')
# EXPORT_MAX_PAGES = int(config.get('EXPORT_MAX_PAGES', 40))
# 
# Path: mfr/extensions/pdf/exceptions.py
# class PillowImageError(ExporterError):
#     __TYPE = 'pdf_pillow'
#     def __init__(self, message, *args, export_format: str='', detected_format: str='',
#                  original_exception: Exception=None, **kwargs):


import os
import shutil
import binascii
import pytest
from mfr.extensions.pdf import (settings,
                                exceptions,
                                PdfExporter)
        ('test_broken.tif'),
    ])
    def test_single_page_tiff(self, directory, file_name):
        source_file_path = os.path.join(BASE, 'files', file_name)
        output_file_path = os.path.join(directory, 'test.{}'.format(settings.EXPORT_TYPE))
        format = '{}.{}'.format(settings.EXPORT_MAXIMUM_SIZE, settings.EXPORT_TYPE)
        exporter = PdfExporter(source_file_path=source_file_path, ext='.tif',
                               output_file_path=output_file_path, format=format,
                               metadata={'unique_key': 'moo moo moo'})

        assert not os.path.exists(output_file_path)

        exporter.export()

        assert os.path.exists(output_file_path)
        # Open file to check that the exported PDF contains the proper signature
        with open(output_file_path, 'rb') as file:
            # the first 4 bytes contain the signature
            assert binascii.hexlify(file.read(4)) == PDF_SIG

    def test_bad_tiff(self, directory):
        source_file_path = os.path.join(BASE, 'files', 'invalid.tif')
        output_file_path = os.path.join(directory, 'test.{}'.format(settings.EXPORT_TYPE))
        format = '{}.{}'.format(settings.EXPORT_MAXIMUM_SIZE, settings.EXPORT_TYPE)
        exporter = PdfExporter(source_file_path=source_file_path, ext='.tif',
                               output_file_path=output_file_path, format=format,
                               metadata={'unique_key': 'moo moo moo'})

        assert not os.path.exists(output_file_path)


# Path: mfr/extensions/pdf/settings.py
# EXPORT_TYPE = config.get('EXPORT_TYPE', 'pdf')
# EXPORT_MAXIMUM_SIZE = config.get('EXPORT_MAXIMUM_SIZE', '1200x1200')
# ENABLE_HYPOTHESIS = config.get_bool('ENABLE_HYPOTHESIS', True)
# EXPORT_SUPPORTED = config.get('EXPORT_SUPPORTED', '.tiff .tif').split(' ')
# EXPORT_MAX_PAGES = int(config.get('EXPORT_MAX_PAGES', 40))
# 
# Path: mfr/extensions/pdf/exceptions.py
# class PillowImageError(ExporterError):
#     __TYPE = 'pdf_pillow'
#     def __init__(self, message, *args, export_format: str='', detected_format: str='',
#                  original_exception: Exception=None, **kwargs):


# Path: tests/extensions/pdf/test_exporter.py
import os
import shutil
import binascii
import pytest
from mfr.extensions.pdf import (settings,
                                exceptions,
                                PdfExporter)

        ('test_broken.tif'),
    ])
    def test_single_page_tiff(self, directory, file_name):
        source_file_path = os.path.join(BASE, 'files', file_name)
        output_file_path = os.path.join(directory, 'test.{}'.format(settings.EXPORT_TYPE))
        format = '{}.{}'.format(settings.EXPORT_MAXIMUM_SIZE, settings.EXPORT_TYPE)
        exporter = PdfExporter(source_file_path=source_file_path, ext='.tif',
                               output_file_path=output_file_path, format=format,
                               metadata={'unique_key': 'moo moo moo'})

        assert not os.path.exists(output_file_path)

        exporter.export()

        assert os.path.exists(output_file_path)
        # Open file to check that the exported PDF contains the proper signature
        with open(output_file_path, 'rb') as file:
            # the first 4 bytes contain the signature
            assert binascii.hexlify(file.read(4)) == PDF_SIG

    def test_bad_tiff(self, directory):
        source_file_path = os.path.join(BASE, 'files', 'invalid.tif')
        output_file_path = os.path.join(directory, 'test.{}'.format(settings.EXPORT_TYPE))
        format = '{}.{}'.format(settings.EXPORT_MAXIMUM_SIZE, settings.EXPORT_TYPE)
        exporter = PdfExporter(source_file_path=source_file_path, ext='.tif',
                               output_file_path=output_file_path, format=format,
                               metadata={'unique_key': 'moo moo moo'})

        assert not os.path.exists(output_file_path)


        with pytest.raises(exceptions.PillowImageError):