Allow users to set device class for universal media player (#46550)

This commit is contained in:
Raman Gupta 2021-02-14 22:05:23 -05:00 committed by GitHub
parent 06c8fc6ef1
commit cfdaadf5d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 2 deletions

View file

@ -872,6 +872,25 @@ async def test_state_template(hass):
assert hass.states.get("media_player.tv").state == STATE_OFF
async def test_device_class(hass):
"""Test device_class property."""
hass.states.async_set("sensor.test_sensor", "on")
await async_setup_component(
hass,
"media_player",
{
"media_player": {
"platform": "universal",
"name": "tv",
"device_class": "tv",
}
},
)
await hass.async_block_till_done()
assert hass.states.get("media_player.tv").attributes["device_class"] == "tv"
async def test_invalid_state_template(hass):
"""Test invalid state template sets state to None."""
hass.states.async_set("sensor.test_sensor", "on")
@ -1001,6 +1020,9 @@ async def test_reload(hass):
assert hass.states.get("media_player.tv") is None
assert hass.states.get("media_player.master_bed_tv").state == "on"
assert hass.states.get("media_player.master_bed_tv").attributes["source"] == "act2"
assert (
"device_class" not in hass.states.get("media_player.master_bed_tv").attributes
)
def _get_fixtures_base_path():