mirror of
https://github.com/home-assistant/core.git
synced 2026-09-28 02:18:10 -04:00
Add optimistic updates for Indevolt (#173091)
This commit is contained in:
@@ -62,12 +62,8 @@ async def test_select_option(
|
||||
# Reset mock call count for this iteration
|
||||
mock_indevolt.set_data.reset_mock()
|
||||
|
||||
# Update mock data to reflect the new value
|
||||
mock_indevolt.fetch_data.return_value[IndevoltConfig.READ_ENERGY_MODE] = (
|
||||
expected_value
|
||||
)
|
||||
|
||||
# Attempt to change option
|
||||
fetch_count_before = mock_indevolt.fetch_data.call_count
|
||||
await hass.services.async_call(
|
||||
SELECT_DOMAIN,
|
||||
SERVICE_SELECT_OPTION,
|
||||
@@ -80,7 +76,8 @@ async def test_select_option(
|
||||
IndevoltConfig.WRITE_ENERGY_MODE, expected_value
|
||||
)
|
||||
|
||||
# Verify updated state
|
||||
# Verify state updated optimistically without a new fetch
|
||||
assert mock_indevolt.fetch_data.call_count == fetch_count_before
|
||||
assert (state := hass.states.get("select.cms_sf2000_energy_mode")) is not None
|
||||
assert state.state == option
|
||||
|
||||
|
||||
Reference in New Issue
Block a user