mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Abort UniFi Network options flow if integration is not setup (#71128)
This commit is contained in:
parent
2e20ec21c4
commit
63e3095062
@ -256,6 +256,8 @@ class UnifiOptionsFlowHandler(config_entries.OptionsFlow):
|
|||||||
|
|
||||||
async def async_step_init(self, user_input=None):
|
async def async_step_init(self, user_input=None):
|
||||||
"""Manage the UniFi Network options."""
|
"""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.controller = self.hass.data[UNIFI_DOMAIN][self.config_entry.entry_id]
|
||||||
self.options[CONF_BLOCK_CLIENT] = self.controller.option_block_clients
|
self.options[CONF_BLOCK_CLIENT] = self.controller.option_block_clients
|
||||||
|
|
||||||
|
@ -21,11 +21,14 @@
|
|||||||
},
|
},
|
||||||
"abort": {
|
"abort": {
|
||||||
"already_configured": "UniFi Network site is already configured",
|
"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%]"
|
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
|
"abort": {
|
||||||
|
"integration_not_setup": "UniFi integration is not setup"
|
||||||
|
},
|
||||||
"step": {
|
"step": {
|
||||||
"device_tracker": {
|
"device_tracker": {
|
||||||
"data": {
|
"data": {
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
|
"abort": {
|
||||||
|
"integration_not_setup": "UniFi integration is not setup"
|
||||||
|
},
|
||||||
"step": {
|
"step": {
|
||||||
"client_control": {
|
"client_control": {
|
||||||
"data": {
|
"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):
|
async def test_form_ssdp(hass):
|
||||||
"""Test we get the form with ssdp source."""
|
"""Test we get the form with ssdp source."""
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user