Set HA time zone with freeze_time in agent test (#131058)

* Patch dt_util instead of using freeze_time

* Use freeze_time but set HA timezone
pull/131055/head
Michael Hansen 2024-11-20 12:29:36 -06:00 committed by GitHub
parent 4776865584
commit 60774575c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 1 deletions

View File

@ -36,6 +36,7 @@ from homeassistant.helpers import (
intent, intent,
) )
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from homeassistant.util import dt as dt_util
from tests.common import async_mock_service from tests.common import async_mock_service
@ -445,12 +446,22 @@ async def test_todo_add_item_fr(
assert intent_obj.slots.get("item", {}).get("value", "").strip() == "farine" assert intent_obj.slots.get("item", {}).get("value", "").strip() == "farine"
@freeze_time(datetime(year=2013, month=9, day=17, hour=1, minute=2)) @freeze_time(
datetime(
year=2013,
month=9,
day=17,
hour=1,
minute=2,
tzinfo=dt_util.UTC,
)
)
async def test_date_time( async def test_date_time(
hass: HomeAssistant, hass: HomeAssistant,
init_components, init_components,
) -> None: ) -> None:
"""Test the date and time intents.""" """Test the date and time intents."""
await hass.config.async_set_time_zone("UTC")
result = await conversation.async_converse( result = await conversation.async_converse(
hass, "what is the date", None, Context(), None hass, "what is the date", None, Context(), None
) )