mirror of
https://github.com/home-assistant/core.git
synced 2025-08-10 16:15:08 +02:00
Only allow single Home Connect config entry (#137088)
* Make Home Connect config entry unique
* Use unique ID for Home connect config entry
* Remove unnecessary code
* Revert "Use unique ID for Home connect config entry"
This reverts commit 4241317469
.
* Added tests
This commit is contained in:
committed by
GitHub
parent
7f6855045a
commit
91dbe3092f
@@ -7,5 +7,6 @@
|
||||
"documentation": "https://www.home-assistant.io/integrations/home_connect",
|
||||
"iot_class": "cloud_push",
|
||||
"loggers": ["aiohomeconnect"],
|
||||
"requirements": ["aiohomeconnect==0.12.3"]
|
||||
"requirements": ["aiohomeconnect==0.12.3"],
|
||||
"single_config_entry": true
|
||||
}
|
||||
|
@@ -2609,7 +2609,8 @@
|
||||
"name": "Home Connect",
|
||||
"integration_type": "hub",
|
||||
"config_flow": true,
|
||||
"iot_class": "cloud_push"
|
||||
"iot_class": "cloud_push",
|
||||
"single_config_entry": true
|
||||
},
|
||||
"home_plus_control": {
|
||||
"name": "Legrand Home+ Control",
|
||||
|
@@ -16,6 +16,7 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||
from tests.typing import ClientSessionGenerator
|
||||
|
||||
@@ -77,3 +78,18 @@ async def test_full_flow(
|
||||
|
||||
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_prevent_multiple_config_entries(
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test we only allow one config entry."""
|
||||
config_entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
"home_connect", context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["reason"] == "single_instance_allowed"
|
||||
|
Reference in New Issue
Block a user