39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
from itertools import starmap
|
|
|
|
import fpdf
|
|
import pytest
|
|
from funcy import merge
|
|
|
|
from image_prediction.image_extractor.extractor import ImageMetadataPair
|
|
from image_prediction.info import Info
|
|
from test.conftest import get_base_position_metadata, add_image, random_single_color_image_from_metadata
|
|
from test.utils.stitching import BoxSplitter
|
|
|
|
|
|
@pytest.mark.parametrize("width", [160])
|
|
@pytest.mark.parametrize("height", [90])
|
|
@pytest.mark.parametrize("page_width", [int(160 * 1.1)])
|
|
@pytest.mark.parametrize("page_height", [int(90 * 1.1)])
|
|
def test_partial_image_metadata_pairs(patch_image_metadata_pairs, page_width, page_height):
|
|
|
|
pdf = fpdf.FPDF(unit="pt", format=(page_width, page_height))
|
|
|
|
for pair in patch_image_metadata_pairs:
|
|
add_image(pdf, pair)
|
|
|
|
pdf.output("/tmp/bla.pdf")
|
|
|
|
|
|
@pytest.fixture
|
|
def patch_image_metadata_pairs(patches_metadata):
|
|
images = map(random_single_color_image_from_metadata, patches_metadata)
|
|
return starmap(ImageMetadataPair, zip(images, patches_metadata))
|
|
|
|
|
|
@pytest.fixture
|
|
def patches_metadata(width, height, page_width, page_height):
|
|
metadata = get_base_position_metadata(width, height, page_width, page_height)
|
|
metadata = merge(metadata, {Info.X1: 0, Info.Y1: 0, Info.X2: width, Info.Y2: height})
|
|
patches_metadata = BoxSplitter().split_box(metadata)
|
|
return patches_metadata
|