Binary Sensor for Remote UI & Fix timezone (#22076)
* Binary Sensor for Remote UI * Fix lint * Revert make hass public * Add tests
This commit is contained in:
1 parent
9520d38288
commit
17ba33004c
7 files changed
+124
-6
No files matched your search
@@ -0,0 +1,32 @@
|
||||
"""Tests for the cloud binary sensor."""
|
||||
from unittest.mock import Mock
|
||||
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.components.cloud.const import DISPATCHER_REMOTE_UPDATE
|
||||
|
||||
|
||||
async def test_remote_connection_sensor(hass):
|
||||
"""Test the remote connection sensor."""
|
||||
assert await async_setup_component(hass, 'cloud', {'cloud': {}})
|
||||
cloud = hass.data['cloud'] = Mock()
|
||||
cloud.remote.certificate = None
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get('binary_sensor.remote_ui')
|
||||
assert state is not None
|
||||
assert state.state == 'unavailable'
|
||||
|
||||
cloud.remote.is_connected = False
|
||||
cloud.remote.certificate = object()
|
||||
hass.helpers.dispatcher.async_dispatcher_send(DISPATCHER_REMOTE_UPDATE, {})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get('binary_sensor.remote_ui')
|
||||
assert state.state == 'off'
|
||||
|
||||
cloud.remote.is_connected = True
|
||||
hass.helpers.dispatcher.async_dispatcher_send(DISPATCHER_REMOTE_UPDATE, {})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get('binary_sensor.remote_ui')
|
||||
assert state.state == 'on'
|
||||
Reference in new issue
Block a user