refactoring

This commit is contained in:
Matthias Bisping 2022-04-05 22:53:26 +02:00
parent b1efb5ed09
commit 6e5d6912ed

View File

@ -1,3 +1,5 @@
from itertools import starmap
import fpdf
import pytest
from funcy import merge
@ -8,27 +10,29 @@ from test.conftest import get_base_position_metadata, add_image, random_single_c
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):
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 patch in patches_metadata:
image = random_single_color_image_from_metadata(patch)
add_image(pdf, ImageMetadataPair(image, patch))
for pair in patch_image_metadata_pairs:
add_image(pdf, pair)
pdf.output("/tmp/bla.pdf")
@pytest.fixture()
@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):
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
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