mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Improve airq test coverage (#90192)
* Add a missing test for aborting with "already_configured" Test that config_flow aborts with "already_configured" when the integration has already been configured * Don't copy test data Since #90232 is merged, it is no longer needed * Split the initialisation into two steps, as it should be
This commit is contained in:
parent
d228df6d81
commit
091932c3ac
@ -11,6 +11,8 @@ from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResultType
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
pytestmark = pytest.mark.usefixtures("mock_setup_entry")
|
pytestmark = pytest.mark.usefixtures("mock_setup_entry")
|
||||||
|
|
||||||
TEST_USER_DATA = {
|
TEST_USER_DATA = {
|
||||||
@ -91,3 +93,25 @@ async def test_form_invalid_input(hass: HomeAssistant) -> None:
|
|||||||
|
|
||||||
assert result2["type"] == FlowResultType.FORM
|
assert result2["type"] == FlowResultType.FORM
|
||||||
assert result2["errors"] == {"base": "invalid_input"}
|
assert result2["errors"] == {"base": "invalid_input"}
|
||||||
|
|
||||||
|
|
||||||
|
async def test_duplicate_error(hass: HomeAssistant) -> None:
|
||||||
|
"""Test that errors are shown when duplicates are added."""
|
||||||
|
MockConfigEntry(
|
||||||
|
data=TEST_USER_DATA,
|
||||||
|
domain=DOMAIN,
|
||||||
|
unique_id=TEST_DEVICE_INFO["id"],
|
||||||
|
).add_to_hass(hass)
|
||||||
|
|
||||||
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
|
)
|
||||||
|
|
||||||
|
with patch("aioairq.AirQ.validate"), patch(
|
||||||
|
"aioairq.AirQ.fetch_device_info", return_value=TEST_DEVICE_INFO
|
||||||
|
):
|
||||||
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
result["flow_id"], TEST_USER_DATA
|
||||||
|
)
|
||||||
|
assert result2["type"] == FlowResultType.ABORT
|
||||||
|
assert result2["reason"] == "already_configured"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user