From 605484776474eb324a18654c382ee2d474be765b Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Thu, 16 Jun 2022 06:36:03 -0600 Subject: [PATCH] Test recordings endpoint --- frigate/test/test_http.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/frigate/test/test_http.py b/frigate/test/test_http.py index e7b56d975..3023d50bf 100644 --- a/frigate/test/test_http.py +++ b/frigate/test/test_http.py @@ -313,6 +313,19 @@ class TestHttp(unittest.TestCase): assert config assert config["cameras"]["front_door"] + def test_recordings(self): + app = create_app( + FrigateConfig(**self.minimal_config).runtime_config, self.db, None, None, None + ) + id = "123456.random" + + with app.test_client() as client: + _insert_mock_recording(id) + recording = client.get("/front_door/recordings").json + assert recording + assert recording[0]["id"] == id + + def _insert_mock_event(id: str) -> Event: """Inserts a basic event model with a given id.""" return Event.insert( @@ -331,3 +344,17 @@ def _insert_mock_event(id: str) -> Event: has_clip=True, has_snapshot=True, ).execute() + + +def _insert_mock_recording(id: str) -> Event: + """Inserts a basic recording model with a given id.""" + return Recordings.insert( + id=id, + camera="front_door", + path=f"/recordings/{id}", + start_time=datetime.datetime.now().timestamp() - 50, + end_time=datetime.datetime.now().timestamp() - 60, + duration=10, + motion=True, + objects=True, + ).execute()