Add capability-attributes (#29306)

This commit is contained in:
Paulus Schoutsen
2019-12-02 11:15:50 -08:00
committed by GitHub
parent b28bc1d6fb
commit 9771826ed6
3 changed files with 60 additions and 19 deletions
+21 -1
View File
@@ -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"