mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-10 20:07:04 +01:00
cups_queue.py 424 -> 245. display_cups_queue_status, _offer_queue_fix, the _dwj_* choices and the _handle_* dispatchers move to _queue_fix.py. The _cups_* action primitives stay put: test_cups_queue.py patches subprocess and time on cups_queue, and those primitives are their only consumers, so moving them would have left subprocess.run unpatched and free to restart the real CUPS service mid-suite. test_cups_queue.py therefore needs no edit; only part2/part3 repoint their MOD. Pass count is 402 before and after. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
48 lines
3.5 KiB
JSON
48 lines
3.5 KiB
JSON
{
|
|
"intent": "Bring brother_printer/cups_queue.py under the 250-line cap by moving the queue-status display and the interactive fix prompt into their own module, with no behaviour change.",
|
|
"scope": [
|
|
"python_pkg/brother_printer/_queue_fix.py (new)",
|
|
"python_pkg/brother_printer/cups_queue.py",
|
|
"python_pkg/brother_printer/display.py (import path only)",
|
|
"python_pkg/brother_printer/tests/test_cups_queue_part2.py, test_cups_queue_part3.py (MOD and import path only)",
|
|
"Non-goal: no assertion changed, no test deleted, skipped or weakened"
|
|
],
|
|
"changes": [
|
|
"Moved display_cups_queue_status, _offer_queue_fix, the five _dwj_* choice handlers, the _DWJ_ACTIONS table and the four _handle_* dispatchers verbatim into python_pkg/brother_printer/_queue_fix.py.",
|
|
"The _cups_* action primitives stay in cups_queue.py on purpose and _queue_fix imports the three it needs. test_cups_queue.py patches subprocess and time on cups_queue, and those primitives are their only consumers, so moving them would have left subprocess.run unpatched and able to restart the real CUPS service during the suite.",
|
|
"cups_queue.py dropped the imports that only the moved code used (BOLD, CYAN, GREEN, YELLOW, _prompt and the whole TYPE_CHECKING/Callable block); 424 -> 245 lines.",
|
|
"display.py now imports display_cups_queue_status from _queue_fix and get_cups_queue_status from cups_queue, keeping the dependency direction cups_queue <- _queue_fix <- display with no re-export shim and no cycle.",
|
|
"test_cups_queue_part2.py and test_cups_queue_part3.py had their MOD constant and import module repointed at _queue_fix. test_cups_queue.py needed no change at all, which is the signal the seam matched the existing test boundary."
|
|
],
|
|
"verification": [
|
|
{
|
|
"command": "PYTHONPATH=. python3 -m pytest python_pkg/brother_printer/tests -q",
|
|
"result": "pass",
|
|
"evidence": "402 passed before the split and 402 passed after it - identical pass count, not merely a green run."
|
|
},
|
|
{
|
|
"command": "PYTHONPATH=. python3 -c \"from python_pkg.brother_printer import _queue_fix as q, cups_queue as c, display as d; q._cups_enable_printer; q._cups_restart_service; q._prompt; q._handle_disabled_with_jobs; c.subprocess; c.time; c.shutil; c.Path; d.display_cups_queue_status\"",
|
|
"result": "pass",
|
|
"evidence": "runtime probe OK - every name the three test modules patch is still a real attribute of the module they name, so ruff's TC001 rewrite trap did not fire."
|
|
},
|
|
{
|
|
"command": "wc -l python_pkg/brother_printer/cups_queue.py python_pkg/brother_printer/_queue_fix.py",
|
|
"result": "pass",
|
|
"evidence": "245 and 203 lines, both under the 250-line cap."
|
|
},
|
|
{
|
|
"command": "pre-commit run --files <the six touched files>",
|
|
"result": "pass",
|
|
"evidence": "ruff, ruff format, mypy, pylint, bandit and pytest-with-coverage all pass on the touched files."
|
|
}
|
|
],
|
|
"risks": [
|
|
"mock.patch pins names to a module. The dangerous direction here was silent rather than red: an unpatched _cups_restart_service would have run systemctl restart cups for real. Mitigated by leaving all four _cups_* primitives in cups_queue.py, which the runtime probe and the unchanged test_cups_queue.py both confirm.",
|
|
"display.py imports from both modules now; a future move of get_cups_queue_status into _queue_fix would create a cycle."
|
|
],
|
|
"rollback": [
|
|
"git revert the commit; cups_queue.py returns to 424 lines and _queue_fix.py disappears.",
|
|
"After rollback, re-run the package suite and confirm it still reports 402 passed."
|
|
]
|
|
}
|