Testing¶
Unit tests¶
pytest tests/
tests/test_rules.py— the rule engine: state matrix, manual mode, temperature rules (threshold, hysteresis, missing sensor,above: off), combine logic (override/AND/OR), OctoPrint state mapping.tests/test_hardware.py— the fixed channel layout.tests/test_plugin.py— the plugin's pure surface: settings defaults (includingsidebar_enabled), template registration (tab / settings / sidebar), template vars.
The test modules run without an OctoPrint installation (conftest.py
provides minimal stubs). CI runs them on Python 3.9–3.13 plus an OctoPrint
smoke import (1.10.x and devel).
What is deliberately not unit-tested¶
The plugin class's runtime glue (WS lifecycle, event handlers) and the WebSocket client's network behavior — those are covered by the end-to-end checklist below against real hardware. Mocking a firmware that was reverse engineered is a good way to test the mock.
End-to-end checklist (real Panda + printer)¶
- Configure the Panda IP, Test connection reports 10 channels.
- Tab shows live state; manual toggle switches the physical output.
- Rule
printing → on, idle → offon a scratch channel: start/stop a print — the channel follows (including the deferred retry when the rate limit window swallows the first attempt). - Temperature rule bed ≥ threshold: heat the bed — channel on; cool below threshold minus hysteresis — channel off.
- Disconnect the Panda: banner appears, no crash-loop in the log; reconnect: initial sync restores rule targets.
- Restart OctoPrint: labels, modes and rules survive.
- Sidebar panel shows one chip per channel (red = on, green = off, yellow while disconnected); unticking Show channel status in the sidebar hides it without a restart.
Tip
Use a channel with nothing attached (or an LED) for rule testing, and put everything you care about on Ignore first.