Use async_config_entry_first_refresh in Subaru setup (#181015)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
John Pettitt
2026-09-02 07:48:27 +02:00
committed by GitHub
co-authored by Claude Fable 5
parent 1a0baa3f36
commit 8061e0d349
4 changed files with 15 additions and 15 deletions
+1 -1
View File
@@ -75,7 +75,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: SubaruConfigEntry) -> bo
hass, entry, controller=controller, vehicle_info=vehicle_info
)
await coordinator.async_refresh()
await coordinator.async_config_entry_first_refresh()
entry.runtime_data = SubaruRuntimeData(
controller=controller,
+6 -5
View File
@@ -26,6 +26,7 @@ from .conftest import (
MOCK_API,
MOCK_API_FETCH,
MOCK_API_GET_DATA,
advance_time_to_next_fetch,
setup_subaru_config_entry,
)
@@ -302,12 +303,12 @@ async def test_no_buttons_without_remote_start(
async def test_button_unavailable_on_fetch_failure(
hass: HomeAssistant, subaru_config_entry: MockConfigEntry
hass: HomeAssistant, ev_entry: MockConfigEntry
) -> None:
"""Test button goes unavailable when the coordinator fails to fetch data."""
await setup_subaru_config_entry(
hass, subaru_config_entry, fetch_effect=SubaruException("403 Error")
)
"""Test button goes unavailable when a fetch fails after setup."""
with patch(MOCK_API_FETCH, side_effect=SubaruException("403 Error")):
advance_time_to_next_fetch(hass)
await hass.async_block_till_done()
state = hass.states.get(VEHICLE_BUTTONS[TEST_VIN_2_EV]["remote_start"])
assert state.state == STATE_UNAVAILABLE
+2 -3
View File
@@ -172,7 +172,7 @@ async def test_update_disabled(hass: HomeAssistant, ev_entry) -> None:
async def test_fetch_failed(hass: HomeAssistant, subaru_config_entry) -> None:
"""Tests when fetch fails."""
"""Test setup retries when the first fetch fails."""
await setup_subaru_config_entry(
hass,
subaru_config_entry,
@@ -182,8 +182,7 @@ async def test_fetch_failed(hass: HomeAssistant, subaru_config_entry) -> None:
fetch_effect=SubaruException("403 Error"),
)
test_entity = hass.states.get(TEST_ENTITY_ID)
assert test_entity.state == "unavailable"
assert subaru_config_entry.state is ConfigEntryState.SETUP_RETRY
async def test_unload_entry(hass: HomeAssistant, ev_entry) -> None:
+6 -6
View File
@@ -23,7 +23,7 @@ from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import entity_registry as er
from .conftest import MOCK_API, setup_subaru_config_entry
from .conftest import MOCK_API, MOCK_API_FETCH, advance_time_to_next_fetch
from tests.common import MockConfigEntry
@@ -98,12 +98,12 @@ async def test_unlock_specific_door_invalid(hass: HomeAssistant, ev_entry) -> No
async def test_lock_unavailable_on_fetch_failure(
hass: HomeAssistant, subaru_config_entry: MockConfigEntry
hass: HomeAssistant, ev_entry: MockConfigEntry
) -> None:
"""Test lock goes unavailable when the coordinator fails to fetch data."""
await setup_subaru_config_entry(
hass, subaru_config_entry, fetch_effect=SubaruException("403 Error")
)
"""Test lock goes unavailable when a fetch fails after setup."""
with patch(MOCK_API_FETCH, side_effect=SubaruException("403 Error")):
advance_time_to_next_fetch(hass)
await hass.async_block_till_done()
state = hass.states.get(DEVICE_ID)
assert state.state == STATE_UNAVAILABLE