def test_lpstat_doc_examples(): env = { 'lpstat_printers': LpstatPrinters(context_wrap(LPSTAT_P_OUTPUT)), 'lpstat_protocol': LpstatProtocol(context_wrap(LPSTAT_V_OUTPUT)) } failed, total = doctest.testmod(lpstat, globs=env) assert failed == 0
def test_lpstat_parse_unknown_state(): lpstat = LpstatPrinters(context_wrap(LPSTAT_P_OUTPUT_UKNOWN_STATE)) assert len(lpstat.printers) == 1 unknown_printer = lpstat.printers[0] assert set(unknown_printer) == set(['name', 'status']), \ 'Printer dict should contain (only) "name" and "status" keys' assert unknown_printer['name'] == 'unknown_printer' assert unknown_printer['status'] == 'UNKNOWN'
def test_lpstat_parse(): lpstat = LpstatPrinters(context_wrap(LPSTAT_P_OUTPUT)) assert len(lpstat.printers) == 3 idle_printer = lpstat.printers[0] disabled_printer = lpstat.printers[1] processing_printer = lpstat.printers[2] assert set(idle_printer) == set(['name', 'status']), \ 'Printer dict should contain (only) "name" and "status" keys' assert idle_printer['name'] == 'idle_printer' assert idle_printer['status'] == 'IDLE' assert set(disabled_printer) == set(['name', 'status']), \ 'Printer dict should contain (only) "name" and "status" keys' assert disabled_printer['name'] == 'disabled_printer' assert disabled_printer['status'] == 'DISABLED' assert set(processing_printer) == set(['name', 'status']), \ 'Printer dict should contain (only) "name" and "status" keys' assert processing_printer['name'] == 'processing_printer' assert processing_printer['status'] == 'PROCESSING'
def test_lpstat_printer_names_by_status(status, expected_name): lpstat = LpstatPrinters(context_wrap(LPSTAT_P_OUTPUT)) names = lpstat.printer_names_by_status(status) assert names == [expected_name]