"""Unit tests for diagnostics."""
import unittest
import json
from datetime import datetime

class TestDiagnostics(unittest.TestCase):
    def test_hardware_check_creation(self):
        checks = {
            "rplidar": {"status": "OK", "message": "RPLIDAR detected"},
            "realsense": {"status": "ERROR", "message": "RealSense not found"},
        }
        self.assertEqual(len(checks), 2)
        self.assertEqual(checks["rplidar"]["status"], "OK")

    def test_diagnostic_json_logging(self):
        log_data = {
            "timestamp": datetime.now().isoformat(),
            "check_type": "startup",
            "hardware_checks": {"rplidar": {"status": "OK", "message": "OK"}},
        }
        json_str = json.dumps(log_data)
        parsed = json.loads(json_str)
        self.assertIn("timestamp", parsed)

if __name__ == "__main__":
    unittest.main()
