mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Remove config flow import from fastdotcom (#118665)
This commit is contained in:
parent
dd1d21c77a
commit
6a8a975fae
@ -4,46 +4,23 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import voluptuous as vol
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
|
||||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
|
||||||
from homeassistant.const import CONF_SCAN_INTERVAL
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.start import async_at_started
|
from homeassistant.helpers.start import async_at_started
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
from .const import CONF_MANUAL, DEFAULT_INTERVAL, DOMAIN, PLATFORMS
|
from .const import DOMAIN, PLATFORMS
|
||||||
from .coordinator import FastdotcomDataUpdateCoordinator
|
from .coordinator import FastdotcomDataUpdateCoordinator
|
||||||
from .services import async_setup_services
|
from .services import async_setup_services
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema(
|
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
|
||||||
{
|
|
||||||
DOMAIN: vol.Schema(
|
|
||||||
{
|
|
||||||
vol.Optional(CONF_SCAN_INTERVAL, default=DEFAULT_INTERVAL): vol.All(
|
|
||||||
cv.time_period, cv.positive_timedelta
|
|
||||||
),
|
|
||||||
vol.Optional(CONF_MANUAL, default=False): cv.boolean,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
extra=vol.ALLOW_EXTRA,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Set up the Fastdotcom component."""
|
"""Set up the Fastdotcom component."""
|
||||||
if DOMAIN in config:
|
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.flow.async_init(
|
|
||||||
DOMAIN,
|
|
||||||
context={"source": SOURCE_IMPORT},
|
|
||||||
data=config[DOMAIN],
|
|
||||||
)
|
|
||||||
)
|
|
||||||
async_setup_services(hass)
|
async_setup_services(hass)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -5,8 +5,6 @@ from __future__ import annotations
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN
|
|
||||||
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
|
||||||
|
|
||||||
from .const import DEFAULT_NAME, DOMAIN
|
from .const import DEFAULT_NAME, DOMAIN
|
||||||
|
|
||||||
@ -24,24 +22,3 @@ class FastdotcomConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
return self.async_create_entry(title=DEFAULT_NAME, data={})
|
return self.async_create_entry(title=DEFAULT_NAME, data={})
|
||||||
|
|
||||||
return self.async_show_form(step_id="user")
|
return self.async_show_form(step_id="user")
|
||||||
|
|
||||||
async def async_step_import(
|
|
||||||
self, user_input: dict[str, Any] | None = None
|
|
||||||
) -> ConfigFlowResult:
|
|
||||||
"""Handle a flow initiated by configuration file."""
|
|
||||||
async_create_issue(
|
|
||||||
self.hass,
|
|
||||||
HOMEASSISTANT_DOMAIN,
|
|
||||||
f"deprecated_yaml_{DOMAIN}",
|
|
||||||
breaks_in_ha_version="2024.6.0",
|
|
||||||
is_fixable=False,
|
|
||||||
issue_domain=DOMAIN,
|
|
||||||
severity=IssueSeverity.WARNING,
|
|
||||||
translation_key="deprecated_yaml",
|
|
||||||
translation_placeholders={
|
|
||||||
"domain": DOMAIN,
|
|
||||||
"integration_title": "Fast.com",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
return await self.async_step_user(user_input)
|
|
||||||
|
@ -4,7 +4,6 @@ from unittest.mock import patch
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries
|
|
||||||
from homeassistant.components.fastdotcom.const import DOMAIN
|
from homeassistant.components.fastdotcom.const import DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER
|
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -54,19 +53,3 @@ async def test_single_instance_allowed(
|
|||||||
|
|
||||||
assert result["type"] is FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == "single_instance_allowed"
|
assert result["reason"] == "single_instance_allowed"
|
||||||
|
|
||||||
|
|
||||||
async def test_import_flow_success(hass: HomeAssistant) -> None:
|
|
||||||
"""Test import flow."""
|
|
||||||
with patch("homeassistant.components.fastdotcom.coordinator.fast_com"):
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
|
||||||
DOMAIN,
|
|
||||||
context={"source": config_entries.SOURCE_IMPORT},
|
|
||||||
data={},
|
|
||||||
)
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
|
||||||
assert result["title"] == "Fast.com"
|
|
||||||
assert result["data"] == {}
|
|
||||||
assert result["options"] == {}
|
|
||||||
|
@ -11,7 +11,6 @@ from homeassistant.config_entries import ConfigEntryState
|
|||||||
from homeassistant.const import EVENT_HOMEASSISTANT_STARTED, STATE_UNKNOWN
|
from homeassistant.const import EVENT_HOMEASSISTANT_STARTED, STATE_UNKNOWN
|
||||||
from homeassistant.core import CoreState, HomeAssistant
|
from homeassistant.core import CoreState, HomeAssistant
|
||||||
from homeassistant.helpers import issue_registry as ir
|
from homeassistant.helpers import issue_registry as ir
|
||||||
from homeassistant.setup import async_setup_component
|
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
@ -37,23 +36,6 @@ async def test_unload_entry(hass: HomeAssistant) -> None:
|
|||||||
assert config_entry.state is ConfigEntryState.NOT_LOADED
|
assert config_entry.state is ConfigEntryState.NOT_LOADED
|
||||||
|
|
||||||
|
|
||||||
async def test_from_import(hass: HomeAssistant) -> None:
|
|
||||||
"""Test imported entry."""
|
|
||||||
with patch(
|
|
||||||
"homeassistant.components.fastdotcom.coordinator.fast_com", return_value=5.0
|
|
||||||
):
|
|
||||||
await async_setup_component(
|
|
||||||
hass,
|
|
||||||
DOMAIN,
|
|
||||||
{"fastdotcom": {}},
|
|
||||||
)
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
|
|
||||||
state = hass.states.get("sensor.fast_com_download")
|
|
||||||
assert state is not None
|
|
||||||
assert state.state == "5.0"
|
|
||||||
|
|
||||||
|
|
||||||
async def test_delayed_speedtest_during_startup(
|
async def test_delayed_speedtest_during_startup(
|
||||||
hass: HomeAssistant, freezer: FrozenDateTimeFactory
|
hass: HomeAssistant, freezer: FrozenDateTimeFactory
|
||||||
) -> None:
|
) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user