From 91867b729422d66d6ebbefcdff53532ada01f0bd Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Thu, 6 Nov 2025 06:17:13 -0700 Subject: [PATCH] Don't break existing format --- frigate/api/event.py | 2 +- frigate/api/media.py | 2 +- frigate/test/http_api/test_http_media.py | 30 ++++++++++++++++-------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/frigate/api/event.py b/frigate/api/event.py index 5835358c6..544e58fd2 100644 --- a/frigate/api/event.py +++ b/frigate/api/event.py @@ -912,7 +912,7 @@ def events_summary( "count": int(g.count or 0), } - return JSONResponse(content=list(sorted(grouped.keys()).values())) + return JSONResponse(content=list(grouped.values())) @router.get( diff --git a/frigate/api/media.py b/frigate/api/media.py index cd5e0af9d..2bad3658f 100644 --- a/frigate/api/media.py +++ b/frigate/api/media.py @@ -496,7 +496,7 @@ def all_recordings_summary( for g in period_query: days[g.day] = True - return JSONResponse(content=sorted(days.keys())) + return JSONResponse(content=dict(sorted(days.items()))) @router.get( diff --git a/frigate/test/http_api/test_http_media.py b/frigate/test/http_api/test_http_media.py index 739cd57f1..970a331e7 100644 --- a/frigate/test/http_api/test_http_media.py +++ b/frigate/test/http_api/test_http_media.py @@ -99,11 +99,13 @@ class TestHttpMedia(BaseTestHttp): # Verify we get exactly 3 days assert len(summary) == 3, f"Expected 3 days, got {len(summary)}" - # Verify the correct dates are returned - dates = summary - assert "2024-03-09" in dates, f"Expected 2024-03-09 in {dates}" - assert "2024-03-10" in dates, f"Expected 2024-03-10 in {dates}" - assert "2024-03-11" in dates, f"Expected 2024-03-11 in {dates}" + # Verify the correct dates are returned (API returns dict with True values) + assert "2024-03-09" in summary, f"Expected 2024-03-09 in {summary}" + assert "2024-03-10" in summary, f"Expected 2024-03-10 in {summary}" + assert "2024-03-11" in summary, f"Expected 2024-03-11 in {summary}" + assert summary["2024-03-09"] is True + assert summary["2024-03-10"] is True + assert summary["2024-03-11"] is True def test_recordings_summary_across_dst_fall_back(self): """ @@ -173,11 +175,13 @@ class TestHttpMedia(BaseTestHttp): # Verify we get exactly 3 days assert len(summary) == 3, f"Expected 3 days, got {len(summary)}" - # Verify the correct dates are returned - dates = summary - assert "2024-11-02" in dates, f"Expected 2024-11-02 in {dates}" - assert "2024-11-03" in dates, f"Expected 2024-11-03 in {dates}" - assert "2024-11-04" in dates, f"Expected 2024-11-04 in {dates}" + # Verify the correct dates are returned (API returns dict with True values) + assert "2024-11-02" in summary, f"Expected 2024-11-02 in {summary}" + assert "2024-11-03" in summary, f"Expected 2024-11-03 in {summary}" + assert "2024-11-04" in summary, f"Expected 2024-11-04 in {summary}" + assert summary["2024-11-02"] is True + assert summary["2024-11-03"] is True + assert summary["2024-11-04"] is True def test_recordings_summary_multiple_cameras_across_dst(self): """ @@ -229,6 +233,8 @@ class TestHttpMedia(BaseTestHttp): assert len(summary) == 2, f"Expected 2 days, got {len(summary)}" assert "2024-03-09" in summary assert "2024-03-10" in summary + assert summary["2024-03-09"] is True + assert summary["2024-03-10"] is True def test_recordings_summary_at_dst_transition_time(self): """ @@ -267,6 +273,7 @@ class TestHttpMedia(BaseTestHttp): # The recording should appear on March 10 assert len(summary) == 1 assert "2024-03-10" in summary + assert summary["2024-03-10"] is True def test_recordings_summary_utc_timezone(self): """ @@ -311,6 +318,8 @@ class TestHttpMedia(BaseTestHttp): assert len(summary) == 2 assert "2024-03-09" in summary assert "2024-03-10" in summary + assert summary["2024-03-09"] is True + assert summary["2024-03-10"] is True def test_recordings_summary_no_recordings(self): """ @@ -367,3 +376,4 @@ class TestHttpMedia(BaseTestHttp): summary = response.json() assert len(summary) == 1 assert "2024-03-10" in summary + assert summary["2024-03-10"] is True