Code enhancements for ISS (#66813)

* Code enhancements for ISS

* Assert options
This commit is contained in:
Simon Hansen 2022-02-19 11:38:10 +01:00 committed by GitHub
parent 4ff1f5c788
commit 52ca1a3d47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 11 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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}