"""Tests for M12 relay frames + guest HTML rendering (host/guest data shapes).""" import json import unittest from rigdoctor.core import share from rigdoctor.core.sampler import Sampler from rigdoctor.core.sources import available_sources class RelayFrameTests(unittest.TestCase): def setUp(self): self.sampler = Sampler(available_sources()) def test_full_frame_shape(self): frame = json.loads(share.host_full_frame(self.sampler)) self.assertEqual(frame["type"], "full") self.assertIn("groups", frame["snapshot"]) self.assertIsInstance(frame["report"], list) self.assertIsInstance(frame["inventory"], dict) def test_snapshot_frame_shape(self): frame = json.loads(share.host_snapshot_frame(self.sampler)) self.assertEqual(frame["type"], "snapshot") self.assertIn("groups", frame["snapshot"]) def test_guest_html_renders(self): snap = {"groups": {"gpu": [{"name": "temp", "value": 51.0, "unit": "°C"}]}} report = [{"severity": "ok", "category": "Logs", "title": "No errors"}] inv = {"System": {"Kernel": "7.0.0"}} html = share.guest_html(snap, report, inv) self.assertIn("51.0 °C", html) self.assertIn("No errors", html) self.assertIn("Kernel", html) if __name__ == "__main__": unittest.main()