fix tests

This commit is contained in:
Josh Hawkins
2026-10-02 07:22:55 -05:00
parent 996ffe27ed
commit e3955b18c1
2 changed files with 6 additions and 6 deletions
+5 -6
View File
@@ -59,7 +59,6 @@ def build_watchdog(
MagicMock(), MagicMock(),
) )
watchdog.requestor = MagicMock()
return watchdog return watchdog
@@ -108,8 +107,8 @@ class TestCameraWatchdogStreamHealth(unittest.TestCase):
def test_status_goes_to_the_matching_role_topic(self): def test_status_goes_to_the_matching_role_topic(self):
watchdog = self._build_watchdog() watchdog = self._build_watchdog()
watchdog._send_record_status(STREAM_TYPE_MAIN, "online", 100.0) watchdog.record_status[STREAM_TYPE_MAIN].send("online", 100.0)
watchdog._send_record_status(STREAM_TYPE_SUB, "offline", 100.0) watchdog.record_status[STREAM_TYPE_SUB].send("offline", 100.0)
watchdog.requestor.send_data.assert_any_call( watchdog.requestor.send_data.assert_any_call(
"front_door/status/record", "online" "front_door/status/record", "online"
@@ -121,9 +120,9 @@ class TestCameraWatchdogStreamHealth(unittest.TestCase):
def test_status_is_cached_per_stream(self): def test_status_is_cached_per_stream(self):
watchdog = self._build_watchdog() watchdog = self._build_watchdog()
watchdog._send_record_status(STREAM_TYPE_MAIN, "online", 100.0) watchdog.record_status[STREAM_TYPE_MAIN].send("online", 100.0)
watchdog._send_record_status(STREAM_TYPE_SUB, "online", 100.0) watchdog.record_status[STREAM_TYPE_SUB].send("online", 100.0)
watchdog._send_record_status(STREAM_TYPE_MAIN, "online", 100.0) watchdog.record_status[STREAM_TYPE_MAIN].send("online", 100.0)
assert watchdog.requestor.send_data.call_count == 2 assert watchdog.requestor.send_data.call_count == 2
+1
View File
@@ -120,6 +120,7 @@ class RoleStatus:
last_update_time: float = 0.0 last_update_time: float = 0.0
def send(self, status: str, now: float) -> None: def send(self, status: str, now: float) -> None:
"""Publish a changed status or resend it after the configured interval."""
if ( if (
status != self.last_status status != self.last_status
or (now - self.last_update_time) >= self.resend_interval or (now - self.last_update_time) >= self.resend_interval