Add capability-attributes (#29306)
This commit is contained in:
@@ -9,7 +9,7 @@ import pytest
|
||||
|
||||
from homeassistant.helpers import entity, entity_registry
|
||||
from homeassistant.core import Context
|
||||
from homeassistant.const import ATTR_HIDDEN, ATTR_DEVICE_CLASS
|
||||
from homeassistant.const import ATTR_HIDDEN, ATTR_DEVICE_CLASS, STATE_UNAVAILABLE
|
||||
from homeassistant.config import DATA_CUSTOMIZE
|
||||
from homeassistant.helpers.entity_values import EntityValues
|
||||
|
||||
@@ -641,3 +641,23 @@ async def test_disabled_in_entity_registry(hass):
|
||||
assert entry3 != entry2
|
||||
assert ent.registry_entry == entry3
|
||||
assert ent.enabled is False
|
||||
|
||||
|
||||
async def test_capability_attrs(hass):
|
||||
"""Test we still include capabilities even when unavailable."""
|
||||
with patch.object(
|
||||
entity.Entity, "available", PropertyMock(return_value=False)
|
||||
), patch.object(
|
||||
entity.Entity,
|
||||
"capability_attributes",
|
||||
PropertyMock(return_value={"always": "there"}),
|
||||
):
|
||||
ent = entity.Entity()
|
||||
ent.hass = hass
|
||||
ent.entity_id = "hello.world"
|
||||
ent.async_write_ha_state()
|
||||
|
||||
state = hass.states.get("hello.world")
|
||||
assert state is not None
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
assert state.attributes["always"] == "there"
|
||||
|
||||
Reference in New Issue
Block a user