mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-11-01 19:30:33 +03:00
* keep base path in logout redirect * store manual event sub labels as verified objects Manual events created with a sub label were stored in the review item as "label: sub_label", so review previews and collapsed History cards showed a generic icon, the review label filter missed them, and the sub label never reached sub_labels for chips, notifications, or GenAI prompts. The object processor now publishes the label and sub label separately, and the review maintainer stores them as label-verified plus a sub_labels entry, the same as tracked objects. * only expire snapshots for events that still have one Snapshot expiry selected every event older than snapshot retention, including events whose snapshot was already deleted, so with snapshot retention shorter than alert/detection retention the same missing files were unlinked again every cleanup cycle until the event row expired. That was nearly free on local disk but caused constant metadata load on network shares. The expiry queries now filter on has_snapshot so each snapshot is deleted once.
137 lines
3.4 KiB
Python
137 lines
3.4 KiB
Python
"""Tests for manual event severity categorization.
|
|
|
|
Regression coverage for manual events created via the events API being
|
|
categorized as detections when their label appears in both the alerts and
|
|
detections label lists. Alert labels must win, matching how tracked objects
|
|
are categorized, and labels in neither list must default to alerts so the
|
|
historical behavior of the API is preserved.
|
|
"""
|
|
|
|
import unittest
|
|
|
|
from frigate.config import FrigateConfig
|
|
from frigate.review.maintainer import ReviewSegmentMaintainer
|
|
from frigate.review.types import SeverityEnum
|
|
|
|
BASE_CONFIG = """
|
|
mqtt:
|
|
enabled: False
|
|
cameras:
|
|
front_door:
|
|
ffmpeg:
|
|
inputs:
|
|
- path: rtsp://10.0.0.1:554/video
|
|
roles:
|
|
- detect
|
|
detect:
|
|
width: 1920
|
|
height: 1080
|
|
fps: 5
|
|
%s
|
|
"""
|
|
|
|
|
|
class TestManualEventSeverity(unittest.TestCase):
|
|
def _make_maintainer(self, review_config: str = "") -> ReviewSegmentMaintainer:
|
|
"""Build a maintainer without invoking __init__ (avoids needing ZMQ
|
|
sockets, shared memory, and clip dirs). Only the config is read when
|
|
categorizing a manual event label."""
|
|
maintainer = ReviewSegmentMaintainer.__new__(ReviewSegmentMaintainer)
|
|
maintainer.config = FrigateConfig.parse_yaml(BASE_CONFIG % review_config)
|
|
return maintainer
|
|
|
|
def test_defaults_to_alert(self) -> None:
|
|
maintainer = self._make_maintainer()
|
|
|
|
self.assertEqual(
|
|
maintainer.get_manual_event_severity("front_door", "person"),
|
|
SeverityEnum.alert,
|
|
)
|
|
|
|
def test_unlisted_label_defaults_to_alert(self) -> None:
|
|
maintainer = self._make_maintainer(
|
|
"""
|
|
review:
|
|
detections:
|
|
labels:
|
|
- dog
|
|
"""
|
|
)
|
|
|
|
self.assertEqual(
|
|
maintainer.get_manual_event_severity("front_door", "pir_sensor"),
|
|
SeverityEnum.alert,
|
|
)
|
|
|
|
def test_detection_label_is_detection(self) -> None:
|
|
maintainer = self._make_maintainer(
|
|
"""
|
|
review:
|
|
alerts:
|
|
labels:
|
|
- person
|
|
detections:
|
|
labels:
|
|
- pir_sensor
|
|
"""
|
|
)
|
|
|
|
self.assertEqual(
|
|
maintainer.get_manual_event_severity("front_door", "pir_sensor"),
|
|
SeverityEnum.detection,
|
|
)
|
|
|
|
def test_alert_label_wins_over_detection_label(self) -> None:
|
|
maintainer = self._make_maintainer(
|
|
"""
|
|
review:
|
|
alerts:
|
|
labels:
|
|
- person
|
|
detections:
|
|
labels:
|
|
- person
|
|
- dog
|
|
"""
|
|
)
|
|
|
|
self.assertEqual(
|
|
maintainer.get_manual_event_severity("front_door", "person"),
|
|
SeverityEnum.alert,
|
|
)
|
|
|
|
def test_alert_label_is_detection_when_alerts_disabled(self) -> None:
|
|
maintainer = self._make_maintainer(
|
|
"""
|
|
review:
|
|
alerts:
|
|
enabled: False
|
|
labels:
|
|
- person
|
|
detections:
|
|
labels:
|
|
- person
|
|
"""
|
|
)
|
|
|
|
self.assertEqual(
|
|
maintainer.get_manual_event_severity("front_door", "person"),
|
|
SeverityEnum.detection,
|
|
)
|
|
|
|
def test_no_severity_when_alerts_disabled_and_label_not_a_detection(self) -> None:
|
|
maintainer = self._make_maintainer(
|
|
"""
|
|
review:
|
|
alerts:
|
|
enabled: False
|
|
detections:
|
|
labels:
|
|
- dog
|
|
"""
|
|
)
|
|
|
|
self.assertIsNone(
|
|
maintainer.get_manual_event_severity("front_door", "pir_sensor")
|
|
)
|