Add event statistics to Sonos diagnostics (#64845)
This commit is contained in:
parent
5d7d652237
commit
ec88897d04
7 changed files with 138 additions and 47 deletions
30
tests/components/sonos/test_statistics.py
Normal file
30
tests/components/sonos/test_statistics.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
"""Tests for the Sonos statistics."""
|
||||
from homeassistant.components.sonos.const import DATA_SONOS
|
||||
|
||||
|
||||
async def test_statistics_duplicate(
|
||||
hass, async_autosetup_sonos, soco, device_properties_event
|
||||
):
|
||||
"""Test Sonos statistics."""
|
||||
speaker = list(hass.data[DATA_SONOS].discovered.values())[0]
|
||||
|
||||
subscription = soco.deviceProperties.subscribe.return_value
|
||||
sub_callback = subscription.callback
|
||||
|
||||
# Update the speaker with a callback event
|
||||
sub_callback(device_properties_event)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
report = speaker.event_stats.report()
|
||||
assert report["DeviceProperties"]["received"] == 1
|
||||
assert report["DeviceProperties"]["duplicates"] == 0
|
||||
assert report["DeviceProperties"]["processed"] == 1
|
||||
|
||||
# Ensure a duplicate is registered in the statistics
|
||||
sub_callback(device_properties_event)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
report = speaker.event_stats.report()
|
||||
assert report["DeviceProperties"]["received"] == 2
|
||||
assert report["DeviceProperties"]["duplicates"] == 1
|
||||
assert report["DeviceProperties"]["processed"] == 1
|
Loading…
Add table
Add a link
Reference in a new issue