async def test_entity_category_property(hass):
    """Test entity category property."""
    mock_entity1 = entity.Entity()
    mock_entity1.hass = hass
    mock_entity1.entity_description = entity.EntityDescription(
        key="abc", entity_category="ignore_me")
    mock_entity1.entity_id = "hello.world"
    mock_entity1._attr_entity_category = entity.EntityCategory.CONFIG
    assert mock_entity1.entity_category == "config"

    mock_entity2 = entity.Entity()
    mock_entity2.hass = hass
    mock_entity2.entity_description = entity.EntityDescription(
        key="abc", entity_category=entity.EntityCategory.CONFIG)
    mock_entity2.entity_id = "hello.world"
    assert mock_entity2.entity_category == "config"
Beispiel #2
0
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)