33 lines
886 B
Python
33 lines
886 B
Python
from pathlib import Path
|
|
|
|
from app.config import load_config
|
|
|
|
|
|
def test_load_config_reads_thresholds(tmp_path: Path):
|
|
cfg = tmp_path / "config.yaml"
|
|
cfg.write_text(
|
|
"camera_id: store_cam_01\n"
|
|
"thresholds:\n"
|
|
" min_people: 5\n"
|
|
" min_dwell_seconds: 600\n",
|
|
encoding="utf-8",
|
|
)
|
|
|
|
data = load_config(cfg)
|
|
|
|
assert data.camera_id == "store_cam_01"
|
|
assert data.thresholds.min_people == 5
|
|
assert data.thresholds.min_dwell_seconds == 600
|
|
|
|
|
|
def test_load_config_uses_defaults_for_optional_sections(tmp_path: Path):
|
|
cfg = tmp_path / "config.yaml"
|
|
cfg.write_text("camera_id: store_cam_01\n", encoding="utf-8")
|
|
|
|
data = load_config(cfg)
|
|
|
|
assert data.stream.sample_fps == 2.0
|
|
assert data.staff.min_hits == 3
|
|
assert data.event_sink.path == "logs/events.jsonl"
|
|
assert data.webhook.timeout_seconds == 5.0
|