mirror of
https://github.com/python-escpos/python-escpos
synced 2025-08-24 09:03:34 +00:00
allow qr to set all arguments to image (#600)
* allow qr to set all arguments to image * increase coverage
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
"""
|
||||
|
||||
|
||||
import warnings
|
||||
|
||||
import mock
|
||||
import pytest
|
||||
from PIL import Image
|
||||
@@ -29,10 +31,47 @@ def test_type_of_object_passed_to_image_function(img_function):
|
||||
assert isinstance(args[0], Image.Image)
|
||||
|
||||
|
||||
@mock.patch("escpos.printer.Dummy.image", spec=Dummy)
|
||||
def test_parameter_image_arguments_passed_to_image_function(img_function):
|
||||
"""Test the parameter passed to non-native qr printing."""
|
||||
d = Dummy()
|
||||
d.qr(
|
||||
"LoremIpsum",
|
||||
native=False,
|
||||
image_arguments={
|
||||
"impl": "bitImageColumn",
|
||||
"high_density_vertical": False,
|
||||
"center": True,
|
||||
},
|
||||
)
|
||||
args, kwargs = img_function.call_args
|
||||
assert "impl" in kwargs
|
||||
assert kwargs["impl"] == "bitImageColumn"
|
||||
assert "high_density_vertical" in kwargs
|
||||
assert kwargs["high_density_vertical"] is False
|
||||
assert "center" in kwargs
|
||||
assert kwargs["center"]
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def instance():
|
||||
return Dummy()
|
||||
|
||||
|
||||
def test_center(instance):
|
||||
"""Test printing qr codes."""
|
||||
instance.qr("LoremIpsum", center=True)
|
||||
|
||||
|
||||
def test_deprecated_arguments(instance):
|
||||
"""Test deprecation warning."""
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
# cause all warnings to always be triggered
|
||||
warnings.simplefilter("always")
|
||||
instance.qr(
|
||||
"LoremIpsum",
|
||||
impl="bitImageRaster",
|
||||
image_arguments={"impl": "bitImageColumn"},
|
||||
)
|
||||
assert issubclass(w[-1].category, DeprecationWarning)
|
||||
assert "deprecated" in str(w[-1].message)
|
||||
|
Reference in New Issue
Block a user