Add already_configured coverage to oncue (#63919)

This commit is contained in:
J. Nick Koston 2022-01-11 10:44:44 -10:00 committed by GitHub
parent dd39389a11
commit 259975c116
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,7 +7,13 @@ from aiooncue import LoginFailedException
from homeassistant import config_entries
from homeassistant.components.oncue.const import DOMAIN
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import RESULT_TYPE_CREATE_ENTRY, RESULT_TYPE_FORM
from homeassistant.data_entry_flow import (
RESULT_TYPE_ABORT,
RESULT_TYPE_CREATE_ENTRY,
RESULT_TYPE_FORM,
)
from tests.common import MockConfigEntry
async def test_form(hass: HomeAssistant) -> None:
@ -104,3 +110,32 @@ async def test_form_unknown_exception(hass: HomeAssistant) -> None:
assert result2["type"] == RESULT_TYPE_FORM
assert result2["errors"] == {"base": "unknown"}
async def test_already_configured(hass: HomeAssistant) -> None:
"""Test already configured."""
entry = MockConfigEntry(
domain=DOMAIN,
data={
"username": "TEST-username",
"password": "test-password",
},
unique_id="test-username",
)
entry.add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
with patch("homeassistant.components.oncue.config_flow.Oncue.async_login"):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{
"username": "test-username",
"password": "test-password",
},
)
assert result2["type"] == RESULT_TYPE_ABORT
assert result2["reason"] == "already_configured"