mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 17:57:55 +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,
|
||||
)
|
||||
|
||||
from .config_flow import configured_instances
|
||||
from .const import (
|
||||
ATTR_ALARM_DURATION,
|
||||
ATTR_ALARM_VOLUME,
|
||||
@ -182,9 +181,6 @@ async def async_setup(hass, config):
|
||||
conf = config[DOMAIN]
|
||||
|
||||
for account in conf[CONF_ACCOUNTS]:
|
||||
if account[CONF_USERNAME] in configured_instances(hass):
|
||||
continue
|
||||
|
||||
hass.async_create_task(
|
||||
hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
@ -202,6 +198,11 @@ async def async_setup(hass, config):
|
||||
|
||||
async def async_setup_entry(hass, 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)
|
||||
|
||||
websession = aiohttp_client.async_get_clientsession(hass)
|
||||
|
@ -5,18 +5,9 @@ import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.const import CONF_CODE, CONF_PASSWORD, CONF_TOKEN, CONF_USERNAME
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers import aiohttp_client
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
|
||||
@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)
|
||||
)
|
||||
from .const import DOMAIN # pylint: disable=unused-import
|
||||
|
||||
|
||||
class SimpliSafeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
@ -2,6 +2,8 @@
|
||||
import json
|
||||
from unittest.mock import MagicMock, PropertyMock, mock_open, patch
|
||||
|
||||
from simplipy.errors import SimplipyError
|
||||
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.components.simplisafe import DOMAIN, config_flow
|
||||
from homeassistant.config_entries import SOURCE_USER
|
||||
@ -33,21 +35,8 @@ async def test_duplicate_error(hass):
|
||||
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):
|
||||
"""Test that invalid credentials throws an error."""
|
||||
from simplipy.errors import SimplipyError
|
||||
|
||||
conf = {CONF_USERNAME: "user@email.com", CONF_PASSWORD: "password"}
|
||||
|
||||
flow = config_flow.SimpliSafeFlowHandler()
|
||||
|
Loading…
x
Reference in New Issue
Block a user