1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Catch unexpected battery update payloads on Sonos (#52040)

This commit is contained in:
jjlawren
2021-06-20 23:38:07 -05:00
committed by GitHub
parent 067b5258c6
commit 7b5ed8faa8
2 changed files with 28 additions and 0 deletions

View File

@@ -83,3 +83,23 @@ async def test_battery_on_S1(hass, config_entry, config, soco, battery_event):
power_state = hass.states.get(power.entity_id)
assert power_state.state == STATE_OFF
assert power_state.attributes.get(ATTR_BATTERY_POWER_SOURCE) == "BATTERY"
async def test_device_payload_without_battery(
hass, config_entry, config, soco, battery_event, caplog
):
"""Test device properties event update without battery info."""
soco.get_battery_info.return_value = None
await setup_platform(hass, config_entry, config)
subscription = soco.deviceProperties.subscribe.return_value
sub_callback = subscription.callback
bad_payload = "BadKey:BadValue"
battery_event.variables["more_info"] = bad_payload
sub_callback(battery_event)
await hass.async_block_till_done()
assert bad_payload in caplog.text