test(qm-daemon): add 44 pytest unit tests for pure check functions#8
Conversation
44 tests covering BEACON_RE, check_beacon_naming, check_heartbeats (incl. idle-tier relaxation), check_inbox_drift, check_archive_health, check_buglog_watermark, and render_findings_block smoke tests for each check name. All pass under Python 3.9 + pytest 8.4.2. Network-dependent checks (SSH windows-worktrees, gh CLI spot-check backstop, subprocess audio-staleness) are out of scope for unit tests; pure/deterministic checks only. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis PR adds a complete pytest test module for Changesqm-daemon unit test coverage
🎯 3 (Moderate) | ⏱️ ~25 minutes
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/test_qm_daemon.py (1)
140-140: 💤 Low valueConsider moving
import osto module level.The
import osstatement inside the function works correctly but is unconventional. Standard practice is to place all imports at the module level for better visibility and to avoid repeated import overhead.♻️ Proposed refactor
Move the import to the top of the file with other imports:
import importlib.util import json +import os import time from pathlib import PathThen remove it from the function:
path.write_text(content) # Backdate the mtime by age_seconds target_mtime = time.time() - age_seconds - import os os.utime(str(path), (target_mtime, target_mtime))🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/test_qm_daemon.py` at line 140, The test contains an inline "import os" inside a function; move that "import os" to the module-level import block at the top of the file alongside the other imports, then remove the in-function import so the test function uses the top-level os import instead; no other code changes are required.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/test_qm_daemon.py`:
- Line 140: The test contains an inline "import os" inside a function; move that
"import os" to the module-level import block at the top of the file alongside
the other imports, then remove the in-function import so the test function uses
the top-level os import instead; no other code changes are required.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: f88274b7-7c59-4568-973a-6384a5f90599
📒 Files selected for processing (2)
tests/__init__.pytests/test_qm_daemon.py
Summary
coordination/tests/__init__.pyandcoordination/tests/test_qm_daemon.pywith 44 pytest unit tests for the pure/deterministic functions inqm-daemon.py0.52srun time)Coverage
BEACON_REregexcheck_beacon_namingcheck_heartbeatscheck_inbox_driftcheck_archive_healthcheck_buglog_watermarkbugskey formatrender_findings_blockExcluded from unit-test scope (network-dependent): checks 8 (gh CLI), 10 (SSH), 12 (subprocess audiobook).
Test plan
python3 -m pytest coordination/tests/test_qm_daemon.py -v— 44 passed, 0 failed, 0.52s🤖 Generated with Claude Code
Summary by CodeRabbit