Deprecate YAML config for Flu Near You (0.119 removal) (#42535)

This commit is contained in:
Aaron Bach 2020-10-28 18:54:51 -06:00 committed by GitHub
parent 026e0063fe
commit 3fb091c4ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 54 deletions

View file

@ -4,9 +4,7 @@ from datetime import timedelta
from pyflunearyou import Client
from pyflunearyou.errors import FluNearYouError
import voluptuous as vol
from homeassistant.config_entries import SOURCE_IMPORT
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE
from homeassistant.core import callback
from homeassistant.helpers import aiohttp_client, config_validation as cv
@ -27,17 +25,7 @@ DATA_LISTENER = "listener"
DEFAULT_SCAN_INTERVAL = timedelta(minutes=30)
CONFIG_SCHEMA = vol.Schema(
{
vol.Optional(DOMAIN): vol.Schema(
{
vol.Optional(CONF_LATITUDE): cv.latitude,
vol.Optional(CONF_LONGITUDE): cv.longitude,
}
)
},
extra=vol.ALLOW_EXTRA,
)
CONFIG_SCHEMA = cv.deprecated(DOMAIN, invalidation_version="0.119")
@callback
@ -59,23 +47,6 @@ def async_get_api_category(sensor_type):
async def async_setup(hass, config):
"""Set up the Flu Near You component."""
hass.data[DOMAIN] = {DATA_CLIENT: {}, DATA_LISTENER: {}}
if DOMAIN not in config:
return True
hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_IMPORT},
data={
CONF_LATITUDE: config[DOMAIN].get(CONF_LATITUDE, hass.config.latitude),
CONF_LONGITUDE: config[DOMAIN].get(
CONF_LATITUDE, hass.config.longitude
),
},
)
)
return True

View file

@ -30,10 +30,6 @@ class FluNearYouFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
}
)
async def async_step_import(self, import_config):
"""Import a config entry from configuration.yaml."""
return await self.async_step_user(import_config)
async def async_step_user(self, user_input=None):
"""Handle the start of the config flow."""
if not user_input:

View file

@ -3,7 +3,7 @@ from pyflunearyou.errors import FluNearYouError
from homeassistant import data_entry_flow
from homeassistant.components.flunearyou import DOMAIN
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER
from homeassistant.config_entries import SOURCE_USER
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE
from tests.async_mock import patch
@ -50,25 +50,6 @@ async def test_show_form(hass):
assert result["step_id"] == "user"
async def test_step_import(hass):
"""Test that the import step works."""
conf = {CONF_LATITUDE: "51.528308", CONF_LONGITUDE: "-0.3817765"}
with patch(
"homeassistant.components.flunearyou.async_setup_entry", return_value=True
), patch("pyflunearyou.cdc.CdcReport.status_by_coordinates"):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_IMPORT}, data=conf
)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["title"] == "51.528308, -0.3817765"
assert result["data"] == {
CONF_LATITUDE: "51.528308",
CONF_LONGITUDE: "-0.3817765",
}
async def test_step_user(hass):
"""Test that the user step works."""
conf = {CONF_LATITUDE: "51.528308", CONF_LONGITUDE: "-0.3817765"}