add function for getting info about installed tape
This commit is contained in:
parent
2fda40860a
commit
26664d0b58
7 changed files with 183 additions and 3 deletions
|
|
@ -3,6 +3,8 @@ from typing import Callable
|
|||
|
||||
import pytest
|
||||
|
||||
from labeler.domain.objects import Dimension, MediaDefinition
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def current_dir(request) -> str:
|
||||
|
|
@ -23,3 +25,24 @@ def save_test_image(current_dir) -> Callable[[str, bytes], None]:
|
|||
open(os.path.join(current_dir, "test_images", name), "wb").write(data)
|
||||
|
||||
return f
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def create_test_media() -> Callable[[int, int, int, int, int], MediaDefinition]:
|
||||
def f(
|
||||
width: int,
|
||||
height: int,
|
||||
dpi: int = 600,
|
||||
margin_horizontal: int = 0,
|
||||
margin_vertical: int = 0,
|
||||
):
|
||||
return MediaDefinition(
|
||||
width=Dimension(mm=width),
|
||||
length=Dimension(mm=height),
|
||||
minimal_margin_horizontal=Dimension(mm=margin_horizontal),
|
||||
minimal_margin_vertical=Dimension(mm=margin_vertical),
|
||||
dpi=dpi,
|
||||
description=f"test media {width}mm x{height}mm @ {dpi}dpi",
|
||||
)
|
||||
|
||||
return f
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ def test_infinite_media():
|
|||
minimal_margin_vertical=Dimension(mm=1),
|
||||
minimal_margin_horizontal=Dimension(mm=2),
|
||||
dpi=300,
|
||||
description="test media",
|
||||
)
|
||||
|
||||
assert media.printable_length == Dimension(mm=math.inf)
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ def test_multiline_label(get_test_image):
|
|||
assert label.bytes == expected_label
|
||||
|
||||
|
||||
def test_simple_label_no_fixed_width(get_test_image, save_test_image):
|
||||
def test_simple_label_no_fixed_width(get_test_image):
|
||||
renderer = PILRenderer()
|
||||
expected_label = get_test_image("no_fixed_width.png")
|
||||
|
||||
|
|
@ -38,9 +38,9 @@ def test_simple_label_no_fixed_width(get_test_image, save_test_image):
|
|||
assert label.bytes == expected_label
|
||||
|
||||
|
||||
def test_multiline_label_no_fixed_width(get_test_image, save_test_image):
|
||||
def test_multiline_label_no_fixed_width(get_test_image):
|
||||
renderer = PILRenderer()
|
||||
expected_label = get_test_image("multiline_no_fixed_width.png")
|
||||
expected_label = get_test_image("multiline_label_no_fixed_width.png")
|
||||
|
||||
definition = LabelDefinition(
|
||||
text="dolphin\nis\nawesome", width=Dimension(mm=10), dpi=600
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue