2016-08-30 11:27:48 +00:00
|
|
|
import pytest
|
|
|
|
from escpos.capabilities import get_profile, NotSupported, BARCODE_B, Profile
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def profile():
|
2021-10-30 16:15:22 +00:00
|
|
|
return get_profile("default")
|
2016-08-30 11:27:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestBaseProfile:
|
2021-10-30 16:15:22 +00:00
|
|
|
"""Test the `BaseProfile` class."""
|
2016-08-30 11:27:48 +00:00
|
|
|
|
|
|
|
def test_get_font(self, profile):
|
|
|
|
with pytest.raises(NotSupported):
|
2021-10-30 16:15:22 +00:00
|
|
|
assert profile.get_font("3")
|
2016-08-30 11:27:48 +00:00
|
|
|
assert profile.get_font(1) == 1
|
2021-10-30 16:15:22 +00:00
|
|
|
assert profile.get_font("a") == 0
|
2016-08-30 11:27:48 +00:00
|
|
|
|
|
|
|
def test_supports(self, profile):
|
2021-10-30 16:15:22 +00:00
|
|
|
assert not profile.supports("asdf asdf")
|
2016-08-30 11:27:48 +00:00
|
|
|
assert profile.supports(BARCODE_B)
|
|
|
|
|
|
|
|
def test_get_columns(self, profile):
|
2021-10-30 16:15:22 +00:00
|
|
|
assert profile.get_columns("a") > 5
|
2016-08-30 11:27:48 +00:00
|
|
|
with pytest.raises(NotSupported):
|
2021-10-30 16:15:22 +00:00
|
|
|
assert profile.get_columns("asdfasdf")
|
2016-08-30 11:27:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestCustomProfile:
|
2021-10-30 16:15:22 +00:00
|
|
|
"""Test custom profile options with the `Profile` class."""
|
2016-08-30 11:27:48 +00:00
|
|
|
|
|
|
|
def test_columns(self):
|
2021-10-30 16:15:22 +00:00
|
|
|
assert Profile(columns=10).get_columns("sdfasdf") == 10
|
2016-08-30 11:27:48 +00:00
|
|
|
|
|
|
|
def test_features(self):
|
2021-10-30 16:15:22 +00:00
|
|
|
assert Profile(features={"foo": True}).supports("foo")
|