check for wrong printer names

This commit is contained in:
Patrick Kanzler 2023-12-06 00:15:43 +01:00
parent ab95f714a6
commit 2e9d5a9871

View File

@ -31,8 +31,8 @@ def simple_printer_test(config):
assert p.output == b"1234"
def test_config_load_with_invalid_config(tmp_path):
"""Test the loading of a config with a invalid config file."""
def test_config_load_with_invalid_config_yaml(tmp_path):
"""Test the loading of a config with a invalid config file (yaml issue)."""
# generate a dummy config
config_file = tmp_path / "config.yaml"
generate_dummy_config(config_file, content="}invalid}yaml}")
@ -45,6 +45,22 @@ def test_config_load_with_invalid_config(tmp_path):
c.load(config_path=config_file)
def test_config_load_with_invalid_config_content(tmp_path):
"""Test the loading of a config with a invalid config file (content issue)."""
# generate a dummy config
config_file = tmp_path / "config.yaml"
generate_dummy_config(
config_file, content="printer:\n type: NoPrinterWithThatName\n"
)
# test the config loading
from escpos import config
c = config.Config()
with pytest.raises(escpos.exceptions.ConfigSyntaxError):
c.load(config_path=config_file)
def test_config_load_with_missing_config(tmp_path):
"""Test the loading of a config that does not exist."""
# test the config loading