39 lines
899 B
Python
39 lines
899 B
Python
from __future__ import annotations
|
|
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
from cold_display_guard.config import load_settings
|
|
|
|
|
|
class ConfigTests(unittest.TestCase):
|
|
def test_loads_settings_from_toml(self) -> None:
|
|
with tempfile.TemporaryDirectory() as tmpdir:
|
|
path = Path(tmpdir) / "config.toml"
|
|
path.write_text(
|
|
"""
|
|
camera_id = "cam_a"
|
|
|
|
[thresholds]
|
|
max_dwell_seconds = 30
|
|
trash_confirmation_seconds = 4
|
|
|
|
[layout]
|
|
rows = 1
|
|
cols = 2
|
|
""".strip(),
|
|
encoding="utf-8",
|
|
)
|
|
|
|
settings = load_settings(path)
|
|
|
|
self.assertEqual(settings.camera_id, "cam_a")
|
|
self.assertEqual(settings.max_dwell_seconds, 30)
|
|
self.assertEqual(settings.trash_confirmation_seconds, 4)
|
|
self.assertEqual(settings.zone_ids, ("r1c1", "r1c2"))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|