mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-11-25 23:01:09 -05:00
printer_status reads what the Device tab shows of the printer it is connected to: its state, progress, layer, the file printing and the temperatures, with no serial number and nothing sent to the printer. print_pause, print_resume and print_stop do what the tab's buttons do, and are refused, saying why, where the printer's state does not allow them or a job can be resumed only at the printer.
43 lines
1.7 KiB
Python
43 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""printer_status, print_pause, print_resume and print_stop with no printer connected, as the test_printer_commands
|
|
entry of tools/mcp/test-entries/windows_web.md designs them.
|
|
|
|
tools/mcp/orca_mcp.py launch
|
|
tools/mcp/test_printer_commands.py
|
|
|
|
A scratch datadir is not cut off from the account it may be signed in to, so the test reads printer_status first and
|
|
goes on only when it says no printer is connected: otherwise it fails, naming the printer it found, and calls nothing
|
|
else. Then each job command is refused no_printer_connected, and printer_status still reads no printer and no dialog
|
|
is open. It sends nothing to any printer, and exits 0 when every check passes.
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
import orca_mcp # noqa: E402
|
|
from checks import Checks, dialogs # noqa: E402
|
|
|
|
NO_PRINTER = {"connected": False}
|
|
|
|
|
|
def main():
|
|
client, _session = orca_mcp.session_client()
|
|
t = Checks()
|
|
|
|
# The guard: no job command is called while a printer is connected.
|
|
status = client.call("printer_status")
|
|
if not t.equal("no printer is connected", status, NO_PRINTER):
|
|
print(f"printer_status found {status.get('name')!r} ({status.get('model')!r}); the test calls nothing else", flush=True)
|
|
return t.exit_code()
|
|
|
|
for command in ("print_pause", "print_resume", "print_stop"):
|
|
t.refused(f"{command}: refused", lambda: client.call(command), code="no_printer_connected")
|
|
t.equal(f"{command}: printer_status still reads no printer", client.call("printer_status"), NO_PRINTER)
|
|
t.equal(f"{command}: no dialog", dialogs(client), [])
|
|
return t.exit_code()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|