Files
rigdoctor/tests/test_installer.py
T
jessey 2e6a981120
release / release (push) Successful in 13s
Release 0.0.5: health report (M4), installer (M9), update check (M13)
M4 — health report (the 0.0.4 CHANGELOG entry, folded into this release):
- core/health.py: scan journalctl (Xid/panic/OOM/MCE/AER/thermal), SMART,
  NVIDIA driver mismatch, journald persistence, live temps -> findings
- CLI `rigdoctor report` (text/JSON); GUI Health tab; scanner tests

M9 — installer (first cut):
- core/{catalog,sysenv,installer}.py; `rigdoctor install [--check] [-y]`
- GUI Setup tab: detect distro/GPU, show optional components, one-click
  install of missing apt packages via pkexec/sudo

M13 — update check (check half):
- core/updates.py; sidebar shows up-to-date / "Update to v…" / unavailable

Plus tests, version bump to 0.0.5, CHANGELOG, and doc status updates.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 17:36:11 +02:00

47 lines
1.6 KiB
Python

"""Tests for the M9 installer logic and the M13 version comparison."""
import unittest
from rigdoctor.core import installer
from rigdoctor.core.catalog import Component
from rigdoctor.core.updates import is_newer
class InstallerTests(unittest.TestCase):
def test_component_status_uses_presence(self):
status = installer.component_status(present=lambda cmd: cmd == "smartctl")
by_id = {c.id: ok for c, ok in status}
self.assertTrue(by_id["smartmontools"])
self.assertFalse(by_id["dmidecode"])
def test_missing_packages_dedup_preserves_order(self):
comps = [
Component("a", "A", "B", "x", ("p1", "p2"), "c1"),
Component("b", "B", "B", "y", ("p2", "p3"), "c2"),
]
self.assertEqual(installer.missing_packages(comps), ["p1", "p2", "p3"])
def test_apt_command_includes_packages(self):
joined = " ".join(installer.apt_install_command(["smartmontools", "dmidecode"]))
self.assertIn("smartmontools", joined)
self.assertIn("dmidecode", joined)
self.assertIn("apt-get install", joined)
def test_install_nothing_is_noop(self):
rc, _ = installer.install_packages([])
self.assertEqual(rc, 0)
class UpdateTests(unittest.TestCase):
def test_is_newer(self):
self.assertTrue(is_newer("v0.0.5", "0.0.4"))
self.assertFalse(is_newer("v0.0.4", "0.0.4"))
self.assertFalse(is_newer("v0.0.3", "0.0.4"))
def test_is_newer_handles_garbage(self):
self.assertFalse(is_newer("not-a-version", "0.0.4"))
if __name__ == "__main__":
unittest.main()