Update platform back-compat for custom components without UpdateEntityFeature (#106528)

This commit is contained in:
J. Nick Koston 2023-12-28 14:10:26 -10:00 committed by GitHub
parent 81726808e8
commit 4b6aaf6254
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 4 deletions

View file

@ -865,3 +865,23 @@ async def test_name(hass: HomeAssistant) -> None:
state = hass.states.get(entity4.entity_id)
assert state
assert expected.items() <= state.attributes.items()
def test_deprecated_supported_features_ints(caplog: pytest.LogCaptureFixture) -> None:
"""Test deprecated supported features ints."""
class MockUpdateEntity(UpdateEntity):
@property
def supported_features(self) -> int:
"""Return supported features."""
return 1
entity = MockUpdateEntity()
assert entity.supported_features_compat is UpdateEntityFeature(1)
assert "MockUpdateEntity" in caplog.text
assert "is using deprecated supported features values" in caplog.text
assert "Instead it should use" in caplog.text
assert "UpdateEntityFeature.INSTALL" in caplog.text
caplog.clear()
assert entity.supported_features_compat is UpdateEntityFeature(1)
assert "is using deprecated supported features values" not in caplog.text