mirror of
https://github.com/home-assistant/core.git
synced 2026-08-03 20:24:55 +02:00
Stop using naive now in here_travel_time (#177942)
This commit is contained in:
committed by
GitHub
parent
bd149d66cc
commit
860a0a97c2
@@ -388,7 +388,8 @@ def build_hass_attribution(sections: list[dict[str, Any]]) -> str | None:
|
||||
|
||||
def next_datetime(simple_time: time) -> datetime:
|
||||
"""Take a time like 08:00:00 and combine it with the current date."""
|
||||
combined = datetime.combine(dt_util.start_of_local_day(), simple_time)
|
||||
if combined < datetime.now(): # pylint: disable=home-assistant-enforce-naive-now
|
||||
start_of_day = dt_util.start_of_local_day()
|
||||
combined = datetime.combine(start_of_day, simple_time, start_of_day.tzinfo)
|
||||
if combined < dt_util.now():
|
||||
combined = combined + timedelta(days=1)
|
||||
return combined
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""The test for the HERE Travel Time integration."""
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -32,18 +32,18 @@ from tests.common import MockConfigEntry
|
||||
DEFAULT_OPTIONS,
|
||||
{
|
||||
CONF_ROUTE_MODE: ROUTE_MODE_FASTEST,
|
||||
CONF_DEPARTURE_TIME: datetime.now(), # pylint: disable=home-assistant-enforce-naive-now
|
||||
CONF_DEPARTURE_TIME: "08:00:00",
|
||||
},
|
||||
{
|
||||
CONF_ROUTE_MODE: ROUTE_MODE_FASTEST,
|
||||
CONF_ARRIVAL_TIME: datetime.now(), # pylint: disable=home-assistant-enforce-naive-now
|
||||
CONF_ARRIVAL_TIME: "08:00:00",
|
||||
},
|
||||
{
|
||||
CONF_ROUTE_MODE: ROUTE_MODE_FASTEST,
|
||||
},
|
||||
],
|
||||
)
|
||||
async def test_unload_entry(hass: HomeAssistant, options) -> None:
|
||||
async def test_unload_entry(hass: HomeAssistant, options: dict[str, Any]) -> None:
|
||||
"""Test that unloading an entry works."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
||||
Reference in New Issue
Block a user