Matthias Bisping 64e3350dee refactoring
2022-04-05 19:35:13 +02:00

35 lines
1.2 KiB
Python

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
def test_image_stitcher(partial_image_metadata_pairs):
pass
@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(patches_metadata, page_width, page_height):
pdf = fpdf.FPDF(unit="pt", format=(page_width, page_height))
for patch in patches_metadata:
image = random_single_color_image_from_metadata(patch)
add_image(pdf, ImageMetadataPair(image, patch))
pdf.output("/tmp/bla.pdf")
@pytest.fixture()
def patches_metadata(width, height, page_width, page_height):
box = get_base_position_metadata(width, height, page_width, page_height)
box = merge(box, {Info.X1: 0, Info.Y1: 0, Info.X2: width, Info.Y2: height})
boxes = BoxSplitter().split_box(box)
return boxes