mirror of
https://github.com/home-assistant/core.git
synced 2026-05-08 17:49:37 +01:00
Remove deprecated YAML configuration from Epson (#55045)
This commit is contained in:
@@ -7,8 +7,6 @@ from homeassistant import config_entries, setup
|
||||
from homeassistant.components.epson.const import DOMAIN
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME, STATE_UNAVAILABLE
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_form(hass):
|
||||
"""Test we get the form."""
|
||||
@@ -75,70 +73,3 @@ async def test_form_powered_off(hass):
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["errors"] == {"base": "powered_off"}
|
||||
|
||||
|
||||
async def test_import(hass):
|
||||
"""Test config.yaml import."""
|
||||
with patch(
|
||||
"homeassistant.components.epson.Projector.get_power",
|
||||
return_value="01",
|
||||
), patch(
|
||||
"homeassistant.components.epson.Projector.get_property",
|
||||
return_value="04",
|
||||
), patch(
|
||||
"homeassistant.components.epson.async_setup_entry",
|
||||
return_value=True,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_IMPORT},
|
||||
data={CONF_HOST: "1.1.1.1", CONF_NAME: "test-epson"},
|
||||
)
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["title"] == "test-epson"
|
||||
assert result["data"] == {CONF_HOST: "1.1.1.1"}
|
||||
|
||||
|
||||
async def test_already_imported(hass):
|
||||
"""Test config.yaml imported twice."""
|
||||
MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
source=config_entries.SOURCE_IMPORT,
|
||||
unique_id="bla",
|
||||
title="test-epson",
|
||||
data={CONF_HOST: "1.1.1.1"},
|
||||
).add_to_hass(hass)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.epson.Projector.get_power",
|
||||
return_value="01",
|
||||
), patch(
|
||||
"homeassistant.components.epson.Projector.get_property",
|
||||
return_value="04",
|
||||
), patch(
|
||||
"homeassistant.components.epson.async_setup_entry",
|
||||
return_value=True,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_IMPORT},
|
||||
data={CONF_HOST: "1.1.1.1", CONF_NAME: "test-epson"},
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_import_cannot_connect(hass):
|
||||
"""Test we handle cannot connect error."""
|
||||
with patch(
|
||||
"homeassistant.components.epson.Projector.get_power",
|
||||
return_value=STATE_UNAVAILABLE,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_IMPORT},
|
||||
data={CONF_HOST: "1.1.1.1", CONF_NAME: "test-epson"},
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["reason"] == "cannot_connect"
|
||||
|
||||
Reference in New Issue
Block a user