Test the 'printers' property
This commit is contained in:
parent
5019b88430
commit
3fb5ce27a1
@ -65,6 +65,7 @@ def test_open(cupsprinter, caplog, mocker):
|
|||||||
mocker.patch("escpos.printer.CupsPrinter.printers", new={"test_printer": "Test"})
|
mocker.patch("escpos.printer.CupsPrinter.printers", new={"test_printer": "Test"})
|
||||||
|
|
||||||
cupsprinter.printer_name = "test_printer"
|
cupsprinter.printer_name = "test_printer"
|
||||||
|
assert cupsprinter.printer_name in cupsprinter.printers
|
||||||
|
|
||||||
with caplog.at_level(logging.INFO):
|
with caplog.at_level(logging.INFO):
|
||||||
cupsprinter.open()
|
cupsprinter.open()
|
||||||
|
@ -65,6 +65,7 @@ def test_open(lpprinter, caplog, mocker):
|
|||||||
mocker.patch("escpos.printer.LP.printers", new={"test_printer": "Test"})
|
mocker.patch("escpos.printer.LP.printers", new={"test_printer": "Test"})
|
||||||
|
|
||||||
lpprinter.printer_name = "test_printer"
|
lpprinter.printer_name = "test_printer"
|
||||||
|
assert lpprinter.printer_name in lpprinter.printers
|
||||||
|
|
||||||
with caplog.at_level(logging.INFO):
|
with caplog.at_level(logging.INFO):
|
||||||
lpprinter.open()
|
lpprinter.open()
|
||||||
|
@ -67,6 +67,10 @@ def test_open(win32rawprinter, caplog, mocker):
|
|||||||
THEN check the success is logged and the device property is set
|
THEN check the success is logged and the device property is set
|
||||||
"""
|
"""
|
||||||
mocker.patch("win32print.__init__")
|
mocker.patch("win32print.__init__")
|
||||||
|
mocker.patch("escpos.printer.Win32Raw.printers", new={"test_printer": "Test"})
|
||||||
|
|
||||||
|
win32rawprinter.printer_name = "test_printer"
|
||||||
|
assert win32rawprinter.printer_name in win32rawprinter.printers
|
||||||
|
|
||||||
with caplog.at_level(logging.INFO):
|
with caplog.at_level(logging.INFO):
|
||||||
win32rawprinter.open()
|
win32rawprinter.open()
|
||||||
@ -83,6 +87,9 @@ def test_close_on_reopen(win32rawprinter, mocker):
|
|||||||
"""
|
"""
|
||||||
mocker.patch("win32print.__init__")
|
mocker.patch("win32print.__init__")
|
||||||
spy = mocker.spy(win32rawprinter, "close")
|
spy = mocker.spy(win32rawprinter, "close")
|
||||||
|
mocker.patch("escpos.printer.Win32Raw.printers", new={"test_printer": "Test"})
|
||||||
|
|
||||||
|
win32rawprinter.printer_name = "test_printer"
|
||||||
|
|
||||||
win32rawprinter.open()
|
win32rawprinter.open()
|
||||||
assert win32rawprinter._device
|
assert win32rawprinter._device
|
||||||
@ -98,6 +105,9 @@ def test_close(win32rawprinter, mocker, caplog):
|
|||||||
THEN check the closing is logged and the device property is False
|
THEN check the closing is logged and the device property is False
|
||||||
"""
|
"""
|
||||||
mocker.patch("win32print.__init__")
|
mocker.patch("win32print.__init__")
|
||||||
|
mocker.patch("escpos.printer.Win32Raw.printers", new={"test_printer": "Test"})
|
||||||
|
|
||||||
|
win32rawprinter.printer_name = "test_printer"
|
||||||
|
|
||||||
win32rawprinter.open()
|
win32rawprinter.open()
|
||||||
with caplog.at_level(logging.INFO):
|
with caplog.at_level(logging.INFO):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user