mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 06:17:07 +00:00
Remove unused SimpliSafe config flow function (#32166)
* Remove unused SimpliSafe config flow function * Code review comments from other PR * Linting
This commit is contained in:
parent
75f465bf7e
commit
7c2765fbff
@ -40,7 +40,6 @@ from homeassistant.helpers.service import (
|
|||||||
verify_domain_control,
|
verify_domain_control,
|
||||||
)
|
)
|
||||||
|
|
||||||
from .config_flow import configured_instances
|
|
||||||
from .const import (
|
from .const import (
|
||||||
ATTR_ALARM_DURATION,
|
ATTR_ALARM_DURATION,
|
||||||
ATTR_ALARM_VOLUME,
|
ATTR_ALARM_VOLUME,
|
||||||
@ -182,9 +181,6 @@ async def async_setup(hass, config):
|
|||||||
conf = config[DOMAIN]
|
conf = config[DOMAIN]
|
||||||
|
|
||||||
for account in conf[CONF_ACCOUNTS]:
|
for account in conf[CONF_ACCOUNTS]:
|
||||||
if account[CONF_USERNAME] in configured_instances(hass):
|
|
||||||
continue
|
|
||||||
|
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
hass.config_entries.flow.async_init(
|
hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
@ -202,6 +198,11 @@ async def async_setup(hass, config):
|
|||||||
|
|
||||||
async def async_setup_entry(hass, config_entry):
|
async def async_setup_entry(hass, config_entry):
|
||||||
"""Set up SimpliSafe as config entry."""
|
"""Set up SimpliSafe as config entry."""
|
||||||
|
if not config_entry.unique_id:
|
||||||
|
hass.config_entries.async_update_entry(
|
||||||
|
config_entry, unique_id=config_entry.data[CONF_USERNAME]
|
||||||
|
)
|
||||||
|
|
||||||
_verify_domain_control = verify_domain_control(hass, DOMAIN)
|
_verify_domain_control = verify_domain_control(hass, DOMAIN)
|
||||||
|
|
||||||
websession = aiohttp_client.async_get_clientsession(hass)
|
websession = aiohttp_client.async_get_clientsession(hass)
|
||||||
|
@ -5,18 +5,9 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.const import CONF_CODE, CONF_PASSWORD, CONF_TOKEN, CONF_USERNAME
|
from homeassistant.const import CONF_CODE, CONF_PASSWORD, CONF_TOKEN, CONF_USERNAME
|
||||||
from homeassistant.core import callback
|
|
||||||
from homeassistant.helpers import aiohttp_client
|
from homeassistant.helpers import aiohttp_client
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN # pylint: disable=unused-import
|
||||||
|
|
||||||
|
|
||||||
@callback
|
|
||||||
def configured_instances(hass):
|
|
||||||
"""Return a set of configured SimpliSafe instances."""
|
|
||||||
return set(
|
|
||||||
entry.data[CONF_USERNAME] for entry in hass.config_entries.async_entries(DOMAIN)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class SimpliSafeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
class SimpliSafeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
import json
|
import json
|
||||||
from unittest.mock import MagicMock, PropertyMock, mock_open, patch
|
from unittest.mock import MagicMock, PropertyMock, mock_open, patch
|
||||||
|
|
||||||
|
from simplipy.errors import SimplipyError
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import data_entry_flow
|
||||||
from homeassistant.components.simplisafe import DOMAIN, config_flow
|
from homeassistant.components.simplisafe import DOMAIN, config_flow
|
||||||
from homeassistant.config_entries import SOURCE_USER
|
from homeassistant.config_entries import SOURCE_USER
|
||||||
@ -33,21 +35,8 @@ async def test_duplicate_error(hass):
|
|||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
async def test_get_configured_instances(hass):
|
|
||||||
"""Test retrieving all configured instances."""
|
|
||||||
conf = {CONF_USERNAME: "user@email.com", CONF_PASSWORD: "password"}
|
|
||||||
|
|
||||||
MockConfigEntry(domain=DOMAIN, unique_id="user@email.com", data=conf).add_to_hass(
|
|
||||||
hass
|
|
||||||
)
|
|
||||||
|
|
||||||
assert len(config_flow.configured_instances(hass)) == 1
|
|
||||||
|
|
||||||
|
|
||||||
async def test_invalid_credentials(hass):
|
async def test_invalid_credentials(hass):
|
||||||
"""Test that invalid credentials throws an error."""
|
"""Test that invalid credentials throws an error."""
|
||||||
from simplipy.errors import SimplipyError
|
|
||||||
|
|
||||||
conf = {CONF_USERNAME: "user@email.com", CONF_PASSWORD: "password"}
|
conf = {CONF_USERNAME: "user@email.com", CONF_PASSWORD: "password"}
|
||||||
|
|
||||||
flow = config_flow.SimpliSafeFlowHandler()
|
flow = config_flow.SimpliSafeFlowHandler()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user