mirror of
https://github.com/home-assistant/core.git
synced 2025-04-27 10:47:51 +00:00
Cleanup unused import in upb config flow (#124694)
* Cleanup unused import in upb config flow * More cleanup
This commit is contained in:
parent
18b49a6f62
commit
8ff8ed7f76
@ -79,10 +79,6 @@ class UPBConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
|
||||||
def __init__(self) -> None:
|
|
||||||
"""Initialize the UPB config flow."""
|
|
||||||
self.importing = False
|
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
@ -105,9 +101,6 @@ class UPBConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
await self.async_set_unique_id(network_id)
|
await self.async_set_unique_id(network_id)
|
||||||
self._abort_if_unique_id_configured()
|
self._abort_if_unique_id_configured()
|
||||||
|
|
||||||
if self.importing:
|
|
||||||
return self.async_create_entry(title=info["title"], data=user_input)
|
|
||||||
|
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
title=info["title"],
|
title=info["title"],
|
||||||
data={
|
data={
|
||||||
@ -120,11 +113,6 @@ class UPBConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
step_id="user", data_schema=DATA_SCHEMA, errors=errors
|
step_id="user", data_schema=DATA_SCHEMA, errors=errors
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_import(self, user_input):
|
|
||||||
"""Handle import."""
|
|
||||||
self.importing = True
|
|
||||||
return await self.async_step_user(user_input)
|
|
||||||
|
|
||||||
def _url_already_configured(self, url):
|
def _url_already_configured(self, url):
|
||||||
"""See if we already have a UPB PIM matching user input configured."""
|
"""See if we already have a UPB PIM matching user input configured."""
|
||||||
existing_hosts = {
|
existing_hosts = {
|
||||||
|
@ -114,42 +114,3 @@ async def test_form_user_with_already_configured(hass: HomeAssistant) -> None:
|
|||||||
assert result2["type"] is FlowResultType.ABORT
|
assert result2["type"] is FlowResultType.ABORT
|
||||||
assert result2["reason"] == "already_configured"
|
assert result2["reason"] == "already_configured"
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
|
||||||
async def test_form_import(hass: HomeAssistant) -> None:
|
|
||||||
"""Test we get the form with import source."""
|
|
||||||
|
|
||||||
with (
|
|
||||||
mocked_upb(),
|
|
||||||
patch(
|
|
||||||
"homeassistant.components.upb.async_setup_entry", return_value=True
|
|
||||||
) as mock_setup_entry,
|
|
||||||
):
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
|
||||||
DOMAIN,
|
|
||||||
context={"source": config_entries.SOURCE_IMPORT},
|
|
||||||
data={"host": "tcp://42.4.2.42", "file_path": "upb.upe"},
|
|
||||||
)
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
|
||||||
assert result["title"] == "UPB"
|
|
||||||
|
|
||||||
assert result["data"] == {"host": "tcp://42.4.2.42", "file_path": "upb.upe"}
|
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
|
||||||
|
|
||||||
|
|
||||||
async def test_form_junk_input(hass: HomeAssistant) -> None:
|
|
||||||
"""Test we get the form with import source."""
|
|
||||||
|
|
||||||
with mocked_upb():
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
|
||||||
DOMAIN,
|
|
||||||
context={"source": config_entries.SOURCE_IMPORT},
|
|
||||||
data={"foo": "goo", "goo": "foo"},
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
|
||||||
assert result["errors"] == {"base": "unknown"}
|
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user