Code enhancements for ISS (#66813)
* Code enhancements for ISS * Assert options
This commit is contained in:
parent
4ff1f5c788
commit
52ca1a3d47
3 changed files with 13 additions and 11 deletions
|
@ -12,7 +12,6 @@ PLATFORMS = [Platform.BINARY_SENSOR]
|
|||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Set up this integration using UI."""
|
||||
|
||||
hass.data.setdefault(DOMAIN, {})
|
||||
|
||||
entry.async_on_unload(entry.add_update_listener(update_listener))
|
||||
|
@ -29,6 +28,6 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
return unload_ok
|
||||
|
||||
|
||||
async def update_listener(hass: HomeAssistant, entry: ConfigEntry):
|
||||
async def update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
||||
"""Handle options update."""
|
||||
await hass.config_entries.async_reload(entry.entry_id)
|
||||
|
|
|
@ -71,7 +71,6 @@ async def async_setup_entry(
|
|||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up the sensor platform."""
|
||||
|
||||
name = entry.title
|
||||
show_on_map = entry.options.get(CONF_SHOW_ON_MAP, False)
|
||||
|
||||
|
|
|
@ -90,13 +90,17 @@ async def test_options(hass: HomeAssistant):
|
|||
|
||||
config_entry.add_to_hass(hass)
|
||||
|
||||
optionflow = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||
with patch("homeassistant.components.iss.async_setup_entry", return_value=True):
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
|
||||
configured = await hass.config_entries.options.async_configure(
|
||||
optionflow["flow_id"],
|
||||
user_input={
|
||||
CONF_SHOW_ON_MAP: True,
|
||||
},
|
||||
)
|
||||
optionflow = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||
|
||||
assert configured.get("type") == "create_entry"
|
||||
configured = await hass.config_entries.options.async_configure(
|
||||
optionflow["flow_id"],
|
||||
user_input={
|
||||
CONF_SHOW_ON_MAP: True,
|
||||
},
|
||||
)
|
||||
|
||||
assert configured.get("type") == "create_entry"
|
||||
assert config_entry.options == {CONF_SHOW_ON_MAP: True}
|
||||
|
|
Loading…
Add table
Reference in a new issue