hermes-agent/tests/hermes_cli/test_doctor_channel_hygiene.py
ethernet 92686159d1 fix(pm): integrate audited runtime and lifecycle repairs
Prepare dependency generations before selecting them. Keep shipped tool
bytes separate from writable additions, and store facts beside their entries.
Validate proposed plugin sets before config publication. Restore the previous
config if the facts write fails.

Consolidate duplicate updater, backup, setup, and voice helpers. Repair
launcher selection, dependency consumers, download ownership, update feeds,
and native Windows process and file handling.

Verification: 206 changed/prior-failing Python files reported 4630 passed,
one failed, and 330 skipped. Fix the remaining Hindsight fixture boundary.
The final targeted rerun reported 234 passed and two skipped. The store
review regression batch reported 83 passed and one skipped. Desktop
TypeScript checks, 56 selected Electron tests, 24 release tests, and the
removed-import/compatibility guards passed.

This is an integration checkpoint, not full audit acceptance. The complete
Python suite has not run on this fixed tree. Crash-atomic plugin publication,
generation cleanup, receipt correlation, and packaged lifecycle acceptance
remain open in docs/pm-audit-status.md.
2026-09-05 22:36:48 -04:00

54 lines
1.9 KiB
Python

"""Doctor's channel-record hygiene check (_check_channel_record_hygiene).
Report-don't-delete: doctor names the stale config key; the user removes
it. The staleness shapes themselves are covered in
tests/hermes_cli/test_update_channel.py::TestDoctorStaleness — this file
covers the doctor-side wiring: warnings printed, exceptions swallowed
into a warning, silence on a clean config.
"""
from unittest.mock import patch
from hermes_cli.doctor_config import _check_channel_record_hygiene
def test_clean_config_prints_nothing(capsys):
with (
patch("hermes_cli.config.load_config", return_value={}),
):
_check_channel_record_hygiene()
assert capsys.readouterr().out == ""
def test_stale_records_warned_with_reason_texts(tmp_path, capsys, monkeypatch):
home = tmp_path / ".hermes"
home.mkdir()
monkeypatch.setenv("HERMES_HOME", str(home))
gone = tmp_path / "gone"
live = tmp_path / "live"
live.mkdir()
config = {
"update": {
"installs": {
# missing: nothing at the recorded path
"deadbeefdeadbeef": {"path": str(gone), "channel": "main"},
# replaced: path exists but keys to a different sha16
"0" * 16: {"path": str(live), "channel": "stable"},
}
}
}
with patch("hermes_cli.config.load_config", return_value=config):
_check_channel_record_hygiene()
out = capsys.readouterr().out
assert "Stale channel record: deadbeefdeadbeef" in out
assert "safe to remove update.installs.deadbeefdeadbeef" in out
assert f"Stale channel record: {'0' * 16}" in out
assert "different install now" in out
def test_unreadable_config_degrades_to_a_warning(capsys):
with patch("hermes_cli.config.load_config", side_effect=RuntimeError("boom")):
_check_channel_record_hygiene()
out = capsys.readouterr().out
assert "Channel-record hygiene unreadable" in out
assert "boom" in out