Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 1 addition & 30 deletions homeassistant/components/flunearyou/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

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
Expand All @@ -27,17 +25,7 @@

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
Expand All @@ -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


Expand Down
4 changes: 0 additions & 4 deletions homeassistant/components/flunearyou/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ def data_schema(self):
}
)

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:
Expand Down
21 changes: 1 addition & 20 deletions tests/components/flunearyou/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

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
Expand Down Expand Up @@ -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"}
Expand Down