test(host_agent): update existing collector tests for new agent API
CI / lint (push) Successful in 2s
CI / unit (push) Successful in 7s
CI / integration (push) Successful in 2m15s
CI / publish (push) Successful in 8s

collect_cpu now returns (aggregate, [per_core]) and build_sample takes a
rate-state dict, so the pre-existing tests that asserted the old float
return / no-state signature needed updating. Mocks the new collectors
(temps/psi/net/diskio) for determinism.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-16 10:15:43 -04:00
parent a9e7baee6a
commit f037b69c58
2 changed files with 17 additions and 7 deletions
@@ -56,10 +56,11 @@ def test_collect_cpu_reads_twice():
with patch.object(a, "_read_file", _read), \
patch.object(a.time, "sleep", lambda _s: None):
pct = a.collect_cpu(sample_window=0.0)
pct, cores = a.collect_cpu(sample_window=0.0)
# totals: 1000 → 2000 (delta 1000). idle+iowait: 850 → 1700 (delta 850).
# busy = 150. pct = 15.0.
# busy = 150. pct = 15.0. No cpuN lines in the fixture → no per-core values.
assert pct == pytest.approx(15.0, abs=0.1)
assert cores == []
def test_collect_storage():