# 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)
PDF_SIG = b'25504446'


@pytest.fixture
def directory(tmpdir):
    return str(tmpdir)


@pytest.fixture(scope="function", autouse=True)
def setup_filesystem(directory):
    shutil.rmtree(directory)
    os.makedirs(directory, exist_ok=True)


class TestPdfExporter:
    '''
    The PdfExporter uses the `report-lab` library to turn tiffs into pdfs.
    However, opening and verifying pdfs for testing purposes is a paid feature of
    `report-lab`. Instead we will manually open them and just check the signature.
    '''

    @pytest.mark.parametrize("file_name", [
        ('test.tif'),
        ('test_multipage.tif'),
        ('test_ratio.tif'),
        # On old Pillow versions this would fail to open. Should open fin on 4.3.0
        ('test_broken.tif'),
    ])
    def test_single_page_tiff(self, directory, file_name):
        source_file_path = os.path.join(BASE, 'files', file_name)

# 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)

PDF_SIG = b'25504446'


@pytest.fixture
def directory(tmpdir):
    return str(tmpdir)


@pytest.fixture(scope="function", autouse=True)
def setup_filesystem(directory):
    shutil.rmtree(directory)
    os.makedirs(directory, exist_ok=True)


class TestPdfExporter:
    '''
    The PdfExporter uses the `report-lab` library to turn tiffs into pdfs.
    However, opening and verifying pdfs for testing purposes is a paid feature of
    `report-lab`. Instead we will manually open them and just check the signature.
    '''

    @pytest.mark.parametrize("file_name", [
        ('test.tif'),
        ('test_multipage.tif'),
        ('test_ratio.tif'),
        # On old Pillow versions this would fail to open. Should open fin on 4.3.0
        ('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))