1
mirror of https://github.com/home-assistant/core synced 2024-07-30 21:18:57 +02:00

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)
This commit is contained in:
J. Nick Koston 2022-11-07 09:26:38 -06:00 committed by GitHub
parent ff18cece7b
commit 43745dbc6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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]