Fixing the api_streams sensor (#22200)
* Fire events with websocket messages. * Added tests to validate * Fixed api_streams sensor to use new sensor * Delete from coverageac as now works. * Removed websocket request event. * Use dispatcher instead of events. * Moved sensor to under websocket_api * Changes as per code review * Fixed tests. * Modified test * Patch
This commit is contained in:
parent
2b6e197deb
commit
1ddc65a0ce
8 changed files with 142 additions and 168 deletions
30
tests/components/websocket_api/test_sensor.py
Normal file
30
tests/components/websocket_api/test_sensor.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
"""Test cases for the API stream sensor."""
|
||||
|
||||
from homeassistant.bootstrap import async_setup_component
|
||||
|
||||
from tests.common import assert_setup_component
|
||||
from .test_auth import test_auth_via_msg
|
||||
|
||||
|
||||
async def test_websocket_api(hass, no_auth_websocket_client, legacy_auth):
|
||||
"""Test API streams."""
|
||||
with assert_setup_component(1):
|
||||
await async_setup_component(hass, 'sensor', {
|
||||
'sensor': {
|
||||
'platform': 'websocket_api',
|
||||
}
|
||||
})
|
||||
|
||||
state = hass.states.get('sensor.connected_clients')
|
||||
assert state.state == '0'
|
||||
|
||||
await test_auth_via_msg(no_auth_websocket_client, legacy_auth)
|
||||
|
||||
state = hass.states.get('sensor.connected_clients')
|
||||
assert state.state == '1'
|
||||
|
||||
await no_auth_websocket_client.close()
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get('sensor.connected_clients')
|
||||
assert state.state == '0'
|
Loading…
Add table
Add a link
Reference in a new issue