vigilar/tests/unit/test_config.py
Aaron D. Lee 845a85d618 Initial commit: Vigilar DIY home security system
Phase 1 (Foundation): project skeleton, TOML config + Pydantic validation,
MQTT bus wrapper, SQLite schema (9 tables), Click CLI, process supervisor.

Phase 2 (Camera): RTSP capture via OpenCV, MOG2 motion detection with
configurable sensitivity/zones, adaptive FPS recording (2fps idle/30fps
motion) via FFmpeg subprocess, HLS live streaming, pre-motion ring buffer.

Phase 3 (Web UI): Flask + Bootstrap 5 dark theme, 6 blueprints, Jinja2
templates (dashboard, kiosk 2x2 grid, events, sensors, recordings, settings),
PWA with service worker + Web Push, full admin settings UI with config
persistence.

Remote Access: WireGuard tunnel configs, nginx reverse proxy with HLS
caching + rate limiting, bandwidth-optimized remote HLS stream (426x240
@ 500kbps), DO droplet setup script, certbot TLS.

29 tests passing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 23:11:27 -04:00

36 lines
1.1 KiB
Python

"""Tests for config loading and validation."""
from vigilar.config import CameraConfig, VigilarConfig
def test_default_config():
cfg = VigilarConfig()
assert cfg.system.name == "Vigilar Home Security"
assert cfg.web.port == 49735
assert cfg.mqtt.port == 1883
assert cfg.cameras == []
def test_camera_config_defaults():
cam = CameraConfig(id="test", display_name="Test", rtsp_url="rtsp://localhost")
assert cam.idle_fps == 2
assert cam.motion_fps == 30
assert cam.pre_motion_buffer_s == 5
assert cam.post_motion_buffer_s == 30
assert cam.motion_sensitivity == 0.7
def test_duplicate_camera_ids_rejected():
import pytest
with pytest.raises(ValueError, match="Duplicate camera IDs"):
VigilarConfig(cameras=[
CameraConfig(id="cam1", display_name="A", rtsp_url="rtsp://a"),
CameraConfig(id="cam1", display_name="B", rtsp_url="rtsp://b"),
])
def test_camera_sensitivity_bounds():
import pytest
with pytest.raises(Exception):
CameraConfig(id="test", display_name="Test", rtsp_url="rtsp://localhost", motion_sensitivity=1.5)