Fix hidden default (#70699)

This commit is contained in:
Paulus Schoutsen 2022-04-25 10:10:42 -07:00 committed by GitHub
parent 791138eb8b
commit 5317bf02e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View file

@ -230,7 +230,7 @@ class EntityDescription:
device_class: str | None = None device_class: str | None = None
entity_category: EntityCategory | None = None entity_category: EntityCategory | None = None
entity_registry_enabled_default: bool = True entity_registry_enabled_default: bool = True
entity_registry_visible_default: bool = False entity_registry_visible_default: bool = True
force_update: bool = False force_update: bool = False
icon: str | None = None icon: str | None = None
name: str | None = None name: str | None = None

View file

@ -1,6 +1,7 @@
"""Test the entity helper.""" """Test the entity helper."""
# pylint: disable=protected-access # pylint: disable=protected-access
import asyncio import asyncio
import dataclasses
from datetime import timedelta from datetime import timedelta
import threading import threading
from unittest.mock import MagicMock, PropertyMock, patch from unittest.mock import MagicMock, PropertyMock, patch
@ -932,3 +933,16 @@ def test_entity_category_schema_error(value):
match=r"expected EntityCategory or one of 'config', 'diagnostic', 'system'", match=r"expected EntityCategory or one of 'config', 'diagnostic', 'system'",
): ):
schema(value) schema(value)
async def test_entity_description_fallback():
"""Test entity description has same defaults as entity."""
ent = entity.Entity()
ent_with_description = entity.Entity()
ent_with_description.entity_description = entity.EntityDescription(key="test")
for field in dataclasses.fields(entity.EntityDescription):
if field.name == "key":
continue
assert getattr(ent, field.name) == getattr(ent_with_description, field.name)