Remove deprecated YAML configuration from Buienradar (#52939)

This commit is contained in:
Franck Nijhof
2021-07-15 08:31:17 +02:00
committed by GitHub
parent db97fd3d5b
commit a5cdc0157b
8 changed files with 6 additions and 324 deletions
@@ -66,34 +66,6 @@ async def test_config_flow_already_configured_weather(hass):
assert result["reason"] == "already_configured"
async def test_import_camera(hass):
"""Test import of camera."""
with patch(
"homeassistant.components.buienradar.async_setup_entry", return_value=True
):
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_IMPORT},
data={CONF_LATITUDE: TEST_LATITUDE, CONF_LONGITUDE: TEST_LONGITUDE},
)
assert result["type"] == "create_entry"
assert result["title"] == f"{TEST_LATITUDE},{TEST_LONGITUDE}"
assert result["data"] == {
CONF_LATITUDE: TEST_LATITUDE,
CONF_LONGITUDE: TEST_LONGITUDE,
}
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_IMPORT},
data={CONF_LATITUDE: TEST_LATITUDE, CONF_LONGITUDE: TEST_LONGITUDE},
)
assert result["type"] == "abort"
assert result["reason"] == "already_configured"
async def test_options_flow(hass):
"""Test options flow."""
entry = MockConfigEntry(
-89
View File
@@ -1,11 +1,7 @@
"""Tests for the buienradar component."""
from unittest.mock import patch
from homeassistant import setup
from homeassistant.components.buienradar.const import DOMAIN
from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE
from homeassistant.helpers.entity_registry import async_get_registry
from tests.common import MockConfigEntry
@@ -13,91 +9,6 @@ TEST_LATITUDE = 51.5288504
TEST_LONGITUDE = 5.4002156
async def test_import_all(hass):
"""Test import of all platforms."""
config = {
"weather 1": [{"platform": "buienradar", "name": "test1"}],
"sensor 1": [{"platform": "buienradar", "timeframe": 30, "name": "test2"}],
"camera 1": [
{
"platform": "buienradar",
"country_code": "BE",
"delta": 300,
"name": "test3",
}
],
}
with patch(
"homeassistant.components.buienradar.async_setup_entry", return_value=True
):
await setup.async_setup_component(hass, DOMAIN, config)
await hass.async_block_till_done()
conf_entries = hass.config_entries.async_entries(DOMAIN)
assert len(conf_entries) == 1
entry = conf_entries[0]
assert entry.state is ConfigEntryState.LOADED
assert entry.data == {
"latitude": hass.config.latitude,
"longitude": hass.config.longitude,
"timeframe": 30,
"country_code": "BE",
"delta": 300,
"name": "test2",
}
async def test_import_camera(hass):
"""Test import of camera platform."""
entity_registry = await async_get_registry(hass)
entity_registry.async_get_or_create(
domain="camera",
platform="buienradar",
unique_id="512_NL",
original_name="test_name",
)
await hass.async_block_till_done()
config = {
"camera 1": [{"platform": "buienradar", "country_code": "NL", "dimension": 512}]
}
with patch(
"homeassistant.components.buienradar.async_setup_entry", return_value=True
):
await setup.async_setup_component(hass, DOMAIN, config)
await hass.async_block_till_done()
conf_entries = hass.config_entries.async_entries(DOMAIN)
assert len(conf_entries) == 1
entry = conf_entries[0]
assert entry.state is ConfigEntryState.LOADED
assert entry.data == {
"latitude": hass.config.latitude,
"longitude": hass.config.longitude,
"timeframe": 60,
"country_code": "NL",
"delta": 600,
"name": "Buienradar",
}
entity_id = entity_registry.async_get_entity_id(
"camera",
"buienradar",
f"{hass.config.latitude:2.6f}{hass.config.longitude:2.6f}",
)
assert entity_id
entity = entity_registry.async_get(entity_id)
assert entity.original_name == "test_name"
async def test_load_unload(aioclient_mock, hass):
"""Test options flow."""
entry = MockConfigEntry(