Abort UniFi Network options flow if integration is not setup (#71128)
parent
4751356638
commit
174717dd85
|
@ -256,6 +256,8 @@ class UnifiOptionsFlowHandler(config_entries.OptionsFlow):
|
|||
|
||||
async def async_step_init(self, user_input=None):
|
||||
"""Manage the UniFi Network options."""
|
||||
if self.config_entry.entry_id not in self.hass.data[UNIFI_DOMAIN]:
|
||||
return self.async_abort(reason="integration_not_setup")
|
||||
self.controller = self.hass.data[UNIFI_DOMAIN][self.config_entry.entry_id]
|
||||
self.options[CONF_BLOCK_CLIENT] = self.controller.option_block_clients
|
||||
|
||||
|
|
|
@ -21,11 +21,14 @@
|
|||
},
|
||||
"abort": {
|
||||
"already_configured": "UniFi Network site is already configured",
|
||||
"configuration_updated": "Configuration updated.",
|
||||
"configuration_updated": "Configuration updated",
|
||||
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]"
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
"abort": {
|
||||
"integration_not_setup": "UniFi integration is not setup"
|
||||
},
|
||||
"step": {
|
||||
"device_tracker": {
|
||||
"data": {
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
}
|
||||
},
|
||||
"options": {
|
||||
"abort": {
|
||||
"integration_not_setup": "UniFi integration is not setup"
|
||||
},
|
||||
"step": {
|
||||
"client_control": {
|
||||
"data": {
|
||||
|
|
|
@ -542,6 +542,17 @@ async def test_simple_option_flow(hass, aioclient_mock):
|
|||
}
|
||||
|
||||
|
||||
async def test_option_flow_integration_not_setup(hass, aioclient_mock):
|
||||
"""Test advanced config flow options."""
|
||||
config_entry = await setup_unifi_integration(hass, aioclient_mock)
|
||||
|
||||
hass.data[UNIFI_DOMAIN].pop(config_entry.entry_id)
|
||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["reason"] == "integration_not_setup"
|
||||
|
||||
|
||||
async def test_form_ssdp(hass):
|
||||
"""Test we get the form with ssdp source."""
|
||||
|
||||
|
|
Loading…
Reference in New Issue