mirror of
https://github.com/home-assistant/core.git
synced 2025-07-30 16:57:19 +00:00
Improve config entry has already been setup error message (#117091)
This commit is contained in:
parent
82fab7df39
commit
11f86d9e0b
@ -182,7 +182,10 @@ class EntityComponent(Generic[_EntityT]):
|
|||||||
key = config_entry.entry_id
|
key = config_entry.entry_id
|
||||||
|
|
||||||
if key in self._platforms:
|
if key in self._platforms:
|
||||||
raise ValueError("Config entry has already been setup!")
|
raise ValueError(
|
||||||
|
f"Config entry {config_entry.title} ({key}) for "
|
||||||
|
f"{platform_type}.{self.domain} has already been setup!"
|
||||||
|
)
|
||||||
|
|
||||||
self._platforms[key] = self._async_init_entity_platform(
|
self._platforms[key] = self._async_init_entity_platform(
|
||||||
platform_type,
|
platform_type,
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
import re
|
||||||
from unittest.mock import AsyncMock, Mock, patch
|
from unittest.mock import AsyncMock, Mock, patch
|
||||||
|
|
||||||
from freezegun import freeze_time
|
from freezegun import freeze_time
|
||||||
@ -365,7 +366,13 @@ async def test_setup_entry_fails_duplicate(hass: HomeAssistant) -> None:
|
|||||||
|
|
||||||
assert await component.async_setup_entry(entry)
|
assert await component.async_setup_entry(entry)
|
||||||
|
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(
|
||||||
|
ValueError,
|
||||||
|
match=re.escape(
|
||||||
|
f"Config entry Mock Title ({entry.entry_id}) for "
|
||||||
|
"entry_domain.test_domain has already been setup!"
|
||||||
|
),
|
||||||
|
):
|
||||||
await component.async_setup_entry(entry)
|
await component.async_setup_entry(entry)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user