From 43745dbc6c86f14993575449deda15f8bae4df4f Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 7 Nov 2022 09:26:38 -0600 Subject: [PATCH] Pass explict time in logbook tests (#81725) The CI sets the timezone to US/Pacific and the logbook uses start_of_local_day when called without a time. We now call the logbook api with a specific time to avoid them being out of sync since the test would fail at CET 8:55am on Mon Nov 7th 2022 (and probably other dates) --- tests/components/logbook/test_init.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/components/logbook/test_init.py b/tests/components/logbook/test_init.py index fb7ac217867..366b4b30ed5 100644 --- a/tests/components/logbook/test_init.py +++ b/tests/components/logbook/test_init.py @@ -489,7 +489,15 @@ async def test_logbook_describe_event(recorder_mock, hass, hass_client): await async_wait_recording_done(hass) client = await hass_client() - response = await client.get("/api/logbook") + # Today time 00:00:00 + start = dt_util.utcnow().date() + start_date = datetime(start.year, start.month, start.day) + + # Test today entries with filter by end_time + end_time = start + timedelta(hours=24) + response = await client.get( + f"/api/logbook/{start_date.isoformat()}?end_time={end_time}" + ) results = await response.json() assert len(results) == 1 event = results[0] @@ -553,7 +561,15 @@ async def test_exclude_described_event(recorder_mock, hass, hass_client): await async_wait_recording_done(hass) client = await hass_client() - response = await client.get("/api/logbook") + # Today time 00:00:00 + start = dt_util.utcnow().date() + start_date = datetime(start.year, start.month, start.day) + + # Test today entries with filter by end_time + end_time = start + timedelta(hours=24) + response = await client.get( + f"/api/logbook/{start_date.isoformat()}?end_time={end_time}" + ) results = await response.json() assert len(results) == 1 event = results[0]