fix: show LXC storage in --dry-run summary
Lint / Python (flake8) (push) Successful in 57s
Security / Python Security (bandit) (push) Successful in 59s
Test / Python Tests (pytest) (push) Successful in 46s
Lint / Notify on failure (push) Has been skipped
Lint / Python (flake8) (pull_request) Successful in 34s
Security / Python Security (bandit) (pull_request) Successful in 34s
Test / Python Tests (pytest) (pull_request) Successful in 1m33s
Lint / Notify on failure (pull_request) Has been skipped

The LXC storage check runs in every mode, but its results were never
printed in the --dry-run summary, so a --dry-run appeared to skip LXC
storage entirely. Add an "LXC Storage:" section to the summary
(per-container usage %, a warning flag over the LXC_WARNING threshold, and
the issue count) via a small, testable helper `_format_lxc_dry_run()`.
Adds 4 regression tests.

Closes #23
Ref: #23

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-15 16:59:05 -04:00
co-authored by Claude Opus 4.8
parent 2c6b8c1294
commit 0feac1746d
2 changed files with 62 additions and 0 deletions
+33
View File
@@ -503,3 +503,36 @@ class TestAttributeThresholds:
"""Age is still *tracked* (just not ticketed) — new-drive detection must work."""
assert monitor._is_new_drive(100) is True # ~4 days
assert monitor._is_new_drive(64860) is False # ~7.4 years
# ── _format_lxc_dry_run (LXC storage shown in --dry-run summary; issue #23) ────
class TestLxcDryRunSummary:
def test_includes_container_usage_and_flags_over_threshold(self, monitor):
"""Regression for issue #23: dry-run summary must surface LXC storage."""
lxc = {
'status': 'WARNING',
'issues': ['LXC 105 high storage usage: 84.0% on /'],
'containers': [
{'vmid': '105', 'filesystems': [{'mountpoint': '/', 'usage_percent': 84.0}]},
],
}
text = '\n'.join(monitor._format_lxc_dry_run(lxc))
assert 'LXC Storage:' in text
assert 'CT105 /' in text and '84.0% used' in text
assert '⚠️' in text # flagged: over the 80% warning threshold
assert 'Issues: 1 found' in text
def test_healthy_container_not_flagged(self, monitor):
lxc = {'status': 'OK', 'issues': [],
'containers': [{'vmid': '119', 'filesystems': [{'mountpoint': '/', 'usage_percent': 26.0}]}]}
text = '\n'.join(monitor._format_lxc_dry_run(lxc))
assert 'CT119 /' in text and '26.0% used' in text
assert '⚠️' not in text
def test_empty_when_no_containers(self, monitor):
assert monitor._format_lxc_dry_run({'status': 'OK', 'containers': [], 'issues': []}) == []
def test_error_status_is_reported(self, monitor):
lines = monitor._format_lxc_dry_run({'status': 'ERROR', 'containers': [], 'issues': ['boom']})
assert any('check error' in ln for ln in lines)