2019-04-26 08:56:43 +02:00
|
|
|
"""Tests for the Sonos Media Player platform."""
|
2021-04-04 17:26:55 -10:00
|
|
|
from homeassistant.const import STATE_IDLE
|
2021-03-09 14:28:32 +01:00
|
|
|
from homeassistant.helpers import device_registry as dr
|
2016-07-28 22:40:58 -05:00
|
|
|
|
|
|
|
|
2021-12-08 12:28:27 -06:00
|
|
|
async def test_device_registry(hass, async_autosetup_sonos, soco):
|
2020-05-17 16:16:50 -05:00
|
|
|
"""Test sonos device registered in the device registry."""
|
2021-03-09 14:28:32 +01:00
|
|
|
device_registry = dr.async_get(hass)
|
2020-05-17 16:16:50 -05:00
|
|
|
reg_device = device_registry.async_get_device(
|
2021-01-07 14:49:45 +02:00
|
|
|
identifiers={("sonos", "RINCON_test")}
|
2020-05-17 16:16:50 -05:00
|
|
|
)
|
|
|
|
assert reg_device.model == "Model Name"
|
2021-05-23 08:43:49 -05:00
|
|
|
assert reg_device.sw_version == "13.1"
|
2021-09-28 01:36:47 +10:00
|
|
|
assert reg_device.connections == {
|
|
|
|
(dr.CONNECTION_NETWORK_MAC, "00:11:22:33:44:55"),
|
|
|
|
(dr.CONNECTION_UPNP, "uuid:RINCON_test"),
|
|
|
|
}
|
2020-05-17 16:16:50 -05:00
|
|
|
assert reg_device.manufacturer == "Sonos"
|
2021-02-19 21:28:52 -10:00
|
|
|
assert reg_device.suggested_area == "Zone A"
|
2020-05-17 16:16:50 -05:00
|
|
|
assert reg_device.name == "Zone A"
|
2021-04-04 17:26:55 -10:00
|
|
|
|
|
|
|
|
2021-12-08 12:28:27 -06:00
|
|
|
async def test_entity_basic(hass, async_autosetup_sonos, discover):
|
2021-04-04 17:26:55 -10:00
|
|
|
"""Test basic state and attributes."""
|
|
|
|
state = hass.states.get("media_player.zone_a")
|
|
|
|
assert state.state == STATE_IDLE
|
|
|
|
attributes = state.attributes
|
|
|
|
assert attributes["friendly_name"] == "Zone A"
|
|
|
|
assert attributes["is_volume_muted"] is False
|
|
|
|
assert attributes["volume_level"] == 0.19
|