diff --git a/custom_components/nestquest/__init__.py b/custom_components/nestquest/__init__.py index 310a2a6..7802707 100644 --- a/custom_components/nestquest/__init__.py +++ b/custom_components/nestquest/__init__.py @@ -298,7 +298,7 @@ def _register_day_rollover_listener( await _materialize_run(database, start_date, end_date) return async_track_time_change( - hass, _run_materialization, hour=hour, minute=minute, local=True + hass, _run_materialization, hour=hour, minute=minute ) diff --git a/tests/conftest.py b/tests/conftest.py index 42e4512..ff8c5d6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -248,7 +248,7 @@ class TimeChangeRegistry: """Models HA's time-change listener bookkeeping. ``track`` mirrors ``homeassistant.helpers.event.async_track_time_change``: - each call appends a record (action + hour/minute/second/local) and returns + each call appends a record (action + hour/minute/second) and returns a remove callable that reverses the registration. Tests inspect ``registrations`` and exercise the newest action through :meth:`fire`. """ @@ -257,13 +257,12 @@ class TimeChangeRegistry: self._hass = hass self._registrations: list[dict] = [] - def track(self, action, hour=None, minute=None, second=None, local=False): + def track(self, action, hour=None, minute=None, second=None): record = { "action": action, "hour": hour, "minute": minute, "second": second, - "local": local, } def _remove(): @@ -290,17 +289,19 @@ class TimeChangeRegistry: await result -def _async_track_time_change(hass, action, hour=None, minute=None, second=None, local=False): +def _async_track_time_change(hass, action, hour=None, minute=None, second=None): """Mirror homeassistant.helpers.event.async_track_time_change. - Routes to the registry attached to ``hass`` (created on demand), so - tests reach the registrations via ``hass.time_change``. + Exact HA 2024.6 signature — no ``local`` keyword: the local-time + wrapper is already this function. Routes to the registry attached to + ``hass`` (created on demand), so tests reach the registrations via + ``hass.time_change``. """ registry = getattr(hass, "time_change", None) if registry is None: registry = TimeChangeRegistry(hass) hass.time_change = registry - return registry.track(action, hour=hour, minute=minute, second=second, local=local) + return registry.track(action, hour=hour, minute=minute, second=second) _ha_mock("homeassistant.helpers.event").async_track_time_change = _async_track_time_change diff --git a/tests/test_lifecycle.py b/tests/test_lifecycle.py index 3516310..0acb96e 100644 --- a/tests/test_lifecycle.py +++ b/tests/test_lifecycle.py @@ -251,7 +251,6 @@ async def test_setup_registers_day_rollover_listener(hass, make_entry) -> None: registration = hass.time_change.registrations[0] assert registration["hour"] == 0 assert registration["minute"] == 0 - assert registration["local"] is True assert callable(entry.runtime_data.remove_time_change_listener) @@ -322,6 +321,23 @@ async def test_day_rollover_listener_materializes_ha_local_horizon( fake.assert_awaited_once_with(database, expected_start, expected_end) +def test_day_rollover_time_change_tracker_rejects_local_kwarg() -> None: + """The fake async_track_time_change mirrors HA 2024.6 (no ``local`` kwarg). + + Setup drives the local-time wrapper directly, so passing ``local=`` must + raise TypeError — otherwise a regression in the production call would be + silently masked by the fake. + """ + import inspect as _inspect + + from homeassistant.helpers.event import async_track_time_change + + params = _inspect.signature(async_track_time_change).parameters + assert list(params) == ["hass", "action", "hour", "minute", "second"] + with pytest.raises(TypeError): + async_track_time_change(None, lambda _now: None, hour=0, minute=0, local=True) + + async def test_setup_applies_all_v1_tables(hass, make_entry) -> None: """Setup applies the full v1 DDL: all four v1 tables exist afterwards.""" entry = _wire(make_entry(), hass.registry)