Remove deprecated yaml config from squeezebox (#62537)

This commit is contained in:
Robert Hillis 2021-12-22 06:03:31 -05:00 committed by GitHub
parent 5e25df91b2
commit ee878513a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 105 deletions

View file

@ -158,13 +158,6 @@ class SqueezeboxConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
step_id="edit", data_schema=self.data_schema, errors=errors
)
async def async_step_import(self, config):
"""Import a config flow from configuration."""
error = await self._validate_input(config)
if error:
return self.async_abort(reason=error)
return self.async_create_entry(title=config[CONF_HOST], data=config)
async def async_step_integration_discovery(self, discovery_info):
"""Handle discovery of a server."""
_LOGGER.debug("Reached server discovery flow with info: %s", discovery_info)

View file

@ -6,8 +6,7 @@ import logging
from pysqueezebox import Server, async_discover
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerEntity
from homeassistant.components.media_player import MediaPlayerEntity
from homeassistant.components.media_player.const import (
ATTR_MEDIA_ENQUEUE,
MEDIA_TYPE_MUSIC,
@ -51,13 +50,7 @@ from homeassistant.helpers.dispatcher import (
from homeassistant.util.dt import utcnow
from .browse_media import build_item_response, generate_playlist, library_payload
from .const import (
DEFAULT_PORT,
DISCOVERY_TASK,
DOMAIN,
KNOWN_PLAYERS,
PLAYER_DISCOVERY_UNSUB,
)
from .const import DISCOVERY_TASK, DOMAIN, KNOWN_PLAYERS, PLAYER_DISCOVERY_UNSUB
SERVICE_CALL_METHOD = "call_method"
SERVICE_CALL_QUERY = "call_query"
@ -90,21 +83,6 @@ SUPPORT_SQUEEZEBOX = (
| SUPPORT_STOP
)
PLATFORM_SCHEMA = vol.All(
cv.deprecated(CONF_HOST),
cv.deprecated(CONF_PORT),
cv.deprecated(CONF_PASSWORD),
cv.deprecated(CONF_USERNAME),
PLATFORM_SCHEMA.extend(
{
vol.Required(CONF_HOST): cv.string,
vol.Optional(CONF_PASSWORD): cv.string,
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
vol.Optional(CONF_USERNAME): cv.string,
}
),
)
KNOWN_SERVERS = "known_servers"
ATTR_PARAMETERS = "parameters"
ATTR_OTHER_PLAYER = "other_player"
@ -145,14 +123,6 @@ async def start_server_discovery(hass):
)
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up squeezebox platform from platform entry in configuration.yaml (deprecated)."""
if config:
await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=config
)
async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up an LMS Server from a config entry."""
config = config_entry.data

View file

@ -246,69 +246,3 @@ async def test_dhcp_discovery_existing_player(hass):
),
)
assert result["type"] == RESULT_TYPE_ABORT
async def test_import(hass):
"""Test handling of configuration imported."""
with patch("pysqueezebox.Server.async_query", return_value={"uuid": UUID},), patch(
"homeassistant.components.squeezebox.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={CONF_HOST: HOST, CONF_PORT: PORT},
)
assert result["type"] == RESULT_TYPE_CREATE_ENTRY
await hass.async_block_till_done()
assert len(mock_setup_entry.mock_calls) == 1
async def test_import_bad_host(hass):
"""Test handling of configuration imported with bad host."""
with patch("pysqueezebox.Server.async_query", return_value=False):
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_IMPORT},
data={CONF_HOST: HOST, CONF_PORT: PORT},
)
assert result["type"] == RESULT_TYPE_ABORT
assert result["reason"] == "cannot_connect"
async def test_import_bad_auth(hass):
"""Test handling of configuration import with bad authentication."""
with patch("pysqueezebox.Server.async_query", new=patch_async_query_unauthorized):
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_IMPORT},
data={
CONF_HOST: HOST,
CONF_PORT: PORT,
CONF_USERNAME: "test",
CONF_PASSWORD: "bad",
},
)
assert result["type"] == RESULT_TYPE_ABORT
assert result["reason"] == "invalid_auth"
async def test_import_existing(hass):
"""Test handling of configuration import of existing server."""
with patch(
"homeassistant.components.squeezebox.async_setup_entry",
return_value=True,
), patch(
"pysqueezebox.Server.async_query",
return_value={"ip": HOST, "uuid": UUID},
):
entry = MockConfigEntry(domain=DOMAIN, unique_id=UUID)
await hass.config_entries.async_add(entry)
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_IMPORT},
data={CONF_HOST: HOST, CONF_PORT: PORT},
)
assert result["type"] == RESULT_TYPE_ABORT
assert result["reason"] == "already_configured"