mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 18:54:03 +01:00
25 tests in four files, no production change - the module is byte-identical to HEAD. Lands before the split for the usual reason. Covers the CLI surface (every default, every flag, main's dispatch), both run paths including the shared empty-window-means-a-full-day fallback, _run_since's no-data path and both state-advance branches, the clipboard/emit side (tool selection, a failing tool, no tool at all), _preflight's three outcomes, _aggregate_segments with a gap day and with a present-but-empty log, and _log_descriptions. Also covers _compute_window, which turns out to be dead: a shim documented as "kept for backwards import compatibility" with zero callers anywhere in the repo. Tested rather than deleted here, since removing it is a behaviour change that does not belong in a coverage commit - but it is a deletion candidate. 185 stmts / 44 branches, 0 missed. Directory: 179 -> 204 passing. No suppressions: mypy rejected a `list.append(...) or 0` lambda, replaced with a real closure; ten ruff S108 findings on hardcoded /tmp paths became /nonexistent sentinels, which is more accurate anyway since those paths are never opened. Written as two files of 273 and 282 lines, then split to four under the cap before committing - the DropZone lesson from earlier today. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
47 lines
3.8 KiB
JSON
47 lines
3.8 KiB
JSON
{
|
|
"intent": "Take usage_report.py from 47% to 100% line and branch coverage, so the split that follows can be verified against tests written before the seam existed.",
|
|
"scope": [
|
|
"Four new test files under linux_configuration/tests/: cli, emit, segments, run_since - 25 tests",
|
|
"No production file changed. usage_report.py is byte-identical to HEAD.",
|
|
"Non-goal: the split itself, and deleting the dead _compute_window shim"
|
|
],
|
|
"changes": [
|
|
"Covered the CLI surface: every argparse default, every flag with its parsed type, and main's dispatch between the single-day and since-last-report paths.",
|
|
"Covered _run_single_day and _run_since end to end with their collaborators stubbed, including the shared 'a window with no measured seconds is treated as a full day' fallback on both paths.",
|
|
"Covered _run_since's no-data path: the stderr note, the absence of a report, and that the saved timestamp still advances unless --no-update-state is given. Both state-advance branches are exercised on both the data and no-data paths.",
|
|
"Covered the output side: _emit with and without the clipboard, and _copy_to_clipboard picking the first available tool, reporting a tool that fails, and skipping when none is installed.",
|
|
"Covered _preflight's three outcomes, _aggregate_segments including a gap day and a present-but-empty log, _log_descriptions, and the deprecated _compute_window shim.",
|
|
"No suppression was used. mypy rejected a `list.append(...) or 0` lambda as func-returns-value; it was replaced with a real closure rather than silenced. Ten ruff S108 findings on hardcoded /tmp paths were fixed by using /nonexistent sentinels - those paths are never opened, they only prove which value was passed through."
|
|
],
|
|
"verification": [
|
|
{
|
|
"command": "pytest linux_configuration/tests/ --cov=usage_report --cov-branch --cov-report=term-missing",
|
|
"result": "pass",
|
|
"evidence": "Before: 185 stmts, 89 miss, 44 branch, 47%, missing 65-68, 112-127, 150-152, 219-224, 244-254, 261-263, 294-316, 331-364, 369-413, 418-422. After: 185 stmts, 0 miss, 44 branch, 0 partial, 100%."
|
|
},
|
|
{
|
|
"command": "pytest linux_configuration/tests/ (whole directory)",
|
|
"result": "pass",
|
|
"evidence": "204 passed, up from 179 - exactly the 25 tests added, with no change to the 179 already there."
|
|
},
|
|
{
|
|
"command": "pre-commit run --files <the four new test files>",
|
|
"result": "pass",
|
|
"evidence": "All applicable hooks pass, including ruff, ruff format, mypy and the noqa blockers. grep for 'noqa|type: ignore' across them returns 0."
|
|
},
|
|
{
|
|
"command": "bash ~/utils/scripts/check_file_length.sh --all",
|
|
"result": "pass",
|
|
"evidence": "The tests were first written as two files of 273 and 282 lines, both over the 250 cap, and split into four of 180/158/111/156 before committing. This is the DropZone lesson from earlier in the session, where a fix silently added an over-cap file; the over-cap total is unchanged at 38 by this commit."
|
|
}
|
|
],
|
|
"risks": [
|
|
"These tests stub usage_report's collaborators (_aggregate_segments, _render_report, _emit, aggregate_atop) rather than exercising the real pipeline, so they verify orchestration and control flow, not that a real report renders. That is covered by running the actual program, which the split commit does.",
|
|
"_compute_window is dead code: a shim documented as 'kept for backwards import compatibility' with zero callers anywhere in the repo (verified by grep across .py and .sh). It is tested here rather than deleted, because deleting it is a behaviour change beyond a coverage commit. It is a candidate for removal in its own right."
|
|
],
|
|
"rollback": [
|
|
"git rm the four test files. No production code depends on them.",
|
|
"After rollback, coverage of usage_report.py returns to 47% and linux_configuration/tests reports 179 passing tests."
|
|
]
|
|
}
|