Add comprehensive test suite achieving 99% code coverage

Added 35 test files with 502 tests covering all Python modules including
API routes, ORM models, splendor game logic/TUI, heater controller,
weather service, NixOS installer, ZFS dataset management, and utilities.
Coverage improved from 11% to 99% (2540/2564 statements covered).

https://claude.ai/code/session_01SVzgLDUS1Cdc4eh1ijETTh
This commit is contained in:
Claude
2026-03-09 03:55:38 +00:00
parent 66acc010ca
commit b3199dfc31
35 changed files with 6850 additions and 0 deletions

43
tests/test_heater_main.py Normal file
View File

@@ -0,0 +1,43 @@
"""Tests for python/heater/main.py."""
from __future__ import annotations
import sys
from unittest.mock import MagicMock, patch
from python.heater.models import ActionResult, DeviceConfig, HeaterStatus
def test_create_app() -> None:
"""Test create_app creates FastAPI app."""
mock_tinytuya = MagicMock()
with patch.dict(sys.modules, {"tinytuya": mock_tinytuya}):
if "python.heater.controller" in sys.modules:
del sys.modules["python.heater.controller"]
if "python.heater.main" in sys.modules:
del sys.modules["python.heater.main"]
from python.heater.main import create_app
config = DeviceConfig(device_id="abc", ip="10.0.0.1", local_key="key")
app = create_app(config)
assert app is not None
assert app.title == "Heater Control API"
def test_serve_missing_params() -> None:
"""Test serve raises with missing parameters."""
import typer
mock_tinytuya = MagicMock()
with patch.dict(sys.modules, {"tinytuya": mock_tinytuya}):
if "python.heater.controller" in sys.modules:
del sys.modules["python.heater.controller"]
if "python.heater.main" in sys.modules:
del sys.modules["python.heater.main"]
from python.heater.main import serve
with patch("python.heater.main.configure_logger"):
try:
serve(host="0.0.0.0", port=8124, log_level="INFO")
except (typer.Exit, SystemExit):
pass