Task 4 — Alert Profiles: presence-aware + time-of-day alert routing. Profiles match household state (EMPTY/KIDS_HOME/ADULTS_HOME/ALL_HOME) and time windows (sleep hours). Per-detection-type rules control push/record/quiet behavior with role-based recipients (all vs adults). Task 5 — Recording Timeline: canvas-based 24h timeline per camera with color-coded segments (person=red, vehicle=blue, motion=gray). Click-to-play, date picker, detection type filters, hour markers. Timeline API endpoint returns segments for a camera+date. All 5 daily-use feature tasks complete. 140 tests passing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
40 lines
1.8 KiB
Python
40 lines
1.8 KiB
Python
"""Tests for recording timeline."""
|
|
|
|
import time
|
|
|
|
from vigilar.storage.queries import get_timeline_data, insert_recording
|
|
|
|
|
|
class TestTimelineQuery:
|
|
def test_returns_recordings_for_day(self, test_db):
|
|
now = int(time.time())
|
|
insert_recording(test_db, camera_id="cam1", started_at=now, ended_at=now+60,
|
|
file_path="/tmp/a.mp4", trigger="MOTION", detection_type="person")
|
|
insert_recording(test_db, camera_id="cam1", started_at=now+100, ended_at=now+130,
|
|
file_path="/tmp/b.mp4", trigger="MOTION", detection_type="motion")
|
|
|
|
results = get_timeline_data(test_db, "cam1", now - 3600, now + 3600)
|
|
assert len(results) == 2
|
|
assert results[0]["detection_type"] == "person"
|
|
assert results[1]["detection_type"] == "motion"
|
|
|
|
def test_filters_by_camera(self, test_db):
|
|
now = int(time.time())
|
|
insert_recording(test_db, camera_id="cam1", started_at=now, ended_at=now+60,
|
|
file_path="/tmp/a.mp4", trigger="MOTION")
|
|
insert_recording(test_db, camera_id="cam2", started_at=now, ended_at=now+60,
|
|
file_path="/tmp/b.mp4", trigger="MOTION")
|
|
|
|
results = get_timeline_data(test_db, "cam1", now - 3600, now + 3600)
|
|
assert len(results) == 1
|
|
|
|
def test_filters_by_time_range(self, test_db):
|
|
now = int(time.time())
|
|
insert_recording(test_db, camera_id="cam1", started_at=now - 7200, ended_at=now - 7100,
|
|
file_path="/tmp/old.mp4", trigger="MOTION")
|
|
insert_recording(test_db, camera_id="cam1", started_at=now, ended_at=now+60,
|
|
file_path="/tmp/new.mp4", trigger="MOTION")
|
|
|
|
results = get_timeline_data(test_db, "cam1", now - 3600, now + 3600)
|
|
assert len(results) == 1
|