mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-09-28 10:56:52 +03:00
* refactor notices * show startup message for enrichments in health pane * tweaks
41 lines
1.4 KiB
Python
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()
|