Files
frigate/frigate/test/test_watchdog_notices.py
T
Josh HawkinsandGitHub cd83fee1d6 Refactor Notices and System Health pane (#24243)
* refactor notices

* show startup message for enrichments in health pane

* tweaks
2026-09-11 11:53:55 -06:00

41 lines
1.4 KiB
Python

"""Tests for the detector stuck notice raised by the Frigate watchdog."""
import unittest
from unittest.mock import MagicMock, patch
from frigate.watchdog import FrigateWatchdog
class TestDetectorStuckNotice(unittest.TestCase):
def _stuck_detector(self) -> MagicMock:
detector = MagicMock()
detector.detection_start.value = 1.0
detector.detect_process.is_alive.return_value = True
return detector
def test_stuck_restart_raises_notice(self):
detector = self._stuck_detector()
watchdog = FrigateWatchdog({"ov": detector}, MagicMock())
with (
patch("frigate.watchdog.datetime") as mock_datetime,
patch("frigate.watchdog.raise_notice") as raise_notice,
):
mock_datetime.datetime.now.return_value.timestamp.return_value = 100.0
watchdog._check_detectors()
detector.start_or_restart.assert_called_once()
raise_notice.assert_called_once_with(
"detector_stuck", scope="ov", params={"detector": "ov"}
)
def test_healthy_detector_raises_nothing(self):
detector = self._stuck_detector()
detector.detection_start.value = 0.0
watchdog = FrigateWatchdog({"ov": detector}, MagicMock())
with patch("frigate.watchdog.raise_notice") as raise_notice:
watchdog._check_detectors()
raise_notice.assert_not_called()