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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user