From c2f1a6b87e8440cc7414e59d1e7cd42ffe1e4e4e Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Sat, 24 Oct 2026 16:37:15 -0500 Subject: [PATCH] Added a test that calls `_execute_start_camera_watch` and checks `start_vlm_watch_job` receives the caller's username, so removing that argument now fails it. --- frigate/test/test_chat_stop_camera_watch.py | 25 ++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/frigate/test/test_chat_stop_camera_watch.py b/frigate/test/test_chat_stop_camera_watch.py index 9b78ef1c64..9159ec2bc7 100644 --- a/frigate/test/test_chat_stop_camera_watch.py +++ b/frigate/test/test_chat_stop_camera_watch.py @@ -1,10 +1,11 @@ -"""Tests for the stop_camera_watch chat tool.""" +"""Tests for camera watch ownership in the chat tools.""" +import asyncio import unittest from types import SimpleNamespace -from unittest.mock import patch +from unittest.mock import AsyncMock, MagicMock, patch -from frigate.api.chat import _execute_stop_camera_watch +from frigate.api.chat import _execute_start_camera_watch, _execute_stop_camera_watch from frigate.jobs.vlm_watch import VLMWatchJob @@ -40,5 +41,23 @@ class TestStopCameraWatch(unittest.TestCase): self.stop.assert_called_once() +class TestStartCameraWatch(unittest.TestCase): + @patch("frigate.api.chat.require_camera_access", new_callable=AsyncMock) + @patch("frigate.api.chat.start_vlm_watch_job", return_value="job1") + def test_records_caller_as_owner(self, start, _access): + request = _request("alice", "viewer") + request.app = MagicMock() + request.app.frigate_config.cameras = {"front": None} + request.app.genai_manager.chat_client.supports_vision = True + + asyncio.run( + _execute_start_camera_watch( + request, {"camera": "front", "condition": "person"} + ) + ) + + self.assertEqual(start.call_args.kwargs["username"], "alice") + + if __name__ == "__main__": unittest.main()