mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Log type as well as value for unique_id checks (#129575)
This commit is contained in:
parent
6a32722acc
commit
696efe349e
@ -1638,11 +1638,12 @@ class ConfigEntryItems(UserDict[str, ConfigEntry]):
|
|||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
(
|
(
|
||||||
"Config entry '%s' from integration %s has an invalid unique_id"
|
"Config entry '%s' from integration %s has an invalid unique_id"
|
||||||
" '%s', please %s"
|
" '%s' of type %s when a string is expected, please %s"
|
||||||
),
|
),
|
||||||
entry.title,
|
entry.title,
|
||||||
entry.domain,
|
entry.domain,
|
||||||
entry.unique_id,
|
entry.unique_id,
|
||||||
|
type(entry.unique_id).__name__,
|
||||||
report_issue,
|
report_issue,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
@ -5447,16 +5447,17 @@ async def test_string_unique_id_no_warning(
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"unique_id",
|
("unique_id", "type_name"),
|
||||||
[
|
[
|
||||||
(123),
|
(123, "int"),
|
||||||
(2.3),
|
(2.3, "float"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_hashable_unique_id(
|
async def test_hashable_unique_id(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
caplog: pytest.LogCaptureFixture,
|
caplog: pytest.LogCaptureFixture,
|
||||||
unique_id: Any,
|
unique_id: Any,
|
||||||
|
type_name: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the ConfigEntryItems user dict handles hashable non string unique_id."""
|
"""Test the ConfigEntryItems user dict handles hashable non string unique_id."""
|
||||||
entries = config_entries.ConfigEntryItems(hass)
|
entries = config_entries.ConfigEntryItems(hass)
|
||||||
@ -5477,6 +5478,7 @@ async def test_hashable_unique_id(
|
|||||||
|
|
||||||
assert (
|
assert (
|
||||||
"Config entry 'title' from integration test has an invalid unique_id"
|
"Config entry 'title' from integration test has an invalid unique_id"
|
||||||
|
f" '{unique_id}' of type {type_name} when a string is expected"
|
||||||
) in caplog.text
|
) in caplog.text
|
||||||
|
|
||||||
assert entry.entry_id in entries
|
assert entry.entry_id in entries
|
||||||
|
Loading…
x
Reference in New Issue
Block a user