Show live camera refresh status
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import unittest
|
||||
|
||||
from frigate_camera_control_bridge.app import CameraControlBridge
|
||||
|
||||
|
||||
class DummyAction:
|
||||
def __init__(self, action_id, camera=None, kind="hikvision_colorvu"):
|
||||
self.id = action_id
|
||||
self.kind = kind
|
||||
self.cfg = {}
|
||||
if camera:
|
||||
self.cfg["snapshot"] = {
|
||||
"frigate_url": "http://frigate.example.test:5000",
|
||||
"camera": camera,
|
||||
}
|
||||
|
||||
|
||||
class RefreshSummaryTest(unittest.TestCase):
|
||||
def test_camera_keys_ignore_global_actions(self):
|
||||
keys = CameraControlBridge.camera_keys_from_actions(
|
||||
[
|
||||
DummyAction("one_light", "one"),
|
||||
DummyAction("all_off", kind="all_off"),
|
||||
]
|
||||
)
|
||||
|
||||
self.assertEqual(keys, {("http://frigate.example.test:5000", "one")})
|
||||
|
||||
def test_refresh_message_reports_camera_changes_first(self):
|
||||
message = CameraControlBridge.refresh_message(
|
||||
"en",
|
||||
{
|
||||
"added_cameras": 1,
|
||||
"removed_cameras": 0,
|
||||
"added_actions": 2,
|
||||
"removed_actions": 0,
|
||||
},
|
||||
)
|
||||
|
||||
self.assertEqual(message, "Cameras updated: +1, -0.")
|
||||
|
||||
def test_refresh_message_reports_no_changes(self):
|
||||
message = CameraControlBridge.refresh_message(
|
||||
"en",
|
||||
{
|
||||
"added_cameras": 0,
|
||||
"removed_cameras": 0,
|
||||
"added_actions": 0,
|
||||
"removed_actions": 0,
|
||||
},
|
||||
)
|
||||
|
||||
self.assertEqual(message, "No camera changes found.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -69,6 +69,8 @@ class UiRenderTest(unittest.TestCase):
|
||||
self.assertIn('action="/refresh?lang=en&token=secret"', html)
|
||||
self.assertIn('title="Refresh cameras"', html)
|
||||
self.assertIn('aria-label="Refresh cameras"', html)
|
||||
self.assertIn('data-refresh-status', html)
|
||||
self.assertIn('data-working-label="Refreshing cameras..."', html)
|
||||
self.assertIn("<svg", html)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user