adapt behavior of cups printer to match other implementations

This commit is contained in:
Patrick Kanzler 2023-12-16 21:57:36 +01:00
parent 5c5acff16c
commit b634354c99
2 changed files with 5 additions and 5 deletions

View File

@ -205,9 +205,9 @@ class CupsPrinter(Escpos):
"""
printer = self.printers.get(self.printer_name, {})
state = printer.get("printer-state")
if not state:
return b""
return bytes((state,))
if not state or state in [4, 5]:
return b"8" # offline
return b"0" # online
def close(self) -> None:
"""Close CUPS connection.

View File

@ -170,7 +170,7 @@ def test_read_no_device(cupsprinter) -> None:
"""
GIVEN a cups printer object
WHEN device is None
THEN check the return value is b''
THEN check the return value is b'8'
"""
cupsprinter.device = None
assert cupsprinter._read() == b""
assert cupsprinter._read() == b"8"