305b6c4497
Planning docs (SPEC, ARCHITECTURE, MODULES, ROADMAP, DECISIONS) with decisions D1-D15 settled: RigDoctor name, Python 3 + Qt/PySide6 stack (core/CLI/daemon stdlib-only), Ubuntu + NVIDIA first, .deb packaging, read-only + suggestions, GUI + tray modules, stress module dropped. First code: the M1 sensor core (stdlib-only) and a CLI. - core engine: Reading/Sample model, Sampler, hwmon reader - self-probing sources (NVIDIA first): nvidia-smi GPU, coretemp/k10temp CPU, /proc/meminfo + DDR5 SPD memory, NVMe storage - CLI: snapshot (text/JSON), monitor, sources; record/report stubbed - stdlib unittest smoke tests Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
"""Smoke tests for the sensor core (stdlib unittest; no hardware assumptions)."""
|
|
|
|
import unittest
|
|
|
|
from rigdoctor.core import sources
|
|
from rigdoctor.core.sample import Reading, Sample
|
|
from rigdoctor.core.sampler import Sampler
|
|
from rigdoctor.render import render_snapshot
|
|
|
|
|
|
class CoreTests(unittest.TestCase):
|
|
def test_available_sources_returns_list(self):
|
|
self.assertIsInstance(sources.available_sources(), list)
|
|
|
|
def test_sample_groups_and_rows(self):
|
|
sample = Sample(
|
|
ts=1.0,
|
|
readings=[
|
|
Reading("gpu", "temp", 50.0, "°C"),
|
|
Reading("cpu", "temp", 40.0, "°C", "Package id 0"),
|
|
],
|
|
)
|
|
self.assertEqual(set(sample.by_source()), {"gpu", "cpu"})
|
|
rows = sample.to_rows()
|
|
self.assertEqual(rows[0]["ts"], 1.0)
|
|
self.assertEqual(rows[0]["source"], "gpu")
|
|
|
|
def test_reading_handles_none_value(self):
|
|
text = render_snapshot(Sample(readings=[Reading("gpu", "temp", None, "°C", "memory")]))
|
|
self.assertIn("N/A", text)
|
|
|
|
def test_sampler_runs(self):
|
|
sample = Sampler(sources.available_sources()).sample()
|
|
self.assertIsInstance(sample, Sample)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|