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:
Pascal Vizeli authored and Paulus Schoutsen committed 2019-03-15 10:59:27 -07:00
1 parent 3ec8b5a170
commit ac1aeb35a6
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'