test(host_agent): update existing collector tests for new agent API
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:
@@ -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():
|
||||
|
||||
Reference in New Issue
Block a user