mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Code enhancements for ISS (#66813)
* Code enhancements for ISS * Assert options
This commit is contained in:
parent
4ff1f5c788
commit
52ca1a3d47
@ -12,7 +12,6 @@ PLATFORMS = [Platform.BINARY_SENSOR]
|
|||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up this integration using UI."""
|
"""Set up this integration using UI."""
|
||||||
|
|
||||||
hass.data.setdefault(DOMAIN, {})
|
hass.data.setdefault(DOMAIN, {})
|
||||||
|
|
||||||
entry.async_on_unload(entry.add_update_listener(update_listener))
|
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
|
return unload_ok
|
||||||
|
|
||||||
|
|
||||||
async def update_listener(hass: HomeAssistant, entry: ConfigEntry):
|
async def update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
||||||
"""Handle options update."""
|
"""Handle options update."""
|
||||||
await hass.config_entries.async_reload(entry.entry_id)
|
await hass.config_entries.async_reload(entry.entry_id)
|
||||||
|
@ -71,7 +71,6 @@ async def async_setup_entry(
|
|||||||
async_add_entities: AddEntitiesCallback,
|
async_add_entities: AddEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the sensor platform."""
|
"""Set up the sensor platform."""
|
||||||
|
|
||||||
name = entry.title
|
name = entry.title
|
||||||
show_on_map = entry.options.get(CONF_SHOW_ON_MAP, False)
|
show_on_map = entry.options.get(CONF_SHOW_ON_MAP, False)
|
||||||
|
|
||||||
|
@ -90,6 +90,9 @@ async def test_options(hass: HomeAssistant):
|
|||||||
|
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
|
with patch("homeassistant.components.iss.async_setup_entry", return_value=True):
|
||||||
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||||
|
|
||||||
optionflow = await hass.config_entries.options.async_init(config_entry.entry_id)
|
optionflow = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
|
|
||||||
configured = await hass.config_entries.options.async_configure(
|
configured = await hass.config_entries.options.async_configure(
|
||||||
@ -100,3 +103,4 @@ async def test_options(hass: HomeAssistant):
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert configured.get("type") == "create_entry"
|
assert configured.get("type") == "create_entry"
|
||||||
|
assert config_entry.options == {CONF_SHOW_ON_MAP: True}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user