mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-10-25 07:54:40 +03:00
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.
This commit is contained in:
@@ -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
|
import unittest
|
||||||
from types import SimpleNamespace
|
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
|
from frigate.jobs.vlm_watch import VLMWatchJob
|
||||||
|
|
||||||
|
|
||||||
@@ -40,5 +41,23 @@ class TestStopCameraWatch(unittest.TestCase):
|
|||||||
self.stop.assert_called_once()
|
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__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
Reference in New Issue
Block a user